From 978ef7074a68e395da4a7ddd10507014f13ffe83 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 26 Apr 2025 09:34:55 +0200 Subject: [PATCH] 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 --- CMake/PickyWarnings.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 -- 2.47.3