@@ -4,12 +4,25 @@ enable_testing()
4
4
5
5
include (CheckCXXSourceCompiles)
6
6
7
+ # report an updated value for recent C++ language standards support. By
8
+ # default, Visual Studio always returns the value "199711L" for the
9
+ # __cplusplus preprocessor macro.
10
+ if (MSVC )
11
+ string (APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus" )
12
+ endif ()
13
+
7
14
set (OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} " )
8
- set (CMAKE_REQUIRED_FLAGS -std=c++17)
15
+ if (MSVC )
16
+ set (CMAKE_REQUIRED_FLAGS /std:c++17)
17
+ else ()
18
+ set (CMAKE_REQUIRED_FLAGS -std=c++17)
19
+ endif ()
20
+
9
21
check_cxx_source_compiles("
10
22
#include <string_view>
11
23
#include <type_traits>
12
24
int main() { return std::is_same_v<std::string_view, int>; }" CAN_COMPILE_17)
25
+
13
26
set (CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS} " )
14
27
15
28
if (EXISTS ${CMAKE_BINARY_DIR} /conan_paths.cmake)
@@ -22,7 +35,7 @@ find_package(Catch2 REQUIRED)
22
35
if (CAN_COMPILE_17)
23
36
add_executable (wise_enum_test test_main.cpp cxx17.cpp)
24
37
target_compile_features (wise_enum_test PRIVATE cxx_std_17)
25
- target_include_directories (wise_enum_test PRIVATE ..)
38
+ target_include_directories (wise_enum_test PRIVATE ${CMAKE_CURRENT_LIST_DIR} / ..)
26
39
else ()
27
40
add_executable (wise_enum_test test_main.cpp)
28
41
endif ()
@@ -31,7 +44,7 @@ target_link_libraries(wise_enum_test PRIVATE Catch2::Catch2)
31
44
add_executable (wise_enum_test14 test_main.cpp cxx14.cpp)
32
45
target_compile_features (wise_enum_test14 PRIVATE cxx_std_14)
33
46
target_link_libraries (wise_enum_test14 PRIVATE Catch2::Catch2)
34
- target_include_directories (wise_enum_test14 PRIVATE ..)
47
+ target_include_directories (wise_enum_test14 PRIVATE ${CMAKE_CURRENT_LIST_DIR} / ..)
35
48
36
49
add_test (NAME wise_enum.unit_tests COMMAND wise_enum_test)
37
50
add_test (NAME wise_enum.unit_tests14 COMMAND wise_enum_test14)
0 commit comments