[cmake-developers] [ANNOUNCE] CMake 3.12.0-rc2 is ready for testing

Rolf Eike Beer eike at sf-mail.de
Sat Jun 30 15:15:38 EDT 2018


> * The "target_link_libraries()" command may now be called to modify
>   targets created outside the current directory.

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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part.
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20180630/33dc9da8/attachment.sig>


More information about the cmake-developers mailing list