mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Add an additional state to the cmake instance to track diagnostics. Use
this to initialize any new/reset states we create so that other contexts
will inherit the diagnostic state from presets / command-line options.
Modify the front-end to map presets and -W command-line options to
manipulation of this new diagnostic state. Remove old members for
storing diagnostic state. Rework how diagnostic state is persisted.
Deprecate old, non-standard spellings for manipulating diagnostics.
Deprecate old 'dev' spelling for CMD_AUTHOR.
Note that this is a work in progress. Messaging has not yet been
updated, so the new state is not yet being used to control diagnostics,
and some of the logic to update the old state has been stripped (and
will eventually be removed entirely). Backward compatibility support for
the deprecated CMAKE_{WARN,ERROR}_DEPRECATED variables is only partially
implemented. The GUI's interface for manipulating warnings is partially
broken and needs to be overhauled. These tasks are being done in
separate commits in order to minimize review burden and keep the changes
per commit / per merge request more manageable.
75 lines
2.4 KiB
CMake
75 lines
2.4 KiB
CMake
function(run_test ACTION INIT TARGET EXPECTED)
|
|
cmake_diagnostic(SET CMD_DEPRECATED ${INIT})
|
|
|
|
cmake_diagnostic(GET CMD_DEPRECATED action)
|
|
if(NOT "${action}" STREQUAL "${INIT}")
|
|
message(SEND_ERROR "failed to set diagnostic state")
|
|
endif()
|
|
|
|
cmake_diagnostic(${ACTION} CMD_AUTHOR ${TARGET} RECURSE)
|
|
|
|
cmake_diagnostic(GET CMD_DEPRECATED action)
|
|
if(NOT "${action}" STREQUAL "${EXPECTED}")
|
|
message(SEND_ERROR
|
|
"failed to change diagnostic state"
|
|
" (expected '${EXPECTED}', actual '${action}')"
|
|
)
|
|
endif()
|
|
endfunction()
|
|
|
|
# Run tests for altering a diagnostic from a known state
|
|
run_test(SET IGNORE WARN WARN)
|
|
run_test(SET IGNORE SEND_ERROR SEND_ERROR)
|
|
run_test(SET IGNORE FATAL_ERROR FATAL_ERROR)
|
|
|
|
run_test(PROMOTE IGNORE IGNORE IGNORE)
|
|
run_test(PROMOTE IGNORE WARN WARN)
|
|
run_test(PROMOTE IGNORE SEND_ERROR SEND_ERROR)
|
|
run_test(PROMOTE IGNORE FATAL_ERROR FATAL_ERROR)
|
|
|
|
run_test(PROMOTE WARN IGNORE WARN)
|
|
run_test(PROMOTE WARN WARN WARN)
|
|
run_test(PROMOTE WARN SEND_ERROR SEND_ERROR)
|
|
run_test(PROMOTE WARN FATAL_ERROR FATAL_ERROR)
|
|
|
|
run_test(PROMOTE SEND_ERROR IGNORE SEND_ERROR)
|
|
run_test(PROMOTE SEND_ERROR WARN SEND_ERROR)
|
|
run_test(PROMOTE SEND_ERROR SEND_ERROR SEND_ERROR)
|
|
run_test(PROMOTE SEND_ERROR FATAL_ERROR FATAL_ERROR)
|
|
|
|
run_test(PROMOTE FATAL_ERROR IGNORE FATAL_ERROR)
|
|
run_test(PROMOTE FATAL_ERROR WARN FATAL_ERROR)
|
|
run_test(PROMOTE FATAL_ERROR SEND_ERROR FATAL_ERROR)
|
|
run_test(PROMOTE FATAL_ERROR FATAL_ERROR FATAL_ERROR)
|
|
|
|
run_test(DEMOTE IGNORE IGNORE IGNORE)
|
|
run_test(DEMOTE IGNORE WARN IGNORE)
|
|
run_test(DEMOTE IGNORE SEND_ERROR IGNORE)
|
|
run_test(DEMOTE IGNORE FATAL_ERROR IGNORE)
|
|
|
|
run_test(DEMOTE WARN IGNORE IGNORE)
|
|
run_test(DEMOTE WARN WARN WARN)
|
|
run_test(DEMOTE WARN SEND_ERROR WARN)
|
|
run_test(DEMOTE WARN FATAL_ERROR WARN)
|
|
|
|
run_test(DEMOTE SEND_ERROR IGNORE IGNORE)
|
|
run_test(DEMOTE SEND_ERROR WARN WARN)
|
|
run_test(DEMOTE SEND_ERROR SEND_ERROR SEND_ERROR)
|
|
run_test(DEMOTE SEND_ERROR FATAL_ERROR SEND_ERROR)
|
|
|
|
run_test(DEMOTE FATAL_ERROR IGNORE IGNORE)
|
|
run_test(DEMOTE FATAL_ERROR WARN WARN)
|
|
run_test(DEMOTE FATAL_ERROR SEND_ERROR SEND_ERROR)
|
|
run_test(DEMOTE FATAL_ERROR FATAL_ERROR FATAL_ERROR)
|
|
|
|
# Ensure that altering a diagnostic that is still in the default state
|
|
# uses the default state as the basis for alteration
|
|
cmake_diagnostic(DEMOTE CMD_UNINITIALIZED WARN)
|
|
|
|
cmake_diagnostic(GET CMD_UNINITIALIZED action)
|
|
if(NOT "${action}" STREQUAL "IGNORE")
|
|
message(SEND_ERROR
|
|
"CMD_UNINITIALIZED has unexpected state '${action}' (expected 'IGNORE')"
|
|
)
|
|
endif()
|