]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: honor individual picky option overrides found in `CMAKE_C_FLAGS`
authorViktor Szakats <commit@vsz.me>
Sat, 26 Apr 2025 07:34:55 +0000 (09:34 +0200)
committerViktor Szakats <commit@vsz.me>
Sat, 26 Apr 2025 10:59:54 +0000 (12:59 +0200)
Also to sync up with similar `./configure` feature via
`CURL_ADD_COMPILER_WARNINGS()`.

Example: `-DCMAKE_C_FLAGS=-Wno-xor-used-as-pow`

It may be useful as a workaround if a specific build combination hits
a picky warning within curl's source code. If such happens, we do
appreciate a report to fix it in curl itself.

Closes #17197

CMake/PickyWarnings.cmake

index 061e7a7a17c6879e8a9571cf9b8775b802a2516a..3531de1c52d5be2e9cb556f3d2fd8c09662dc157 100644 (file)
@@ -199,7 +199,6 @@ if(PICKY_COMPILER)
         list(APPEND _picky_enable
           -Wjump-misses-init               #             gcc  4.5
         )
-
         if(MINGW)
           list(APPEND _picky_enable
             -Wno-pedantic-ms-format        #             gcc  4.5 (MinGW-only)
@@ -254,9 +253,18 @@ if(PICKY_COMPILER)
 
     #
 
+    set(_picky_skipped "")
     foreach(_ccopt IN LISTS _picky_enable)
-      list(APPEND _picky "${_ccopt}")
+      string(REGEX MATCH "-W([a-z0-9-]+)" _ccmatch "${_ccopt}")
+      if(_ccmatch AND CMAKE_C_FLAGS MATCHES "-Wno-${CMAKE_MATCH_1}" AND NOT _ccopt STREQUAL "-Wall" AND NOT _ccopt MATCHES "^-Wno-")
+        string(APPEND _picky_skipped " ${_ccopt}")
+      else()
+        list(APPEND _picky "${_ccopt}")
+      endif()
     endforeach()
+    if(_picky_skipped)
+      message(STATUS "Picky compiler options skipped due to CMAKE_C_FLAGS override:${_picky_skipped}")
+    endif()
 
     foreach(_ccopt IN LISTS _picky_detect)
       # Use a unique variable name 1. for meaningful log output 2. to have a fresh, undefined variable for each detection