summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeCXXCompilerId.cpp.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-07-14 13:17:05 (GMT)
committerBrad King <brad.king@kitware.com>2017-07-17 14:48:43 (GMT)
commit131c721f542cd6f8805967d847965510172a2c6b (patch)
tree17bc0f7b78eef874be23de8e6877547ddfaa18b9 /Modules/CMakeCXXCompilerId.cpp.in
parentcef77f06878371cf7615bf4dd3da7cc3ba257878 (diff)
downloadCMake-131c721f542cd6f8805967d847965510172a2c6b.zip
CMake-131c721f542cd6f8805967d847965510172a2c6b.tar.gz
CMake-131c721f542cd6f8805967d847965510172a2c6b.tar.bz2
MSVC: Add flags for C++ language standards
Visual Studio 2015 Update 3 introduced the notion of language standard levels to MSVC. The language standard level is defined in `_MSVC_LANG` instead of `__cplusplus`. It also added support for the `-std:c++14` and `-std:c++latest` flags, although the compiler defaults to its C++14 mode anyway. Visual Studio 2017 Update 3 will introduce support for the `-std:c++17` flag. Fixes: #16482
Diffstat (limited to 'Modules/CMakeCXXCompilerId.cpp.in')
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in12
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 9aa096d..6572bb3 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -27,12 +27,18 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
@CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@
+#if defined(_MSC_VER) && defined(_MSVC_LANG)
+#define CXX_STD _MSVC_LANG
+#else
+#define CXX_STD __cplusplus
+#endif
+
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
-#if __cplusplus > 201402L
+#if CXX_STD > 201402L
"17"
-#elif __cplusplus >= 201402L
+#elif CXX_STD >= 201402L
"14"
-#elif __cplusplus >= 201103L
+#elif CXX_STD >= 201103L
"11"
#else
"98"