summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-08-15 20:21:50 (GMT)
committerBrad King <brad.king@kitware.com>2012-08-22 19:14:33 (GMT)
commit965a69dcaa0b67c730f45487abeee97ef652d545 (patch)
tree0b16a50604aa49212594137706c22b78479fb28f
parent9a9e1ee98d59ba1ed2a89a2858224a7f8a92bbf6 (diff)
downloadCMake-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.
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake36
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake2
-rw-r--r--Modules/CompilerId/Xcode-1.pbxproj.in120
-rw-r--r--Modules/CompilerId/Xcode-2.pbxproj.in119
-rw-r--r--Modules/CompilerId/Xcode-3.pbxproj.in107
7 files changed, 387 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 3ce1a36..7f0ffee 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -44,6 +44,8 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
set(CMAKE_C_PLATFORM_ID "Windows")
set(CMAKE_C_COMPILER_ID "MSVC")
set(CMAKE_C_COMPILER "${CMAKE_GENERATOR_CC}")
+elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
+ set(CMAKE_C_COMPILER_XCODE_TYPE sourcecode.c.c)
else()
if(NOT CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER_INIT NOTFOUND)
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index 6ed2c68..110fcb1 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -43,6 +43,8 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
set(CMAKE_CXX_PLATFORM_ID "Windows")
set(CMAKE_CXX_COMPILER_ID "MSVC")
set(CMAKE_CXX_COMPILER "${CMAKE_GENERATOR_CXX}")
+elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
+ set(CMAKE_CXX_COMPILER_XCODE_TYPE sourcecode.cpp.cpp)
else()
if(NOT CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER_INIT NOTFOUND)
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(
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index 5bd514a..45213b9 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -30,6 +30,8 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
set(CMAKE_Fortran_PLATFORM_ID "Windows")
set(CMAKE_Fortran_COMPILER_ID "Intel")
set(CMAKE_Fortran_COMPILER "${CMAKE_GENERATOR_FC}")
+elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
+ set(CMAKE_Fortran_COMPILER_XCODE_TYPE sourcecode.fortran.f90)
else()
if(NOT CMAKE_Fortran_COMPILER)
# prefer the environment variable CC
diff --git a/Modules/CompilerId/Xcode-1.pbxproj.in b/Modules/CompilerId/Xcode-1.pbxproj.in
new file mode 100644
index 0000000..f06960f
--- /dev/null
+++ b/Modules/CompilerId/Xcode-1.pbxproj.in
@@ -0,0 +1,120 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 39;
+ objects = {
+ 014CEA460018CE2711CA2923 = {
+ buildSettings = {
+ };
+ isa = PBXBuildStyle;
+ name = Development;
+ };
+ 08FB7793FE84155DC02AAC07 = {
+ buildSettings = {
+ };
+ buildStyles = (
+ 014CEA460018CE2711CA2923,
+ );
+ hasScannedForEncodings = 1;
+ isa = PBXProject;
+ mainGroup = 08FB7794FE84155DC02AAC07;
+ projectDirPath = "";
+ targets = (
+ 8DD76FA90486AB0100D96B5E,
+ );
+ };
+ 08FB7794FE84155DC02AAC07 = {
+ children = (
+ 08FB7795FE84155DC02AAC07,
+ 1AB674ADFE9D54B511CA2CBB,
+ );
+ isa = PBXGroup;
+ name = CompilerId@id_lang@;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 08FB7795FE84155DC02AAC07 = {
+ children = (
+ 2C18F0B415DC1DC700593670,
+ );
+ isa = PBXGroup;
+ name = Source;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1AB674ADFE9D54B511CA2CBB = {
+ children = (
+ 8DD76F6C0486A84900D96B5E,
+ );
+ isa = PBXGroup;
+ name = Products;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 2C18F0B415DC1DC700593670 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = @id_type@;
+ path = @id_src@;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 2C18F0B615DC1E0300593670 = {
+ fileRef = 2C18F0B415DC1DC700593670;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 2C8FEB8E15DC1A1A00E56A5D = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "echo \"GCC_VERSION=$GCC_VERSION\"";
+ };
+ 8DD76FA90486AB0100D96B5E = {
+ buildPhases = (
+ 2C18F0B515DC1DCE00593670,
+ 2C8FEB8E15DC1A1A00E56A5D,
+ );
+ buildRules = (
+ );
+ buildSettings = {
+ PRODUCT_NAME = CompilerId@id_lang@;
+ SYMROOT = .;
+ };
+ dependencies = (
+ );
+ isa = PBXNativeTarget;
+ name = CompilerId@id_lang@;
+ productName = CompilerId@id_lang@;
+ productReference = 8DD76F6C0486A84900D96B5E;
+ productType = "com.apple.product-type.tool";
+ };
+ 2C18F0B515DC1DCE00593670 = {
+ buildActionMask = 2147483647;
+ files = (
+ 2C18F0B615DC1E0300593670,
+ );
+ isa = PBXSourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 8DD76F6C0486A84900D96B5E = {
+ explicitFileType = "compiled.mach-o.executable";
+ includeInIndex = 0;
+ isa = PBXFileReference;
+ path = CompilerId@id_lang@;
+ refType = 3;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ };
+ rootObject = 08FB7793FE84155DC02AAC07;
+}
diff --git a/Modules/CompilerId/Xcode-2.pbxproj.in b/Modules/CompilerId/Xcode-2.pbxproj.in
new file mode 100644
index 0000000..e3c7aa9
--- /dev/null
+++ b/Modules/CompilerId/Xcode-2.pbxproj.in
@@ -0,0 +1,119 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 42;
+ objects = {
+
+ 2C18F0B615DC1E0300593670 = {isa = PBXBuildFile; fileRef = 2C18F0B415DC1DC700593670; };
+ 2C18F0B415DC1DC700593670 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = @id_type@; path = @id_src@; sourceTree = "<group>"; };
+ 8DD76F6C0486A84900D96B5E = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CompilerId@id_lang@; sourceTree = BUILT_PRODUCTS_DIR; };
+
+ 08FB7794FE84155DC02AAC07 = {
+ isa = PBXGroup;
+ children = (
+ 08FB7795FE84155DC02AAC07,
+ 1AB674ADFE9D54B511CA2CBB,
+ );
+ name = CompilerId@id_lang@;
+ sourceTree = "<group>";
+ };
+ 08FB7795FE84155DC02AAC07 = {
+ isa = PBXGroup;
+ children = (
+ 2C18F0B415DC1DC700593670,
+ );
+ name = Source;
+ sourceTree = "<group>";
+ };
+ 1AB674ADFE9D54B511CA2CBB = {
+ isa = PBXGroup;
+ children = (
+ 8DD76F6C0486A84900D96B5E,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+
+ 8DD76FA90486AB0100D96B5E = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB928508733DD80010E9CD;
+ buildPhases = (
+ 2C18F0B515DC1DCE00593670,
+ 2C8FEB8E15DC1A1A00E56A5D,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CompilerId@id_lang@;
+ productName = CompilerId@id_lang@;
+ productReference = 8DD76F6C0486A84900D96B5E;
+ productType = "com.apple.product-type.tool";
+ };
+ 08FB7793FE84155DC02AAC07 = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB928908733DD80010E9CD;
+ hasScannedForEncodings = 1;
+ mainGroup = 08FB7794FE84155DC02AAC07;
+ projectDirPath = "";
+ targets = (
+ 8DD76FA90486AB0100D96B5E,
+ );
+ };
+ 2C8FEB8E15DC1A1A00E56A5D = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "echo \"GCC_VERSION=$GCC_VERSION\"";
+ };
+ 2C18F0B515DC1DCE00593670 = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 2C18F0B615DC1E0300593670,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 1DEB928608733DD80010E9CD = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = CompilerId@id_lang@;
+ };
+ name = Debug;
+ };
+ 1DEB928A08733DD80010E9CD = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
+ SYMROOT = .;
+ };
+ name = Debug;
+ };
+ 1DEB928508733DD80010E9CD = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB928608733DD80010E9CD,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Debug;
+ };
+ 1DEB928908733DD80010E9CD = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB928A08733DD80010E9CD,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Debug;
+ };
+ };
+ rootObject = 08FB7793FE84155DC02AAC07;
+}
diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in
new file mode 100644
index 0000000..41ca7db
--- /dev/null
+++ b/Modules/CompilerId/Xcode-3.pbxproj.in
@@ -0,0 +1,107 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+ 2C18F0B615DC1E0300593670 = {isa = PBXBuildFile; fileRef = 2C18F0B415DC1DC700593670; };
+ 2C18F0B415DC1DC700593670 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = @id_type@; path = @id_src@; sourceTree = "<group>"; };
+ 08FB7794FE84155DC02AAC07 = {
+ isa = PBXGroup;
+ children = (
+ 2C18F0B415DC1DC700593670,
+ );
+ name = CompilerId@id_lang@;
+ sourceTree = "<group>";
+ };
+ 8DD76FA90486AB0100D96B5E = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB928508733DD80010E9CD;
+ buildPhases = (
+ 2C18F0B515DC1DCE00593670,
+ 2C8FEB8E15DC1A1A00E56A5D,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CompilerId@id_lang@;
+ productName = CompilerId@id_lang@;
+ productType = "com.apple.product-type.tool";
+ };
+ 08FB7793FE84155DC02AAC07 = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB928908733DD80010E9CD;
+ compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
+ hasScannedForEncodings = 1;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 08FB7794FE84155DC02AAC07;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8DD76FA90486AB0100D96B5E,
+ );
+ };
+ 2C8FEB8E15DC1A1A00E56A5D = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "echo \"GCC_VERSION=$GCC_VERSION\"";
+ showEnvVarsInLog = 0;
+ };
+ 2C18F0B515DC1DCE00593670 = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 2C18F0B615DC1E0300593670,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 1DEB928608733DD80010E9CD = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = CompilerId@id_lang@;
+ };
+ name = Debug;
+ };
+ 1DEB928A08733DD80010E9CD = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ ONLY_ACTIVE_ARCH = YES;
+ CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
+ SYMROOT = .;
+ };
+ name = Debug;
+ };
+ 1DEB928508733DD80010E9CD = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB928608733DD80010E9CD,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Debug;
+ };
+ 1DEB928908733DD80010E9CD = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB928A08733DD80010E9CD,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Debug;
+ };
+ };
+ rootObject = 08FB7793FE84155DC02AAC07;
+}