diff options
author | Brad King <brad.king@kitware.com> | 2012-08-15 20:21:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-08-22 19:14:33 (GMT) |
commit | 965a69dcaa0b67c730f45487abeee97ef652d545 (patch) | |
tree | 0b16a50604aa49212594137706c22b78479fb28f /Modules/CMakeDetermineCompilerId.cmake | |
parent | 9a9e1ee98d59ba1ed2a89a2858224a7f8a92bbf6 (diff) | |
download | CMake-965a69dcaa0b67c730f45487abeee97ef652d545.zip CMake-965a69dcaa0b67c730f45487abeee97ef652d545.tar.gz CMake-965a69dcaa0b67c730f45487abeee97ef652d545.tar.bz2 |
Xcode: Detect the compiler id and tool location
Configure a hand-generated Xcode project to build the compiler id source
file since we cannot run the compiler command-line tool directly. Add a
post-build shell script phase to print out the compiler toolset build
setting. Run xcodebuild to compile the identification binary. Parse
the full path to the compiler tool from the xcodebuild output.
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f4b9bb0..d0c1ea5 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -107,7 +107,41 @@ Id flags: ${testflags} ") # Compile the compiler identification source. - if(0) + if("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(id_lang "${lang}") + set(id_type ${CMAKE_${lang}_COMPILER_XCODE_TYPE}) + set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) + get_filename_component(id_src "${src}" NAME) + if(NOT ${XCODE_VERSION} VERSION_LESS 3) + set(v 3) + set(ext xcodeproj) + elseif(NOT ${XCODE_VERSION} VERSION_LESS 2) + set(v 2) + set(ext xcodeproj) + else() + set(v 1) + set(ext xcode) + endif() + configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in + ${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY IMMEDIATE) + execute_process(COMMAND xcodebuild + WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT + ) + + # Match the link line from xcodebuild output of the form + # Ld ... + # ... + # /path/to/cc ...CompilerId${lang}/... + # to extract the compiler front-end for the language. + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/\\./CompilerId${lang}[ \t\n\\\"]") + set(_comp "${CMAKE_MATCH_2}") + if(EXISTS "${_comp}") + set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) + endif() + endif() else() if(COMMAND EXECUTE_PROCESS) execute_process( |