]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: use `CMAKE_COMPILE_WARNING_AS_ERROR` if available
authorViktor Szakats <commit@vsz.me>
Fri, 25 Apr 2025 08:52:39 +0000 (10:52 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 25 Apr 2025 09:42:24 +0000 (11:42 +0200)
It's available in CMake >= 3.24.

Ref: https://cmake.org/cmake/help/latest/variable/CMAKE_COMPILE_WARNING_AS_ERROR.html

Closes #17183

CMake/PickyWarnings.cmake

index 2ab9dc3517926cdfba3be99de2b34a3a981cd070..610def004d433810f5d52d162d3e3790e31dc261 100644 (file)
@@ -27,10 +27,14 @@ set(_picky "")
 set(_picky_nocheck "")  # not to pass to feature checks
 
 if(CURL_WERROR)
-  if(MSVC)
-    list(APPEND _picky_nocheck "-WX")
-  else()  # llvm/clang and gcc style options
-    list(APPEND _picky_nocheck "-Werror")
+  if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
+    set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
+  else()
+    if(MSVC)
+      list(APPEND _picky_nocheck "-WX")
+    else()  # llvm/clang and gcc style options
+      list(APPEND _picky_nocheck "-Werror")
+    endif()
   endif()
 
   if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND