From: Viktor Szakats Date: Sat, 26 Apr 2025 07:34:55 +0000 (+0200) Subject: cmake: honor individual picky option overrides found in `CMAKE_C_FLAGS` X-Git-Tag: curl-8_14_0~203 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=978ef7074a68e395da4a7ddd10507014f13ffe83;p=thirdparty%2Fcurl.git 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 --- diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index 061e7a7a17..3531de1c52 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -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