summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-15 14:54:12 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-01-15 14:54:12 (GMT)
commite7c1836e044689c0a55d9fcacd94d88ef8b9ec19 (patch)
tree74d5e5ebba0037c574e594ee1c4b87dc46414cb6 /Modules
parentff1727af778301c2a53007098bd31fe7b9af6c40 (diff)
parentda928d305b10445c2a736597d87fb2a8c4409eb7 (diff)
downloadCMake-e7c1836e044689c0a55d9fcacd94d88ef8b9ec19.zip
CMake-e7c1836e044689c0a55d9fcacd94d88ef8b9ec19.tar.gz
CMake-e7c1836e044689c0a55d9fcacd94d88ef8b9ec19.tar.bz2
Merge topic 'Apple-compiler-selection'
da928d30 Help: Add notes for topic 'Apple-compiler-selection' 1f085e11 OS X: Resolve compiler in /usr/bin to that reported by Xcode xcrun 85d31735 CMakeDetermineCompiler: Factor out xcrun invocation into a macro
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCompiler.cmake31
1 files changed, 23 insertions, 8 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake
index 0ab3af6..85c8662 100644
--- a/Modules/CMakeDetermineCompiler.cmake
+++ b/Modules/CMakeDetermineCompiler.cmake
@@ -71,16 +71,31 @@ macro(_cmake_find_compiler lang)
unset(_languages)
# Look for a make tool provided by Xcode
- if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE)
- foreach(comp ${CMAKE_${lang}_COMPILER_LIST})
- execute_process(COMMAND xcrun --find ${comp}
+ if(CMAKE_HOST_APPLE)
+ macro(_query_xcrun compiler_name result_var_keyword result_var)
+ if(NOT "x${result_var_keyword}" STREQUAL "xRESULT_VAR")
+ message(FATAL_ERROR "Bad arguments to macro")
+ endif()
+ execute_process(COMMAND xcrun --find ${compiler_name}
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE _xcrun_err)
- if(_xcrun_out)
- set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_out}")
- break()
- endif()
- endforeach()
+ set("${result_var}" "${_xcrun_out}")
+ endmacro()
+
+ set(xcrun_result)
+ if (CMAKE_${lang}_COMPILER MATCHES "^/usr/bin/(.+)$")
+ _query_xcrun("${CMAKE_MATCH_1}" RESULT_VAR xcrun_result)
+ elseif (CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND")
+ foreach(comp ${CMAKE_${lang}_COMPILER_LIST})
+ _query_xcrun("${comp}" RESULT_VAR xcrun_result)
+ if(xcrun_result)
+ break()
+ endif()
+ endforeach()
+ endif()
+ if (xcrun_result)
+ set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${xcrun_result}")
+ endif()
endif()
endmacro()