From 724bd7790e1a28826b5457c0b28edbfff9af4d15 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Wed, 27 Jun 2018 18:36:47 +0200 Subject: LINK_DEPENDS: add support of 'generator expressions' --- Help/prop_tgt/LINK_DEPENDS.rst | 5 +++++ Help/release/dev/LINK_DEPENDS-property.rst | 5 +++++ Source/cmGeneratorTarget.cxx | 16 +++++++++++----- Tests/BuildDepends/Project/CMakeLists.txt | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/LINK_DEPENDS-property.rst diff --git a/Help/prop_tgt/LINK_DEPENDS.rst b/Help/prop_tgt/LINK_DEPENDS.rst index bc83393..3ab8658 100644 --- a/Help/prop_tgt/LINK_DEPENDS.rst +++ b/Help/prop_tgt/LINK_DEPENDS.rst @@ -10,3 +10,8 @@ linked if any of the named files is newer than it. This property is supported only by Makefile and Ninja generators. It is intended to specify dependencies on "linker scripts" for custom Makefile link rules. + +Contents of ``LINK_DEPENDS`` may use "generator expressions" with +the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` +manual for available expressions. See the :manual:`cmake-buildsystem(7)` +manual for more on defining buildsystem properties. diff --git a/Help/release/dev/LINK_DEPENDS-property.rst b/Help/release/dev/LINK_DEPENDS-property.rst new file mode 100644 index 0000000..83beba8 --- /dev/null +++ b/Help/release/dev/LINK_DEPENDS-property.rst @@ -0,0 +1,5 @@ +LINK_DEPENDS-property +--------------------- + +* The :prop_tgt:`LINK_DEPENDS` target property learned to support + :manual:`generator expressions `. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d4686c2..e07ccd9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3027,15 +3027,21 @@ void cmGeneratorTarget::GetLinkDepends(std::vector& result, const std::string& config, const std::string& language) const { - if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) { - cmSystemTools::ExpandListArgument(linkDepends, result); - } - - std::unordered_set uniqueOptions; std::vector linkDependsEntries; + std::unordered_set uniqueOptions; cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "LINK_DEPENDS", nullptr, nullptr); + if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) { + std::vector depends; + cmGeneratorExpression ge; + cmSystemTools::ExpandListArgument(linkDepends, depends); + for (const auto& depend : depends) { + std::unique_ptr cge = ge.Parse(depend); + linkDependsEntries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(std::move(cge))); + } + } AddInterfaceEntries(this, config, "INTERFACE_LINK_DEPENDS", linkDependsEntries); processLinkDepends(this, linkDependsEntries, result, uniqueOptions, diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 09be3ea..3f41b26 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -106,7 +106,7 @@ set_property( if(TEST_LINK_DEPENDS) add_executable(linkdep linkdep.cxx) - set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) + set_property(TARGET linkdep PROPERTY LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>) add_library(foo_interface INTERFACE) set_property(TARGET foo_interface PROPERTY INTERFACE_LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>) -- cgit v0.12