summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerId.cmake
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 /Modules/CMakeDetermineCompilerId.cmake
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.
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake18
1 files changed, 17 insertions, 1 deletions
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()