diff options
author | Brad King <brad.king@kitware.com> | 2024-05-15 13:58:38 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-05-15 13:58:48 (GMT) |
commit | 19c2f8e1f32973ee14c7ff36998c65e9380f6724 (patch) | |
tree | 43dd0ed05a80e536e6b4fb2394c9d83943ed5565 | |
parent | b3958a0a5acc1d8c72b270f83240601bb6d6b3f8 (diff) | |
parent | c773d5b436fcf8e773809e8594eec1ac3701ce82 (diff) | |
download | CMake-19c2f8e1f32973ee14c7ff36998c65e9380f6724.zip CMake-19c2f8e1f32973ee14c7ff36998c65e9380f6724.tar.gz CMake-19c2f8e1f32973ee14c7ff36998c65e9380f6724.tar.bz2 |
Merge topic 'cmp0037-message' into release-3.29
c773d5b436 CMP0037: Restore diagnostic message for invalid ALIAS target names
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !9519
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/RunCMakeTest.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-NEW-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-NEW-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-NEW.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-OLD-stderr.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-OLD.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-WARN-stderr.txt | 11 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-WARN.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/alias-test-common.cmake | 3 |
10 files changed, 45 insertions, 3 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1606eec..b2ee306 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2730,6 +2730,7 @@ cmGlobalGenerator::SplitFrameworkPath(const std::string& path, } static bool RaiseCMP0037Message(cmake* cm, cmTarget* tgt, + std::string const& targetNameAsWritten, std::string const& reason) { MessageType messageType = MessageType::AUTHOR_WARNING; @@ -2750,8 +2751,8 @@ static bool RaiseCMP0037Message(cmake* cm, cmTarget* tgt, break; } if (issueMessage) { - e << "The target name \"" << tgt->GetName() << "\" is reserved " << reason - << "."; + e << "The target name \"" << targetNameAsWritten << "\" is reserved " + << reason << "."; if (messageType == MessageType::AUTHOR_WARNING) { e << " It may result in undefined behavior."; } @@ -2770,7 +2771,8 @@ bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName, if (!tgt) { return true; } - return RaiseCMP0037Message(this->GetCMakeInstance(), tgt, reason); + return RaiseCMP0037Message(this->GetCMakeInstance(), tgt, targetName, + reason); } void cmGlobalGenerator::CreateDefaultGlobalTargets( diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake index 558fba3..89beb59 100644 --- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -45,6 +45,10 @@ run_cmake(WARN-cond) run_cmake(WARN-cond-test) run_cmake(WARN-cond-package) +run_cmake(alias-test-NEW) +run_cmake(alias-test-OLD) +run_cmake(alias-test-WARN) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") run_cmake(NEW-cond-package_source) run_cmake(OLD-cond-package_source) diff --git a/Tests/RunCMake/CMP0037/alias-test-NEW-result.txt b/Tests/RunCMake/CMP0037/alias-test-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/alias-test-NEW-stderr.txt b/Tests/RunCMake/CMP0037/alias-test-NEW-stderr.txt new file mode 100644 index 0000000..68a36cc --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-NEW-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at alias-test-common\.cmake:[0-9]+ \(add_library\): + The target name "test" is reserved when CTest testing is enabled\. +Call Stack \(most recent call first\): + alias-test-NEW\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0037/alias-test-NEW.cmake b/Tests/RunCMake/CMP0037/alias-test-NEW.cmake new file mode 100644 index 0000000..32569b5 --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0037 NEW) +include(alias-test-common.cmake) diff --git a/Tests/RunCMake/CMP0037/alias-test-OLD-stderr.txt b/Tests/RunCMake/CMP0037/alias-test-OLD-stderr.txt new file mode 100644 index 0000000..bf177e2 --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at alias-test-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0037 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0037/alias-test-OLD.cmake b/Tests/RunCMake/CMP0037/alias-test-OLD.cmake new file mode 100644 index 0000000..1f3e770 --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0037 OLD) +include(alias-test-common.cmake) diff --git a/Tests/RunCMake/CMP0037/alias-test-WARN-stderr.txt b/Tests/RunCMake/CMP0037/alias-test-WARN-stderr.txt new file mode 100644 index 0000000..43bf98b --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-WARN-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at alias-test-common\.cmake:[0-9]+ \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern\. Run "cmake --help-policy CMP0037" for policy + details\. Use the cmake_policy command to set the policy and suppress this + warning\. + + The target name "test" is reserved when CTest testing is enabled\. It may + result in undefined behavior\. +Call Stack \(most recent call first\): + alias-test-WARN\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CMP0037/alias-test-WARN.cmake b/Tests/RunCMake/CMP0037/alias-test-WARN.cmake new file mode 100644 index 0000000..688cb95 --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-WARN.cmake @@ -0,0 +1,2 @@ +# leave CMP0037 unset +include(alias-test-common.cmake) diff --git a/Tests/RunCMake/CMP0037/alias-test-common.cmake b/Tests/RunCMake/CMP0037/alias-test-common.cmake new file mode 100644 index 0000000..f6e5000 --- /dev/null +++ b/Tests/RunCMake/CMP0037/alias-test-common.cmake @@ -0,0 +1,3 @@ +enable_testing() +add_library(iface INTERFACE) +add_library(test ALIAS iface) |