mirror of
https://github.com/reactos/CMake.git
synced 2024-12-05 02:06:34 +00:00
9502276f82
Since commit7cd65c97fa
(Add CMAKE_SYSROOT variable to set --sysroot when cross compiling., 2013-04-13, v3.0.0-rc1~342^2) we have prefixed the value of `CMAKE_SYSROOT` to implicit include directories. This was done because we hard-coded `/usr/include` as an implicit include directory without accounting for the sysroot. Instead we should prefix the hard-coded paths when they are constructed. Update the `Platform/UnixPaths` module to do this as `Platform/Darwin` already does. Since commit5990ecb741
(Compute implicit include directories from compiler output, 2018-12-07, v3.14.0-rc1~108^2) the values of the `CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` variables are computed from a real compiler invocation so they already account for the sysroot prefix. In commit6fc3382944
(Update logic for sysroot in detected implicit include directories, 2019-02-13, v3.14.0-rc2~6^2) we attempted to apply the prefix conditionally, but that is incorrect because the compiler's real implicit include directories are not all under the sysroot. Instead assume that all implicit include directories in `CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` already have the sysroot prefix if needed. Code that constructs the value must be responsible for that because it is the only place that knows.
93 lines
2.7 KiB
CMake
93 lines
2.7 KiB
CMake
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
|
# Block multiple inclusion because "CMakeCInformation.cmake" includes
|
|
# "Platform/${CMAKE_SYSTEM_NAME}" even though the generic module
|
|
# "CMakeSystemSpecificInformation.cmake" already included it.
|
|
# The extra inclusion is a work-around documented next to the include()
|
|
# call, so this can be removed when the work-around is removed.
|
|
if(__UNIX_PATHS_INCLUDED)
|
|
return()
|
|
endif()
|
|
set(__UNIX_PATHS_INCLUDED 1)
|
|
|
|
set(UNIX 1)
|
|
|
|
# also add the install directory of the running cmake to the search directories
|
|
# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up
|
|
get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
|
|
get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
|
|
|
|
# List common installation prefixes. These will be used for all
|
|
# search types.
|
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
|
# Standard
|
|
/usr/local /usr /
|
|
|
|
# CMake install location
|
|
"${_CMAKE_INSTALL_DIR}"
|
|
)
|
|
if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
|
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
|
# Project install destination.
|
|
"${CMAKE_INSTALL_PREFIX}"
|
|
)
|
|
if(CMAKE_STAGING_PREFIX)
|
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
|
# User-supplied staging prefix.
|
|
"${CMAKE_STAGING_PREFIX}"
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
# Non "standard" but common install prefixes
|
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
|
/usr/X11R6
|
|
/usr/pkg
|
|
/opt
|
|
)
|
|
|
|
# List common include file locations not under the common prefixes.
|
|
list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
|
|
# X11
|
|
/usr/include/X11
|
|
)
|
|
|
|
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
|
|
# X11
|
|
/usr/lib/X11
|
|
)
|
|
|
|
list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
|
|
/lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
|
|
)
|
|
|
|
if(CMAKE_SYSROOT_COMPILE)
|
|
set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
|
|
else()
|
|
set(_cmake_sysroot_compile "${CMAKE_SYSROOT}")
|
|
endif()
|
|
|
|
# Default per-language values. These may be later replaced after
|
|
# parsing the implicit directory information from compiler output.
|
|
set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
|
|
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
|
|
"${_cmake_sysroot_compile}/usr/include"
|
|
)
|
|
set(_CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES_INIT
|
|
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}
|
|
"${_cmake_sysroot_compile}/usr/include"
|
|
)
|
|
set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
|
|
${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}
|
|
"${_cmake_sysroot_compile}/usr/include"
|
|
)
|
|
|
|
unset(_cmake_sysroot_compile)
|
|
|
|
# Enable use of lib32 and lib64 search path variants by default.
|
|
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
|
|
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
|
|
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS TRUE)
|