mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
We do not add default warning flags on other compilers, and having
a warning flag in the default flags makes it hard for projects to
customize the warning level. They need to use string processing
to remove `/W3` from `CMAKE_{C,CXX}_FLAGS`. Therefore we should
drop it.
However, projects may be using string processing to replace `/W3`
with another flag, so we cannot simply drop it. Add a policy to
drop it in a compatible way.
Fixes: #18317
13 lines
372 B
CMake
13 lines
372 B
CMake
enable_language(C)
|
|
|
|
cmake_policy(GET CMP0092 cmp0092)
|
|
if(cmp0092 STREQUAL "NEW")
|
|
if("${CMAKE_C_FLAGS}" MATCHES "([/-]W[0-9])")
|
|
message(SEND_ERROR "CMAKE_C_FLAGS has '${CMAKE_MATCH_1}' under NEW behavior")
|
|
endif()
|
|
else()
|
|
if(NOT " ${CMAKE_C_FLAGS} " MATCHES " /W3 ")
|
|
message(SEND_ERROR "CMAKE_C_FLAGS does not have '/W3' under OLD behavior")
|
|
endif()
|
|
endif()
|