summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-04 14:10:22 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-04 17:25:06 (GMT)
commit51ab85c398319c074200ca51f37baa0e4c47ed7c (patch)
treef59e349ad80203504590265084463865832a3289
parentbe10826bf130d7568011ec3cf97355686c298dd3 (diff)
downloadCMake-51ab85c398319c074200ca51f37baa0e4c47ed7c.zip
CMake-51ab85c398319c074200ca51f37baa0e4c47ed7c.tar.gz
CMake-51ab85c398319c074200ca51f37baa0e4c47ed7c.tar.bz2
CMakeDetermineCompilerId: Add notion of "simulated" id/version
Some compilers try to simulate other compilers as a drop-in replacement supporting all the same command-line options and predefined preprocessor macros. In such cases it will be useful to have CMake load the compiler information files for the simulated compiler instead of duplicating the information. Teach CMakeDetermineCompilerId to extract the simulated compiler id and version when the compiler id detection provides it.
-rw-r--r--Modules/CMakeCCompiler.cmake.in2
-rw-r--r--Modules/CMakeCCompilerId.c.in9
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in2
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in9
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake18
-rw-r--r--Modules/CMakePlatformId.h.in18
-rw-r--r--Source/cmDocumentVariables.cxx22
7 files changed, 79 insertions, 1 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index c41adc9..3e8d4ff 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -3,6 +3,8 @@ set(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@")
set(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@")
set(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@")
set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@")
+set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
+set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
@SET_MSVC_C_ARCHITECTURE_ID@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_RANLIB "@CMAKE_RANLIB@")
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 66a5582..48b46fa 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -206,6 +206,9 @@
because some compilers will just produce instructions to fill the
array rather than assigning a pointer to a static array. */
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
@CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
@@ -223,6 +226,12 @@ int main(int argc, char* argv[])
#ifdef COMPILER_VERSION_MAJOR
require += info_version[argc];
#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
(void)argv;
return require;
}
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index 9287b81..777f007 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -3,6 +3,8 @@ set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@")
set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
+set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
+set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
@SET_MSVC_CXX_ARCHITECTURE_ID@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_RANLIB "@CMAKE_RANLIB@")
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 5e87715..f4a4176 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -199,6 +199,9 @@
because some compilers will just produce instructions to fill the
array rather than assigning a pointer to a static array. */
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
@@ -212,6 +215,12 @@ int main(int argc, char* argv[])
#ifdef COMPILER_VERSION_MAJOR
require += info_version[argc];
#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
(void)argv;
return require;
}
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index c14372f..cf2a7bd 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -80,6 +80,8 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
+ set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
+ set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
endfunction()
#-----------------------------------------------------------------------------
@@ -309,8 +311,10 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(COMPILER_VERSION)
set(PLATFORM_ID)
set(ARCHITECTURE_ID)
+ set(SIMULATE_ID)
+ set(SIMULATE_VERSION)
file(STRINGS ${file}
- CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 4 REGEX "INFO:")
+ CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 6 REGEX "INFO:")
set(COMPILER_ID_TWICE)
foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
if("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*")
@@ -333,6 +337,14 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${COMPILER_VERSION}")
string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}")
endif()
+ if("${info}" MATCHES ".*INFO:simulate\\[([^]\"]*)\\].*")
+ set(SIMULATE_ID "${CMAKE_MATCH_1}")
+ endif()
+ if("${info}" MATCHES ".*INFO:simulate_version\\[([^]\"]*)\\].*")
+ set(SIMULATE_VERSION "${CMAKE_MATCH_1}")
+ string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
+ string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
+ endif()
endforeach()
# Detect the exact architecture from the PE header.
@@ -370,6 +382,8 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}")
set(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}")
+ set(CMAKE_${lang}_SIMULATE_ID "${SIMULATE_ID}")
+ set(CMAKE_${lang}_SIMULATE_VERSION "${SIMULATE_VERSION}")
endif()
# Check the compiler identification string.
@@ -418,6 +432,8 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
+ set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
+ set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
set(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE)
endfunction()
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 69171c2..1e41fec 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -151,6 +151,24 @@ char const info_version[] = {
']','\0'};
#endif
+/* Construct a string literal encoding the version number components. */
+#ifdef SIMULATE_VERSION_MAJOR
+char const info_simulate_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
+ SIMULATE_VERSION_MAJOR,
+# ifdef SIMULATE_VERSION_MINOR
+ '.', SIMULATE_VERSION_MINOR,
+# ifdef SIMULATE_VERSION_PATCH
+ '.', SIMULATE_VERSION_PATCH,
+# ifdef SIMULATE_VERSION_TWEAK
+ '.', SIMULATE_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
/* Construct the string literal in pieces to prevent the source from
getting matched. Store it in a pointer rather than an array
because some compilers will just produce instructions to fill the
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index c4f6216..2fafef5 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1659,6 +1659,28 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"Variables for Languages");
cm->DefineProperty
+ ("CMAKE_<LANG>_SIMULATE_ID", cmProperty::VARIABLE,
+ "Identification string of \"simulated\" compiler.",
+ "Some compilers simulate other compilers to serve as drop-in "
+ "replacements. "
+ "When CMake detects such a compiler it sets this variable to what "
+ "would have been the CMAKE_<LANG>_COMPILER_ID for the simulated "
+ "compiler.",
+ false,
+ "Variables for Languages");
+
+ cm->DefineProperty
+ ("CMAKE_<LANG>_SIMULATE_VERSION", cmProperty::VARIABLE,
+ "Version string of \"simulated\" compiler.",
+ "Some compilers simulate other compilers to serve as drop-in "
+ "replacements. "
+ "When CMake detects such a compiler it sets this variable to what "
+ "would have been the CMAKE_<LANG>_COMPILER_VERSION for the simulated "
+ "compiler.",
+ false,
+ "Variables for Languages");
+
+ cm->DefineProperty
("CMAKE_<LANG>_SIZEOF_DATA_PTR", cmProperty::VARIABLE,
"Size of pointer-to-data types for language <LANG>.",
"This holds the size (in bytes) of pointer-to-data types in the target "