summaryrefslogtreecommitdiffstats
path: root/Modules/CMakePlatformId.h.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-12-05 14:44:09 (GMT)
committerBrad King <brad.king@kitware.com>2011-12-07 13:59:51 (GMT)
commitfa7141f5ad9bc084fefbb898c6cdda9312c5f615 (patch)
treee5e6c65bb884260c99ce1a00221848911c97378a /Modules/CMakePlatformId.h.in
parente0bc42aa4ff086e9c6976ab91ba924530df0bf72 (diff)
downloadCMake-fa7141f5ad9bc084fefbb898c6cdda9312c5f615.zip
CMake-fa7141f5ad9bc084fefbb898c6cdda9312c5f615.tar.gz
CMake-fa7141f5ad9bc084fefbb898c6cdda9312c5f615.tar.bz2
Add framework to detect compiler version with its id (#12408)
Teach CMakePlatformId.h to construct an "INFO:compiler_version[]" string literal from macros COMPILER_VERSION_(MAJOR|MINOR|PATCH|TWEAK) to be defined in CMake(C|CXX)CompilerId.(c|cpp) for each compiler. Provide conversion macros DEC() and HEX() to decode decimal or hex digits from integer values. Parse the version out of the compiler id binary along with the other INFO values already present. Store the result in variable CMAKE_<LANG>_COMPILER_VERSION in the format "major[.minor[.patch[.tweak]]]". Save the value persistently in CMake(C|CXX)Compiler.cmake in the build tree. Document the variable for internal use since we do not set it everywhere yet. Report the compiler version on the compiler id result line e.g. The C compiler identification is GNU 4.5.2 Report CMAKE_(C|CXX)_COMPILER_(ID|VERSION) in SystemInformation test.
Diffstat (limited to 'Modules/CMakePlatformId.h.in')
-rw-r--r--Modules/CMakePlatformId.h.in40
1 files changed, 40 insertions, 0 deletions
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index cb3f40a..b69bf63 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -105,6 +105,46 @@
# define ARCHITECTURE_ID ""
#endif
+/* Convert integer to decimal digit literals. */
+#define DEC(n) \
+ ('0' + (((n) / 10000000)%10)), \
+ ('0' + (((n) / 1000000)%10)), \
+ ('0' + (((n) / 100000)%10)), \
+ ('0' + (((n) / 10000)%10)), \
+ ('0' + (((n) / 1000)%10)), \
+ ('0' + (((n) / 100)%10)), \
+ ('0' + (((n) / 10)%10)), \
+ ('0' + ((n) % 10))
+
+/* Convert integer to hex digit literals. */
+#define HEX(n) \
+ ('0' + ((n)>>28 & 0xF)), \
+ ('0' + ((n)>>24 & 0xF)), \
+ ('0' + ((n)>>20 & 0xF)), \
+ ('0' + ((n)>>16 & 0xF)), \
+ ('0' + ((n)>>12 & 0xF)), \
+ ('0' + ((n)>>8 & 0xF)), \
+ ('0' + ((n)>>4 & 0xF)), \
+ ('0' + ((n) & 0xF))
+
+/* Construct a string literal encoding the version number components. */
+#ifdef COMPILER_VERSION_MAJOR
+char const info_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
+ COMPILER_VERSION_MAJOR,
+# ifdef COMPILER_VERSION_MINOR
+ '.', COMPILER_VERSION_MINOR,
+# ifdef COMPILER_VERSION_PATCH
+ '.', COMPILER_VERSION_PATCH,
+# ifdef COMPILER_VERSION_TWEAK
+ '.', COMPILER_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