diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-03-25 15:06:54 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-14 17:48:28 (GMT) |
commit | 8cc384f6299d60d705330f712031c2851498aa62 (patch) | |
tree | fe27164dc9a9fcac22c9ffd67a8e8396ddfa491a /Modules/CMakeDetermineCompiler.cmake | |
parent | 37fa5122c2c1e2138b9e01191dc3cc1800f6ba40 (diff) | |
download | CMake-8cc384f6299d60d705330f712031c2851498aa62.zip CMake-8cc384f6299d60d705330f712031c2851498aa62.tar.gz CMake-8cc384f6299d60d705330f712031c2851498aa62.tar.bz2 |
Compilers: Add paths from -print-sysroot to system prefix path
Diffstat (limited to 'Modules/CMakeDetermineCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompiler.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index c37adae..7afae8a 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -118,3 +118,18 @@ macro(_cmake_find_compiler_path lang) endif() endif() endmacro() + +function(_cmake_find_compiler_sysroot lang) + if(CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -print-sysroot + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _cmake_sysroot_run_out + ERROR_VARIABLE _cmake_sysroot_run_err) + + if(_cmake_sysroot_run_out AND NOT _cmake_sysroot_run_err AND IS_DIRECTORY "${_cmake_sysroot_run_out}/usr") + set(CMAKE_${lang}_COMPILER_SYSROOT "${_cmake_sysroot_run_out}/usr" PARENT_SCOPE) + else() + set(CMAKE_${lang}_COMPILER_SYSROOT "" PARENT_SCOPE) + endif() + endif() +endfunction() |