Browse Source

Detect MSVC compiler version with its id

Decode decimal digits from _MSC_VER, _MSC_FULL_VER, and _MSC_BUILD to
compute the version number components.  See documentation at:

  http://msdn.microsoft.com/en-us/library/b0084kay.aspx
  http://predef.sourceforge.net/precomp.html
Brad King 14 years ago
parent
commit
a6d83ccea9
2 changed files with 24 additions and 0 deletions
  1. 12 0
      Modules/CMakeCCompilerId.c.in
  2. 12 0
      Modules/CMakeCXXCompilerId.cpp.in

+ 12 - 0
Modules/CMakeCCompilerId.c.in

@@ -61,6 +61,18 @@
 
 #elif defined(_MSC_VER)
 # define COMPILER_ID "MSVC"
+# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+#  if _MSC_VER >= 1400
+#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+#  else
+#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+#  endif
+# endif
+# if defined(_MSC_BUILD)
+#  define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif
 
 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
 /* Analog Devices C++ compiler for Blackfin, TigerSHARC and

+ 12 - 0
Modules/CMakeCXXCompilerId.cpp.in

@@ -63,6 +63,18 @@
 
 #elif defined(_MSC_VER)
 # define COMPILER_ID "MSVC"
+# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+#  if _MSC_VER >= 1400
+#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+#  else
+#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+#  endif
+# endif
+# if defined(_MSC_BUILD)
+#  define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif
 
 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
 /* Analog Devices C++ compiler for Blackfin, TigerSHARC and