]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Make ccache compile with clang-cl on Windows (#1260)
authorTobias Hieta <tobias@hieta.se>
Thu, 16 Mar 2023 17:27:16 +0000 (18:27 +0100)
committerGitHub <noreply@github.com>
Thu, 16 Mar 2023 17:27:16 +0000 (18:27 +0100)
cmake/DevModeWarnings.cmake
cmake/StandardSettings.cmake
unittest/CMakeLists.txt

index 1ada85f545caeb3889562b7f3f726786b3453b4b..1db8135fe901940d496c8f43506f20fbcad5d3c8 100644 (file)
@@ -74,6 +74,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
 
   # Disable C++20 compatibility for now.
   add_compile_flag_if_supported(CCACHE_COMPILER_WARNINGS "-Wno-c++2a-compat")
+  add_compile_flag_if_supported(CCACHE_COMPILER_WARNINGS "-Wno-c99-extensions")
+  add_compile_flag_if_supported(CCACHE_COMPILER_WARNINGS "-Wno-language-extension-token")
 
   # If compiler supports these warnings they have to be disabled for now.
   add_compile_flag_if_supported(
index 9e09ea67e8df92c3e9016763259ea5c02be77769..bee457c1aa5c6ca42b0cd55630d46ded126bcb03 100644 (file)
@@ -12,7 +12,7 @@ else()
   )
 endif()
 
-if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$")
+if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$" AND NOT MSVC)
   option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" FALSE)
   if(ENABLE_COVERAGE)
     target_compile_options(standard_settings INTERFACE --coverage -O0 -g)
@@ -55,17 +55,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$")
 
   include(StdAtomic)
   include(StdFilesystem)
-
-elseif(MSVC)
+elseif(MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^Clang$")
   target_compile_options(
     standard_settings
-    INTERFACE /Zc:preprocessor /Zc:__cplusplus /D_CRT_SECURE_NO_WARNINGS
+    INTERFACE /Zc:preprocessor /Zc:__cplusplus
   )
 endif()
 
 if(WIN32)
   target_compile_definitions(
     standard_settings
-    INTERFACE WIN32_LEAN_AND_MEAN
+    INTERFACE WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS
   )
 endif()
index 2a3edf0dabeb4e924940032c54ee07e9be3d16e0..062961f01003d02a6f39870543462ca6d8f984c3 100644 (file)
@@ -49,7 +49,7 @@ list(APPEND source_files ${headers})
 
 add_executable(unittest ${source_files})
 
-if(MSVC)
+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.
   set_source_files_properties(test_Stat.cpp PROPERTIES COMPILE_FLAGS /Zc:preprocessor-)
 endif()