mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
CMP0171: Improve diagnostic context
When issuing the policy warning that `codegen` is a reserved target name, use the diagnostic context in which the target was declared, rather than the root context (which cannot be affected in script).
This commit is contained in:
@@ -3101,7 +3101,7 @@ void cmGlobalGenerator::ReserveGlobalTargetCodegen()
|
||||
|
||||
switch (policyStatus) {
|
||||
case cmPolicies::WARN:
|
||||
this->GetCMakeInstance()->IssueDiagnostic(
|
||||
tgt->GetMakefile()->IssueDiagnostic(
|
||||
cmDiagnostics::CMD_AUTHOR,
|
||||
cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0171), '\n',
|
||||
"The target name \"codegen\" is reserved."),
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
add_subdirectory("CMP0171-WARN-QUIET")
|
||||
@@ -0,0 +1,8 @@
|
||||
# CMake should warn the user if they have a target named codegen... unless the
|
||||
# user also suppresses the diagnostic.
|
||||
cmake_diagnostic(SET CMD_AUTHOR IGNORE RECURSE)
|
||||
add_custom_target(codegen
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
)
|
||||
@@ -1,6 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake("CMP0171-WARN")
|
||||
run_cmake("CMP0171-WARN-QUIET")
|
||||
|
||||
run_cmake_with_options(CMP0171-OLD "-DCMAKE_POLICY_DEFAULT_CMP0171=OLD")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user