1 diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
2 index b9381c3d7d..5e944640b5 100644
3 --- a/Modules/Platform/UnixPaths.cmake
4 +++ b/Modules/Platform/UnixPaths.cmake
5 @@ -26,9 +26,6 @@ get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
6 # please make sure to keep Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst
8 list(APPEND CMAKE_SYSTEM_PREFIX_PATH
12 # CMake install location
13 "${_CMAKE_INSTALL_DIR}"
15 @@ -47,48 +44,49 @@ endif()
17 # Non "standard" but common install prefixes
18 list(APPEND CMAKE_SYSTEM_PREFIX_PATH
24 # List common include file locations not under the common prefixes.
25 +if(DEFINED ENV{NIX_CC}
26 + AND IS_DIRECTORY "$ENV{NIX_CC}"
27 + AND EXISTS "$ENV{NIX_CC}/nix-support/orig-libc"
28 + AND EXISTS "$ENV{NIX_CC}/nix-support/orig-libc-dev")
29 + file(STRINGS "$ENV{NIX_CC}/nix-support/orig-libc" _nix_cmake_libc)
30 + file(STRINGS "$ENV{NIX_CC}/nix-support/orig-libc-dev" _nix_cmake_libc_dev)
32 + set(_nix_cmake_libc @libc_lib@)
33 + set(_nix_cmake_libc_dev @libc_dev@)
36 list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
39 + "${_nix_cmake_libc_dev}/include"
42 list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
45 + "${_nix_cmake_libc}/lib"
48 list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
49 - /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
50 + "${_nix_cmake_libc}/lib"
53 -if(CMAKE_SYSROOT_COMPILE)
54 - set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
56 - set(_cmake_sysroot_compile "${CMAKE_SYSROOT}")
59 # Default per-language values. These may be later replaced after
60 # parsing the implicit directory information from compiler output.
61 set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
62 ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
63 - "${_cmake_sysroot_compile}/usr/include"
64 + "${_nix_cmake_libc_dev}/include"
66 set(_CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES_INIT
67 ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}
68 - "${_cmake_sysroot_compile}/usr/include"
69 + "${_nix_cmake_libc_dev}/include"
71 set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
72 ${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}
73 - "${_cmake_sysroot_compile}/usr/include"
74 + "${_nix_cmake_libc_dev}/include"
77 -unset(_cmake_sysroot_compile)
78 +unset(_nix_cmake_libc)
79 +unset(_nix_cmake_libc_dev)
81 # Reminder when adding new locations computed from environment variables
82 # please make sure to keep Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst
83 diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake
84 index b9e2f17979..ab517cd4a7 100644
85 --- a/Modules/Platform/WindowsPaths.cmake
86 +++ b/Modules/Platform/WindowsPaths.cmake
87 @@ -70,7 +70,7 @@ endif()
89 if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
90 # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
91 - list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
92 + # list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
95 list(APPEND CMAKE_SYSTEM_INCLUDE_PATH