summaryrefslogtreecommitdiffstats
path: root/Tests
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 /Tests
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 'Tests')
-rw-r--r--Tests/CompileFeatures/default_dialect.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp
index 9b65b42..0de1125 100644
--- a/Tests/CompileFeatures/default_dialect.cpp
+++ b/Tests/CompileFeatures/default_dialect.cpp
@@ -2,25 +2,30 @@
template <long l>
struct Outputter;
+#if defined(_MSC_VER) && defined(_MSVC_LANG)
+#define CXX_STD _MSVC_LANG
+#else
+#define CXX_STD __cplusplus
+#endif
+
#if DEFAULT_CXX17
-#if __cplusplus <= 201402L
-Outputter<__cplusplus> o;
+#if CXX_STD <= 201402L
+Outputter<CXX_STD> o;
#endif
#elif DEFAULT_CXX14
-#if __cplusplus != 201402L
-Outputter<__cplusplus> o;
+#if CXX_STD != 201402L
+Outputter<CXX_STD> o;
#endif
#elif DEFAULT_CXX11
-#if __cplusplus != 201103L
-Outputter<__cplusplus> o;
+#if CXX_STD != 201103L
+Outputter<CXX_STD> o;
#endif
#else
#if !DEFAULT_CXX98
#error Buildsystem error
#endif
-#if __cplusplus != 199711L && __cplusplus != 1 && \
- !defined(__GXX_EXPERIMENTAL_CXX0X__)
-Outputter<__cplusplus> o;
+#if CXX_STD != 199711L && CXX_STD != 1 && !defined(__GXX_EXPERIMENTAL_CXX0X__)
+Outputter<CXX_STD> o;
#endif
#endif