180c60a86f
Previously we checked for this flag by parsing the version number of GCC out of 'gcc --version', but this is not reliable because the format can vary greatly. Now we run 'gcc -v --help' and look for '-isysroot' in the list of options. We also now store the result on a per-language basis in the per-compiler info file "CMake<LANG>Compiler.cmake". This is necessary to make it accessible from try-compile projects so that they generate correctly.
19 lines
602 B
CMake
19 lines
602 B
CMake
macro(cmake_gnu_has_isysroot lang)
|
|
if("x${CMAKE_${lang}_HAS_ISYSROOT}" STREQUAL "x")
|
|
set(_doc "${lang} compiler has -isysroot")
|
|
message(STATUS "Checking whether ${_doc}")
|
|
execute_process(
|
|
COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
|
|
OUTPUT_VARIABLE _gcc_help
|
|
ERROR_VARIABLE _gcc_help
|
|
)
|
|
if("${_gcc_help}" MATCHES "isysroot")
|
|
message(STATUS "Checking whether ${_doc} - yes")
|
|
set(CMAKE_${lang}_HAS_ISYSROOT 1)
|
|
else()
|
|
message(STATUS "Checking whether ${_doc} - no")
|
|
set(CMAKE_${lang}_HAS_ISYSROOT 0)
|
|
endif()
|
|
endif()
|
|
endmacro()
|