<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
I've reproduced the error. A possible fix would be to extend
pkg_check_module and pkg_search_module to allow globally imported
targets, i.e. to add an IMPORTED_GLOBAL_TARGET or GLOBAL keyword
(where the latter is only usable together with IMPORTED_TARGET) to
allow similar control as add_library.<br>
<br>
Essentially, adding GLOBAL here<br>
<br>
<a class="moz-txt-link-freetext" href="https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindPkgConfig.cmake#L232">https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindPkgConfig.cmake#L232</a><br>
<br>
immediately solves the problem, so it's indeed related to target
visibility. Therefore, I think this is intended behavior and the
logic for the RHS target is correct.<br>
<br>
Maybe we should open an issue and discuss the design of the fix
there together with Brad King and the others.<br>
<br>
Best regards,<br>
Patrick Stotko<br>
<br>
<div class="moz-cite-prefix">On 30.06.2018 23:03, Patrick Stotko
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:74a095a4-8667-8491-619c-9a0e4daec645@informatik.uni-bonn.de">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
It seems that CMake does not find PkgConfig::GooCanvas because it
is imported but not globally imported, i.e. it is maybe a
visibility problem.<br>
For reference, the relaxation of this limitation (<a
class="moz-txt-link-freetext"
href="https://gitlab.kitware.com/cmake/cmake/merge_requests/2040"
moz-do-not-send="true">https://gitlab.kitware.com/cmake/cmake/merge_requests/2040</a>)
is covered by this additional check for the LHS target:<br>
<br>
<a class="moz-txt-link-freetext"
href="https://gitlab.kitware.com/cmake/cmake/blob/c9349cc1b94a08b4f5ed86a397e72ceed50847dd/Source/cmTargetLinkLibrariesCommand.cxx#L383"
moz-do-not-send="true">https://gitlab.kitware.com/cmake/cmake/blob/c9349cc1b94a08b4f5ed86a397e72ceed50847dd/Source/cmTargetLinkLibrariesCommand.cxx#L383</a><br>
<br>
Maybe a corresponding check for locally imported RHS targets is
missing here:<br>
<br>
<a class="moz-txt-link-freetext"
href="https://gitlab.kitware.com/cmake/cmake/blob/c9349cc1b94a08b4f5ed86a397e72ceed50847dd/Source/cmTargetLinkLibrariesCommand.cxx#L396"
moz-do-not-send="true">https://gitlab.kitware.com/cmake/cmake/blob/c9349cc1b94a08b4f5ed86a397e72ceed50847dd/Source/cmTargetLinkLibrariesCommand.cxx#L396</a><br>
<br>
Best regards,<br>
Patrick Stotko<br>
<br>
<br>
<div class="moz-cite-prefix">Am 30.06.2018 um 21:15 schrieb Rolf
Eike Beer:<br>
</div>
<blockquote type="cite"
cite="mid:8101126.nNzSS0tPB0@daneel.sf-tec.de">
<blockquote type="cite">
<pre wrap="">* The "target_link_libraries()" command may now be called to modify
targets created outside the current directory.
</pre>
</blockquote>
<pre wrap="">I played a bit around with that as I hope it would simplify some things in
OSM2go, but it looks there are still some limitations:
in main:
add_library(osm2go_lib ...)
add_subdirectory(sub)
in sub:
pkg_search_module(GooCanvas REQUIRED IMPORTED_TARGET goocanvas)
target_sources(osm2go_lib PRIVATE
src/platforms/gtk/canvas_goocanvas.cpp
)
target_link_libraries(osm2go_lib PRIVATE PkgConfig::GooCanvas)
Breaks:
CMake Error at CMakeLists.txt:43 (add_library):
Target "osm2go_lib" links to target "PkgConfig::GooCanvas" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Is this intended to work?
There is an easy workaround, but it feels nasty:
add_library(osm2go_x_lib INTERFACE)
target_link_libraries(osm2go_x_lib INTERFACE PkgConfig::GooCanvas)
target_link_libraries(osm2go_lib PRIVATE osm2go_x_lib)
</pre>
<!--'"--><br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
<br>
<!--'"--><br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
<br>
</body>
</html>