Don't add the /Zc:preprocessor- compiler flag when it's not needed, to
avoid the following warning:
D9025 : overriding '/Zc:preprocessor' with '/Zc:preprocessor-
The latest Windows SDK v10.0.22621 compiles fine with conforming
preprocessor enabled, the bug was in older SDK-s like <=10.0.20348.0.
Add the /Zc:preprocessor for msvc >=v19.25, it didn't exist before this
version (it existed as /experimental:preprocessor before).
include(StdAtomic)
include(StdFilesystem)
-elseif(MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^Clang$")
- target_compile_options(
- standard_settings
- INTERFACE /Zc:preprocessor /Zc:__cplusplus
+elseif(MSVC AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ target_compile_options(standard_settings INTERFACE
+ /Zc:__cplusplus
+ $<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,19.25>:/Zc:preprocessor>
)
endif()
add_executable(unittest ${source_files})
-if(MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^Clang$")
- # Turn off /Zc:preprocessor for this test because it triggers a bug in some older Windows 10 SDK headers.
+# Turn off /Zc:preprocessor for this test because it triggers a bug in some older Windows 10 SDK headers.
+if(MSVC AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+ CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.25" AND
+ CMAKE_SYSTEM_VERSION VERSION_LESS "10.0.22621")
set_source_files_properties(test_util_DirEntry.cpp PROPERTIES COMPILE_FLAGS /Zc:preprocessor-)
endif()