From 254687d31f2f45b0d3ce9085c013ab0e15b360de Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 6 Mar 2013 17:15:57 +0100 Subject: Only process transitive interface properties for valid target names. Commit a1c4905f (Use the link information as a source of compile definitions and includes., 2013-02-12) introduced the use of link information as the source of target properties via the TARGET_PROPERTY generator expression. This generator expression has a strict interpretation of a valid target name and emits a fatal error for invalid names. Ensure that only targets with names valid for use with TARGET_PROPERTY or targets which are determined by generator expressions are processed by it. This means that at worst, invalid target names do not participate in the transitive evaluation of properties, but the validation generator expression can be extended where needed to resolve that. --- Source/cmTarget.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f38b16e..d46325b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2898,7 +2898,8 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) ge.Parse(it->Value); std::string result = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(result.c_str())) + if (!cmGeneratorExpression::IsValidTargetName(result.c_str()) + || !this->Makefile->FindTargetToUse(result.c_str())) { continue; } @@ -2975,7 +2976,9 @@ std::string cmTarget::GetCompileDefinitions(const char *config) for (std::vector::const_iterator it = libs.begin(); it != libs.end(); ++it) { - if (this->Makefile->FindTargetToUse(it->c_str())) + if ((cmGeneratorExpression::IsValidTargetName(it->c_str()) + || cmGeneratorExpression::Find(it->c_str()) != std::string::npos) + && this->Makefile->FindTargetToUse(it->c_str())) { depString += sep + "$"; -- cgit v0.12 From 1bdd1675776e6416b23cc6b308269aeb0831bb2e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 6 Mar 2013 17:26:40 +0100 Subject: Restore support for target names with '+' (#13986) Extend the range of valid target names with the + sign. This character can commonly be used for target names, such as those containing 'c++'. Add a test but skip it for Borland and Watcom tools which do not support the character. Suggested-By: Benjamin Kloster --- Source/cmGeneratorExpression.cxx | 2 +- Tests/CMakeCommands/target_link_libraries/CMakeLists.txt | 7 +++++++ Tests/CMakeCommands/target_link_libraries/empty.cpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Tests/CMakeCommands/target_link_libraries/empty.cpp diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 7ea58fa..3f59129 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -393,7 +393,7 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string &input) cmsys::RegularExpression targetNameValidator; // The ':' is supported to allow use with IMPORTED targets. At least // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter. - targetNameValidator.compile("^[A-Za-z0-9_.:-]+$"); + targetNameValidator.compile("^[A-Za-z0-9_.:+-]+$"); return targetNameValidator.find(input.c_str()); } diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index b13c13d..3881644 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -102,7 +102,14 @@ target_compile_definitions(depG INTERFACE TEST_DEF ) + add_executable(targetC targetC.cpp) +if(NOT BORLAND AND NOT WATCOM) + # Linking to a target containing a + should be non-fatal, though it does + # not work at all on Borland or watcom + add_library(wrapc++ empty.cpp) + target_link_libraries(targetC wrapc++) +endif() # The TARGET_PROPERTY expression is duplicated below to test that there is no # shortcutting of the evaluation by returning an empty string. set(_exe_test $,EXECUTABLE>) diff --git a/Tests/CMakeCommands/target_link_libraries/empty.cpp b/Tests/CMakeCommands/target_link_libraries/empty.cpp new file mode 100644 index 0000000..ab32cf6 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/empty.cpp @@ -0,0 +1 @@ +// No content -- cgit v0.12