[CMake] Automatic inclusion of import targets found by find_package()?

Robert Dailey rcdailey.lists at gmail.com
Sun Jul 10 15:16:21 EDT 2016


Let's say I have my own upstream library and I export a target for it.
This subsequent cmake file (containing my IMPORT target definition) is
included with my tarball.

When a consuming project wants to find and use my import targets, they
currently have to do (consider this pseudocode since i just typed it
up for example purposes):

find_package(mylibrary REQUIRED CONFIG)
include(${mylibrary_DIR}/lib/cmake/mylibrary-0.1.2/mylibrary.cmake)
add_executable(fubar mylibrary)

It would be nice if the include part happened automatically. Mostly
because since the version number is intertwined with the path, it
makes explicitly specifying it cumbersome and high maintenance.

Is there more automation here that I'm not seeing? Thanks in advance.


More information about the CMake mailing list