<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    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">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">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">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>
  </body>
</html>