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 xcrun85d31735
CMakeDetermineCompiler: Factor out xcrun invocation into a macro
This commit is contained in:
commit
e7c1836e04
|
@ -0,0 +1,8 @@
|
|||
Apple-compiler-selection
|
||||
------------------------
|
||||
|
||||
* On OS X with Makefile and Ninja generators, when a compiler is found
|
||||
in ``/usr/bin`` it is now mapped to the corresponding compiler inside
|
||||
the Xcode application folder, if any. This allows such build
|
||||
trees to continue to work with their original compiler even when
|
||||
``xcode-select`` switches to a different Xcode installation.
|
|
@ -71,17 +71,32 @@ 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}")
|
||||
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()
|
||||
|
||||
macro(_cmake_find_compiler_path lang)
|
||||
|
|
Loading…
Reference in New Issue