cmake: stop deleting -W<n> from CMAKE_C_FLAGS (MSVC)

1. `CMAKE_C_FLAGS` may apply to other projects, and deleting/altering it
   may be unexpected.

2. We pass `-W4`/`-Wall` internally now, which do override custom
   `-W<n>` options in all supported MSVC versions.
   (as tested with Visual Studio generators)
   Ref: https://ci.appveyor.com/project/curlorg/curl/builds/51945416

Follow-up to e86542038d #17047
Ref: 866e02935d #1711

Closes #17179
This commit is contained in:
Viktor Szakats 2025-04-25 01:45:23 +02:00
parent 5acba8bc36
commit 1e9b48c010
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -52,9 +52,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
endif()
if(MSVC)
# Use the highest warning level for Visual Studio.
string(REGEX REPLACE "[/-]W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
list(APPEND _picky "-W4")
list(APPEND _picky "-W4") # Use the highest warning level for Visual Studio.
elseif(BORLAND)
list(APPEND _picky "-w-") # Disable warnings on Borland to avoid changing 3rd party code.
endif()