mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 06:09:52 -06:00
Add `COMPILE_WARNING_AS_ERROR` target property and supporting `CMAKE_COMPILE_WARNING_AS_ERROR` variable. `COMPILE_WARNING_AS_ERROR` is initialized by `CMAKE_COMPILE_WARNING_AS_ERROR`. It is a boolean variable. If it is true, it expands to a different flag depending on the compiler such that any warnings at compile will be treated as errors. Supports compiler ids that I could find a relevant flag for.
14 lines
444 B
CMake
14 lines
444 B
CMake
enable_language(CXX)
|
|
|
|
include(WarningAsErrorOptions.cmake)
|
|
get_warning_options(warning_options)
|
|
|
|
if (DEFINED warning_options)
|
|
add_executable(WerrorOn warn.cxx)
|
|
target_compile_options(WerrorOn PUBLIC "${warning_options}")
|
|
set_target_properties(WerrorOn PROPERTIES COMPILE_WARNING_AS_ERROR ON)
|
|
else()
|
|
# if no werror option is set for the environment, use err.cxx so that build fails as expected
|
|
add_executable(WerrorOn err.cxx)
|
|
endif()
|