summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-06-10 13:17:43 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-06-10 13:17:43 (GMT)
commit487b6ccdcd7612768d920050dd0b0b67cd32775f (patch)
tree92679bb17a59ebfa7a9533eb4da8580b39ceffa1 /Modules
parente0471ae2f93ef46461ff462bbc9e3be9b64c55ed (diff)
parentddec418a8f27e62ae9f37cd03d28a42eeaa1527f (diff)
downloadCMake-487b6ccdcd7612768d920050dd0b0b67cd32775f.zip
CMake-487b6ccdcd7612768d920050dd0b0b67cd32775f.tar.gz
CMake-487b6ccdcd7612768d920050dd0b0b67cd32775f.tar.bz2
Merge topic 'WriteCompilerDetectionHeader-compiler-versions'
ddec418a Features: Add compiler version support to WriteCompilerDetectionHeader. b7029576 Project: Add configurable name for version computation macros. 78acaafe Project: Separate simulated compiler id from version detection. 567af1a5 WCDH: Issue a better message for version compatibility.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeCompilerIdDetection.cmake7
-rw-r--r--Modules/Compiler/ADSP-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/AppleClang-DetermineCompiler.cmake2
-rw-r--r--Modules/Compiler/Borland-DetermineCompiler.cmake4
-rw-r--r--Modules/Compiler/Clang-DetermineCompilerInternal.cmake16
-rw-r--r--Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake4
-rw-r--r--Modules/Compiler/Compaq-C-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/Cray-DetermineCompiler.cmake4
-rw-r--r--Modules/Compiler/Embarcadero-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/GNU-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/HP-C-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/HP-CXX-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake6
-rw-r--r--Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake6
-rw-r--r--Modules/Compiler/Intel-DetermineCompiler.cmake20
-rw-r--r--Modules/Compiler/MIPSpro-DetermineCompiler.cmake12
-rw-r--r--Modules/Compiler/MSVC-DetermineCompiler.cmake10
-rw-r--r--Modules/Compiler/OpenWatcom-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/PGI-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/PathScale-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/SDCC-C-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/SunPro-C-DetermineCompiler.cmake12
-rw-r--r--Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake12
-rw-r--r--Modules/Compiler/TI-DetermineCompiler.cmake6
-rw-r--r--Modules/Compiler/Watcom-DetermineCompiler.cmake6
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake60
27 files changed, 160 insertions, 93 deletions
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake
index d8a0d67..7f82a9d 100644
--- a/Modules/CMakeCompilerIdDetection.cmake
+++ b/Modules/CMakeCompilerIdDetection.cmake
@@ -17,6 +17,7 @@ function(_readFile file)
get_filename_component(name ${file} NAME_WE)
string(REGEX REPLACE "-.*" "" CompilerId ${name})
set(_compiler_id_version_compute_${CompilerId} ${_compiler_id_version_compute} PARENT_SCOPE)
+ set(_compiler_id_simulate_${CompilerId} ${_compiler_id_simulate} PARENT_SCOPE)
set(_compiler_id_pp_test_${CompilerId} ${_compiler_id_pp_test} PARENT_SCOPE)
endfunction()
@@ -114,7 +115,9 @@ function(compiler_id_detection outvar lang)
endif()
set(id_content "${pp_if} ${_compiler_id_pp_test_${Id}}\n")
if (CID_ID_STRING)
- set(id_content "${id_content}# define ${CID_PREFIX}COMPILER_ID \"${Id}\"")
+ set(PREFIX ${CID_PREFIX})
+ string(CONFIGURE "${_compiler_id_simulate_${Id}}" SIMULATE_BLOCK @ONLY)
+ set(id_content "${id_content}# define ${CID_PREFIX}COMPILER_ID \"${Id}\"${SIMULATE_BLOCK}")
endif()
if (CID_ID_DEFINE)
set(id_content "${id_content}# undef ${CID_PREFIX}COMPILER_IS_${Id}\n")
@@ -122,6 +125,8 @@ function(compiler_id_detection outvar lang)
endif()
if (CID_VERSION_STRINGS)
set(PREFIX ${CID_PREFIX})
+ set(MACRO_DEC DEC)
+ set(MACRO_HEX HEX)
string(CONFIGURE "${_compiler_id_version_compute_${Id}}" VERSION_BLOCK @ONLY)
set(id_content "${id_content}${VERSION_BLOCK}\n")
endif()
diff --git a/Modules/Compiler/ADSP-DetermineCompiler.cmake b/Modules/Compiler/ADSP-DetermineCompiler.cmake
index 0b5af0d..0340f69 100644
--- a/Modules/Compiler/ADSP-DetermineCompiler.cmake
+++ b/Modules/Compiler/ADSP-DetermineCompiler.cmake
@@ -4,7 +4,7 @@ set(_compiler_id_pp_test "defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFI
set(_compiler_id_version_compute "
#if defined(__VISUALDSPVERSION__)
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
-# define @PREFIX@COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__VISUALDSPVERSION__>>24)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__VISUALDSPVERSION__>>16 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__VISUALDSPVERSION__>>8 & 0xFF)
#endif")
diff --git a/Modules/Compiler/AppleClang-DetermineCompiler.cmake b/Modules/Compiler/AppleClang-DetermineCompiler.cmake
index d293b7b..397f95c 100644
--- a/Modules/Compiler/AppleClang-DetermineCompiler.cmake
+++ b/Modules/Compiler/AppleClang-DetermineCompiler.cmake
@@ -4,4 +4,4 @@ set(_compiler_id_pp_test "defined(__clang__) && defined(__apple_build_version__)
include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake")
set(_compiler_id_version_compute "${_compiler_id_version_compute}
-# define @PREFIX@COMPILER_VERSION_TWEAK DEC(__apple_build_version__)")
+# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__apple_build_version__)")
diff --git a/Modules/Compiler/Borland-DetermineCompiler.cmake b/Modules/Compiler/Borland-DetermineCompiler.cmake
index 2e8a948..ef3083b 100644
--- a/Modules/Compiler/Borland-DetermineCompiler.cmake
+++ b/Modules/Compiler/Borland-DetermineCompiler.cmake
@@ -3,5 +3,5 @@ set(_compiler_id_pp_test "defined(__BORLANDC__)")
set(_compiler_id_version_compute "
/* __BORLANDC__ = 0xVRR */
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__BORLANDC__>>8)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__BORLANDC__ & 0xFF)")
diff --git a/Modules/Compiler/Clang-DetermineCompilerInternal.cmake b/Modules/Compiler/Clang-DetermineCompilerInternal.cmake
index 9a37a63..08c1230 100644
--- a/Modules/Compiler/Clang-DetermineCompilerInternal.cmake
+++ b/Modules/Compiler/Clang-DetermineCompilerInternal.cmake
@@ -1,11 +1,15 @@
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__clang_major__)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__clang_minor__)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__clang_major__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__clang_minor__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__clang_patchlevel__)
# if defined(_MSC_VER)
-# define @PREFIX@SIMULATE_ID \"MSVC\"
/* _MSC_VER = VVRR */
-# define @PREFIX@SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
-# define @PREFIX@SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100)
+# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100)
+# endif")
+
+set(_compiler_id_simulate "
+# if defined(_MSC_VER)
+# define @PREFIX@SIMULATE_ID \"MSVC\"
# endif")
diff --git a/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake b/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake
index e4def4d..2265e5e 100644
--- a/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake
+++ b/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake
@@ -3,5 +3,5 @@ set(_compiler_id_pp_test "defined(__COMO__)")
set(_compiler_id_version_compute "
/* __COMO_VERSION__ = VRR */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__COMO_VERSION__ / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__COMO_VERSION__ % 100)")
diff --git a/Modules/Compiler/Compaq-C-DetermineCompiler.cmake b/Modules/Compiler/Compaq-C-DetermineCompiler.cmake
index 56fedb1..02e99dc 100644
--- a/Modules/Compiler/Compaq-C-DetermineCompiler.cmake
+++ b/Modules/Compiler/Compaq-C-DetermineCompiler.cmake
@@ -3,6 +3,6 @@ set(_compiler_id_pp_test "defined(__DECC)")
set(_compiler_id_version_compute "
/* __DECC_VER = VVRRTPPPP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__DECC_VER/10000000)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__DECC_VER/100000 % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__DECC_VER % 10000)")
diff --git a/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake b/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake
index 5855c24..c7d0565 100644
--- a/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake
+++ b/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake
@@ -3,6 +3,6 @@ set(_compiler_id_pp_test "defined(__DECCXX)")
set(_compiler_id_version_compute "
/* __DECCXX_VER = VVRRTPPPP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__DECCXX_VER/10000000)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__DECCXX_VER/100000 % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__DECCXX_VER % 10000)")
diff --git a/Modules/Compiler/Cray-DetermineCompiler.cmake b/Modules/Compiler/Cray-DetermineCompiler.cmake
index 6e4eaf9..881b82c 100644
--- a/Modules/Compiler/Cray-DetermineCompiler.cmake
+++ b/Modules/Compiler/Cray-DetermineCompiler.cmake
@@ -2,5 +2,5 @@
set(_compiler_id_pp_test "defined(_CRAYC)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(_RELEASE)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_RELEASE)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_RELEASE_MINOR)")
diff --git a/Modules/Compiler/Embarcadero-DetermineCompiler.cmake b/Modules/Compiler/Embarcadero-DetermineCompiler.cmake
index f52d79b..2feedac 100644
--- a/Modules/Compiler/Embarcadero-DetermineCompiler.cmake
+++ b/Modules/Compiler/Embarcadero-DetermineCompiler.cmake
@@ -2,6 +2,6 @@
set(_compiler_id_pp_test "defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
-# define @PREFIX@COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__CODEGEARC_VERSION__>>24 & 0x00FF)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__CODEGEARC_VERSION__>>16 & 0x00FF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__CODEGEARC_VERSION__ & 0xFFFF)")
diff --git a/Modules/Compiler/GNU-DetermineCompiler.cmake b/Modules/Compiler/GNU-DetermineCompiler.cmake
index f0c25dd..261f148 100644
--- a/Modules/Compiler/GNU-DetermineCompiler.cmake
+++ b/Modules/Compiler/GNU-DetermineCompiler.cmake
@@ -2,8 +2,8 @@
set(_compiler_id_pp_test "defined(__GNUC__)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__GNUC__)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GNUC__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__)
# if defined(__GNUC_PATCHLEVEL__)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__)
# endif")
diff --git a/Modules/Compiler/HP-C-DetermineCompiler.cmake b/Modules/Compiler/HP-C-DetermineCompiler.cmake
index 024a658..4269799 100644
--- a/Modules/Compiler/HP-C-DetermineCompiler.cmake
+++ b/Modules/Compiler/HP-C-DetermineCompiler.cmake
@@ -3,6 +3,6 @@ set(_compiler_id_pp_test "defined(__HP_cc)")
set(_compiler_id_version_compute "
/* __HP_cc = VVRRPP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__HP_cc % 100)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__HP_cc/10000)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__HP_cc/100 % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__HP_cc % 100)")
diff --git a/Modules/Compiler/HP-CXX-DetermineCompiler.cmake b/Modules/Compiler/HP-CXX-DetermineCompiler.cmake
index 6999492..3d4d7e4 100644
--- a/Modules/Compiler/HP-CXX-DetermineCompiler.cmake
+++ b/Modules/Compiler/HP-CXX-DetermineCompiler.cmake
@@ -3,6 +3,6 @@ set(_compiler_id_pp_test "defined(__HP_aCC)")
set(_compiler_id_version_compute "
/* __HP_aCC = VVRRPP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__HP_aCC/10000)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__HP_aCC/100 % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__HP_aCC % 100)")
diff --git a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake
index 6169ab4..899e284 100644
--- a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake
+++ b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake
@@ -1,6 +1,6 @@
set(_compiler_id_version_compute "
/* __IBMC__ = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMC__/100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMC__/10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMC__ % 10)")
diff --git a/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake
index f673d72..73aa2b4 100644
--- a/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake
+++ b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake
@@ -1,6 +1,6 @@
set(_compiler_id_version_compute "
/* __IBMCPP__ = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMCPP__/100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMCPP__/10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMCPP__ % 10)")
diff --git a/Modules/Compiler/Intel-DetermineCompiler.cmake b/Modules/Compiler/Intel-DetermineCompiler.cmake
index 6fada1c..d7e4532 100644
--- a/Modules/Compiler/Intel-DetermineCompiler.cmake
+++ b/Modules/Compiler/Intel-DetermineCompiler.cmake
@@ -3,20 +3,24 @@ set(_compiler_id_pp_test "defined(__INTEL_COMPILER) || defined(__ICC)")
set(_compiler_id_version_compute "
/* __INTEL_COMPILER = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEL_COMPILER/100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEL_COMPILER/10 % 10)
# if defined(__INTEL_COMPILER_UPDATE)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER_UPDATE)
# else
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER % 10)
# endif
# if defined(__INTEL_COMPILER_BUILD_DATE)
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
-# define @PREFIX@COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
+# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__INTEL_COMPILER_BUILD_DATE)
# endif
# if defined(_MSC_VER)
-# define @PREFIX@SIMULATE_ID \"MSVC\"
/* _MSC_VER = VVRR */
-# define @PREFIX@SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
-# define @PREFIX@SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100)
+# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100)
+# endif")
+
+set(_compiler_id_simulate "
+# if defined(_MSC_VER)
+# define @PREFIX@SIMULATE_ID \"MSVC\"
# endif")
diff --git a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
index 31eb345..9e48553 100644
--- a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
+++ b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
@@ -4,12 +4,12 @@ set(_compiler_id_pp_test "defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VE
set(_compiler_id_version_compute "
# if defined(_SGI_COMPILER_VERSION)
/* _SGI_COMPILER_VERSION = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_SGI_COMPILER_VERSION/100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_SGI_COMPILER_VERSION/10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_SGI_COMPILER_VERSION % 10)
# else
/* _COMPILER_VERSION = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_COMPILER_VERSION/100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_COMPILER_VERSION/10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_COMPILER_VERSION % 10)
# endif")
diff --git a/Modules/Compiler/MSVC-DetermineCompiler.cmake b/Modules/Compiler/MSVC-DetermineCompiler.cmake
index d462d07..313de89 100644
--- a/Modules/Compiler/MSVC-DetermineCompiler.cmake
+++ b/Modules/Compiler/MSVC-DetermineCompiler.cmake
@@ -3,17 +3,17 @@ set(_compiler_id_pp_test "defined(_MSC_VER)")
set(_compiler_id_version_compute "
/* _MSC_VER = VVRR */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100)
# if defined(_MSC_FULL_VER)
# if _MSC_VER >= 1400
/* _MSC_FULL_VER = VVRRPPPPP */
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_MSC_FULL_VER % 100000)
# else
/* _MSC_FULL_VER = VVRRPPPP */
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_MSC_FULL_VER % 10000)
# endif
# endif
# if defined(_MSC_BUILD)
-# define @PREFIX@COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(_MSC_BUILD)
# endif")
diff --git a/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake b/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake
index 6d416c1..2ed116c 100644
--- a/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake
+++ b/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake
@@ -3,8 +3,8 @@ set(_compiler_id_pp_test "defined(__WATCOMC__)")
set(_compiler_id_version_compute "
/* __WATCOMC__ = VVRP + 1100 */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__WATCOMC__ - 1100) / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__WATCOMC__ / 10) % 10)
# if (__WATCOMC__ % 10) > 0
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__WATCOMC__ % 10)
# endif")
diff --git a/Modules/Compiler/PGI-DetermineCompiler.cmake b/Modules/Compiler/PGI-DetermineCompiler.cmake
index 8e68bd6..8d3dc9c 100644
--- a/Modules/Compiler/PGI-DetermineCompiler.cmake
+++ b/Modules/Compiler/PGI-DetermineCompiler.cmake
@@ -2,8 +2,8 @@
set(_compiler_id_pp_test "defined(__PGI)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__PGIC__)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__PGIC__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__PGIC_MINOR__)
# if defined(__PGIC_PATCHLEVEL__)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__PGIC_PATCHLEVEL__)
# endif")
diff --git a/Modules/Compiler/PathScale-DetermineCompiler.cmake b/Modules/Compiler/PathScale-DetermineCompiler.cmake
index 3335e26..4eb81de 100644
--- a/Modules/Compiler/PathScale-DetermineCompiler.cmake
+++ b/Modules/Compiler/PathScale-DetermineCompiler.cmake
@@ -2,8 +2,8 @@
set(_compiler_id_pp_test "defined(__PATHCC__)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__PATHCC__)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__PATHCC__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__PATHCC_MINOR__)
# if defined(__PATHCC_PATCHLEVEL__)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__PATHCC_PATCHLEVEL__)
# endif")
diff --git a/Modules/Compiler/SDCC-C-DetermineCompiler.cmake b/Modules/Compiler/SDCC-C-DetermineCompiler.cmake
index 8fe60d9..1d7dd78 100644
--- a/Modules/Compiler/SDCC-C-DetermineCompiler.cmake
+++ b/Modules/Compiler/SDCC-C-DetermineCompiler.cmake
@@ -5,6 +5,6 @@ set(_compiler_id_pp_test "defined(SDCC)")
set(_compiler_id_version_compute "
/* SDCC = VRP */
-# define COMPILER_VERSION_MAJOR DEC(SDCC/100)
-# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
-# define COMPILER_VERSION_PATCH DEC(SDCC % 10)")
+# define COMPILER_VERSION_MAJOR @MACRO_DEC@(SDCC/100)
+# define COMPILER_VERSION_MINOR @MACRO_DEC@(SDCC/10 % 10)
+# define COMPILER_VERSION_PATCH @MACRO_DEC@(SDCC % 10)")
diff --git a/Modules/Compiler/SunPro-C-DetermineCompiler.cmake b/Modules/Compiler/SunPro-C-DetermineCompiler.cmake
index 7db1a97..e9d7457 100644
--- a/Modules/Compiler/SunPro-C-DetermineCompiler.cmake
+++ b/Modules/Compiler/SunPro-C-DetermineCompiler.cmake
@@ -4,12 +4,12 @@ set(_compiler_id_pp_test "defined(__SUNPRO_C)")
set(_compiler_id_version_compute "
# if __SUNPRO_C >= 0x5100
/* __SUNPRO_C = 0xVRRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
-# define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_C>>12)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_C>>4 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_C & 0xF)
# else
/* __SUNPRO_CC = 0xVRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
-# define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_C>>8)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_C>>4 & 0xF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_C & 0xF)
# endif")
diff --git a/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake b/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake
index 0a48cc6..5c23a95 100644
--- a/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake
+++ b/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake
@@ -4,12 +4,12 @@ set(_compiler_id_pp_test "defined(__SUNPRO_CC)")
set(_compiler_id_version_compute "
# if __SUNPRO_CC >= 0x5100
/* __SUNPRO_CC = 0xVRRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
-# define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_CC>>12)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_CC>>4 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_CC & 0xF)
# else
/* __SUNPRO_CC = 0xVRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
-# define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
-# define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_CC>>8)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_CC>>4 & 0xF)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_CC & 0xF)
# endif")
diff --git a/Modules/Compiler/TI-DetermineCompiler.cmake b/Modules/Compiler/TI-DetermineCompiler.cmake
index 1856c9b..19aa9e3 100644
--- a/Modules/Compiler/TI-DetermineCompiler.cmake
+++ b/Modules/Compiler/TI-DetermineCompiler.cmake
@@ -3,6 +3,6 @@ set(_compiler_id_pp_test "defined(__TI_COMPILER_VERSION__)")
set(_compiler_id_version_compute "
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)")
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__TI_COMPILER_VERSION__/1000000)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__TI_COMPILER_VERSION__/1000 % 1000)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__TI_COMPILER_VERSION__ % 1000)")
diff --git a/Modules/Compiler/Watcom-DetermineCompiler.cmake b/Modules/Compiler/Watcom-DetermineCompiler.cmake
index cc59abf..153e350 100644
--- a/Modules/Compiler/Watcom-DetermineCompiler.cmake
+++ b/Modules/Compiler/Watcom-DetermineCompiler.cmake
@@ -3,8 +3,8 @@ set(_compiler_id_pp_test "defined(__WATCOMC__) && __WATCOMC__ < 1200")
set(_compiler_id_version_compute "
/* __WATCOMC__ = VVRR */
-# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
-# define @PREFIX@COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__WATCOMC__ / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__WATCOMC__ / 10) % 10)
# if (__WATCOMC__ % 10) > 0
-# define @PREFIX@COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__WATCOMC__ % 10)
# endif")
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index 6e64cd2..bf2dc37 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -52,7 +52,15 @@
# Feature Test Macros
# ===================
#
-# For each compiler, a preprocessor test of the compiler version is generated
+# For each compiler, a preprocessor macro is generated matching
+# ``<PREFIX>_COMPILER_IS_<compiler>`` which has the content either ``0``
+# or ``1``, depending on the compiler in use. Preprocessor macros for
+# compiler version components are generated matching
+# ``<PREFIX>_COMPILER_VERSION_MAJOR`` ``<PREFIX>_COMPILER_VERSION_MINOR``
+# and ``<PREFIX>_COMPILER_VERSION_PATCH`` containing decimal values
+# for the corresponding compiler version components, if defined.
+#
+# A preprocessor test is generated based on the compiler version
# denoting whether each feature is enabled. A preprocessor macro
# matching ``<PREFIX>_COMPILER_<FEATURE>``, where ``<FEATURE>`` is the
# upper-case ``<feature>`` name, is generated to contain the value
@@ -187,6 +195,8 @@ function(_load_compiler_variables CompilerId lang)
foreach(feature ${ARGN})
set(_cmake_feature_test_${CompilerId}_${feature} ${_cmake_feature_test_${feature}} PARENT_SCOPE)
endforeach()
+ include("${CMAKE_ROOT}/Modules/Compiler/${CompilerId}-DetermineCompiler.cmake" OPTIONAL)
+ set(_compiler_id_version_compute_${CompilerId} ${_compiler_id_version_compute} PARENT_SCOPE)
endfunction()
function(write_compiler_detection_header
@@ -218,19 +228,33 @@ function(write_compiler_detection_header
if(NOT _WCD_VERSION)
set(_WCD_VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION})
endif()
- if (_WCD_VERSION VERSION_LESS 3.1.0) # Version which introduced this function
- message(FATAL_ERROR "VERSION parameter too low.")
+ set(_min_version 3.1.0) # Version which introduced this function
+ if (_WCD_VERSION VERSION_LESS _min_version)
+ set(err "VERSION compatibility for write_compiler_detection_header is set to ${_WCD_VERSION}, which is too low.")
+ set(err "${err} It must be set to at least ${_min_version}. ")
+ set(err "${err} Either set the VERSION parameter to the write_compiler_detection_header function, or update")
+ set(err "${err} your minimum required CMake version with the cmake_minimum_required command.")
+ message(FATAL_ERROR "${err}")
endif()
set(compilers
GNU
Clang
)
+
+ set(_hex_compilers ADSP Borland Embarcadero SunPro)
+
foreach(_comp ${_WCD_COMPILERS})
list(FIND compilers ${_comp} idx)
if (idx EQUAL -1)
message(FATAL_ERROR "Unsupported compiler ${_comp}.")
endif()
+ if (NOT _need_hex_conversion)
+ list(FIND _hex_compilers ${_comp} idx)
+ if (NOT idx EQUAL -1)
+ set(_need_hex_conversion TRUE)
+ endif()
+ endif()
endforeach()
set(file_content "
@@ -244,6 +268,21 @@ function(write_compiler_detection_header
set(file_content "${file_content}\n${_WCD_PROLOG}\n")
endif()
+ if (_need_hex_conversion)
+ set(file_content "${file_content}
+#define ${prefix_arg}_DEC(X) (X)
+#define ${prefix_arg}_HEX(X) ( \\
+ ((X)>>28 & 0xF) * 10000000 + \\
+ ((X)>>24 & 0xF) * 1000000 + \\
+ ((X)>>20 & 0xF) * 100000 + \\
+ ((X)>>16 & 0xF) * 10000 + \\
+ ((X)>>12 & 0xF) * 1000 + \\
+ ((X)>>8 & 0xF) * 100 + \\
+ ((X)>>4 & 0xF) * 10 + \\
+ ((X) & 0xF) \\
+ )\n")
+ endif()
+
foreach(feature ${_WCD_FEATURES})
if (feature MATCHES "^cxx_")
list(APPEND _langs CXX)
@@ -287,6 +326,21 @@ function(write_compiler_detection_header
# if !(${_cmake_oldestSupported_${compiler}})
# error Unsupported compiler version
# endif\n")
+
+ set(PREFIX ${prefix_arg}_)
+ if (_need_hex_conversion)
+ set(MACRO_DEC ${prefix_arg}_DEC)
+ set(MACRO_HEX ${prefix_arg}_HEX)
+ else()
+ set(MACRO_DEC)
+ set(MACRO_HEX)
+ endif()
+ string(CONFIGURE "${_compiler_id_version_compute_${compiler}}" VERSION_BLOCK @ONLY)
+ set(file_content "${file_content}${VERSION_BLOCK}\n")
+ set(PREFIX)
+ set(MACRO_DEC)
+ set(MACRO_HEX)
+
set(pp_if "elif")
foreach(feature ${${_lang}_features})
string(TOUPPER ${feature} feature_upper)