diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh index eaabb37f4987..f6dd5460c352 100755 --- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -70,15 +70,25 @@ else fi makeCmakeFindLibs(){ + isystem_seen= for flag in $NIX_CFLAGS_COMPILE $NIX_LDFLAGS; do - case $flag in - -I*) - export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH${CMAKE_INCLUDE_PATH:+:}${flag:2}" - ;; - -L*) - export CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH${CMAKE_LIBRARY_PATH:+:}${flag:2}" - ;; - esac + if test -n "$isystem_seen" && test -d "$flag"; then + isystem_seen= + export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH${CMAKE_INCLUDE_PATH:+:}${flag}" + else + isystem_seen= + case $flag in + -I*) + export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH${CMAKE_INCLUDE_PATH:+:}${flag:2}" + ;; + -L*) + export CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH${CMAKE_LIBRARY_PATH:+:}${flag:2}" + ;; + -isystem) + isystem_seen=1 + ;; + esac + fi done }