CMakeDetermineCompiler: Factor out xcrun invocation into a macro
This will allow it to be re-used in multiple code paths later.
This commit is contained in:
parent
472553b4c1
commit
85d3173590
|
@ -72,12 +72,19 @@ macro(_cmake_find_compiler lang)
|
||||||
|
|
||||||
# Look for a make tool provided by Xcode
|
# Look for a make tool provided by Xcode
|
||||||
if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE)
|
if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE)
|
||||||
foreach(comp ${CMAKE_${lang}_COMPILER_LIST})
|
macro(_query_xcrun compiler_name result_var_keyword result_var)
|
||||||
execute_process(COMMAND xcrun --find ${comp}
|
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
|
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
ERROR_VARIABLE _xcrun_err)
|
ERROR_VARIABLE _xcrun_err)
|
||||||
if(_xcrun_out)
|
set("${result_var}" "${_xcrun_out}")
|
||||||
set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_out}")
|
endmacro()
|
||||||
|
foreach(comp ${CMAKE_${lang}_COMPILER_LIST})
|
||||||
|
_query_xcrun("${comp}" RESULT_VAR _xcrun_result)
|
||||||
|
if(_xcrun_result)
|
||||||
|
set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_result}")
|
||||||
break()
|
break()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
Loading…
Reference in New Issue