diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-01-13 22:10:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-01-14 20:26:26 (GMT) |
commit | 85d3173590e4bae63e8422ac8083a77806491b92 (patch) | |
tree | b4a639e1b78db960b05e3614880ad1fa199c7549 | |
parent | 472553b4c152e741cfafc11cdca48a5bfeae4206 (diff) | |
download | CMake-85d3173590e4bae63e8422ac8083a77806491b92.zip CMake-85d3173590e4bae63e8422ac8083a77806491b92.tar.gz CMake-85d3173590e4bae63e8422ac8083a77806491b92.tar.bz2 |
CMakeDetermineCompiler: Factor out xcrun invocation into a macro
This will allow it to be re-used in multiple code paths later.
-rw-r--r-- | Modules/CMakeDetermineCompiler.cmake | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index 0ab3af6..7a5cbcd 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -72,12 +72,19 @@ macro(_cmake_find_compiler lang) # 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} + 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() + 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() endif() endforeach() |