From: Silver Zachara Date: Tue, 28 May 2024 17:03:29 +0000 (+0200) Subject: build: Fix MSVC /Zc:preprocessor warning (#1461) X-Git-Tag: v4.10~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=273bbd63b8a08837b2ec2444b5e1d04aeefe2f6f;p=thirdparty%2Fccache.git build: Fix MSVC /Zc:preprocessor warning (#1461) 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). --- diff --git a/cmake/StandardSettings.cmake b/cmake/StandardSettings.cmake index b6a0643c..b0ff499b 100644 --- a/cmake/StandardSettings.cmake +++ b/cmake/StandardSettings.cmake @@ -59,10 +59,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$" AND NOT MSVC) 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 + $<$,19.25>:/Zc:preprocessor> ) endif() diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 842f3d4d..3fee27fb 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -51,8 +51,10 @@ list(APPEND source_files ${headers}) 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()