cmake: honor individual picky option overrides found in CMAKE_C_FLAGS

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
This commit is contained in:
Viktor Szakats 2025-04-26 09:34:55 +02:00
parent 4b7accda5a
commit 978ef7074a
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View 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