mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 20:50:43 -06:00
target_link_libraries: Fix out-of-dir calls with debug/optimized keywords
In commit a1ad0a699b (target_link_libraries: Allow use with targets in
other directories, 2018-09-07, v3.13.0-rc1~94^2) we added use of `<...>`
to encode a directory id, but the closing `>` can incorrectly terminate
a surrounding generator expression early. Encode the directory id using
`(...)` instead.
Fixes: #20202
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
A call to :command:`target_link_libraries(<target> ...)` may update this
|
||||
property on ``<target>``. If ``<target>`` was not created in the same
|
||||
directory as the call then :command:`target_link_libraries` will add a
|
||||
suffix of the form ``::@<directory-id>`` to each entry, where the
|
||||
``::@`` is a separator and the ``<directory-id>`` is unspecified.
|
||||
suffix of the form ``::@(directory-id)`` to each entry, where the
|
||||
``::@`` is a separator and the ``(directory-id)`` is unspecified.
|
||||
This tells the generators that the named libraries must be looked up in
|
||||
the scope of the caller rather than in the scope in which the
|
||||
``<target>`` was created. Valid directory ids are stripped on export
|
||||
|
||||
@@ -139,7 +139,7 @@ cmDirectoryId cmMakefile::GetDirectoryId() const
|
||||
// If we ever need to expose this to CMake language code we should
|
||||
// add a read-only property in cmMakefile::GetProperty.
|
||||
char buf[32];
|
||||
sprintf(buf, "<%p>",
|
||||
sprintf(buf, "(%p)",
|
||||
static_cast<void const*>(this)); // cast avoids format warning
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ add_executable(SubDirB SubDirB.c)
|
||||
|
||||
# Link to a target imported in this directory that would not normally
|
||||
# be visible to the directory in which TopDir is defined.
|
||||
target_link_libraries(TopDir PUBLIC SameNameImported)
|
||||
target_link_libraries(TopDir PUBLIC debug SameNameImported optimized SameNameImported)
|
||||
|
||||
#FIXME: Demonstrate known issue #20204.
|
||||
#target_link_libraries(TopDir PUBLIC "$<1:SameNameImported;SameNameImported>")
|
||||
|
||||
@@ -1 +1 @@
|
||||
-- INTERFACE_LINK_LIBRARIES='foo::@<[Xx0-9A-Fa-f]+>'
|
||||
-- INTERFACE_LINK_LIBRARIES='foo::@\([Xx0-9A-Fa-f]+\)'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
^CMake Error at CMP0079-link-NEW-bogus.cmake:[0-9]+ \(add_executable\):
|
||||
Target "top" links to target "foo::@<0xdeadbeef>" but the target was not
|
||||
Target "top" links to target "foo::@\(0xdeadbeef\)" but the target was not
|
||||
found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
|
||||
an ALIAS target is missing\?
|
||||
Call Stack \(most recent call first\):
|
||||
|
||||
@@ -3,4 +3,4 @@ cmake_policy(SET CMP0079 NEW)
|
||||
enable_language(C)
|
||||
|
||||
add_executable(top empty.c)
|
||||
set_property(TARGET top APPEND PROPERTY LINK_LIBRARIES "foo::@<0xdeadbeef>")
|
||||
set_property(TARGET top APPEND PROPERTY LINK_LIBRARIES "foo::@(0xdeadbeef)")
|
||||
|
||||
@@ -1 +1 @@
|
||||
-- LINK_LIBRARIES='foo::@<[Xx0-9A-Fa-f]+>'
|
||||
-- LINK_LIBRARIES='foo::@\([Xx0-9A-Fa-f]+\)'
|
||||
|
||||
Reference in New Issue
Block a user