Hi,
I have problems understanding how the cmake-buildsystem is supposed to
resolve inter-package dependencies (imported targets form installed
packages).

Let say I have a project with an executable target (e.g. someApp) that
depends on a library (libfoo). While libfoo is built in a separate
project and depends on libbar which is built in another project.
Libbar and libfoo export cmake packages (fooConfig.cmake,
fooVersion.cmake fooTargets.cmake etc.) according to [1] and [3]

I.e.:
someApp->libfoo->libbar

In libfoo:
- find_package(bar CONFIG REQUIRED)
- target_link_libraries(bar::bar)

The packages are installed and found - no problem here.
In FooTargets.cmake the dependency on bar::bar is added to
INTERFACE_LINK_LIBRARIES.

If in someApp I find foo find_package(foo CONFIG REQUIRED)
I get an error: "The following imported targets are referenced, but are
missing: bar::bar"

The current workaround is to manually add in someApp
find_package(bar CONFIG REQUIRED) before
find_package(foo CONFIG REQUIRED)


But in my understanding this find_package(bar) should somehow be
resolved from the package foo - am I wrong?
The client should not have to resolve the entire dependency tree
manually bay adding find_package() in the correct order.
How can this be done?

Do I miss something or does CMake (3.4) just not do what I want it to do
out of the box?

Thanks in advance!
Thomas

I am using the wiki + reference:
[1] https://cmake.org/Wiki/CMake/Tutorials/Packaging
[2] https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
and this example:
[3] https://github.com/forexample/package-example


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to