[cmake-developers] Exported targets with imported dependencies in CMake 3.0

Philipp Moeller bootsarehax at gmail.com
Thu Mar 6 10:00:44 EST 2014


Jean-Christophe Fillion-Robin
<jchris.fillionr at kitware.com> writes:

> .. and whenever possible the FindXXX.cmake should defined imported targets.

This has been another big problem I encountered while trying to fully
"targetify" my build system: find_package files just aren't up to speed
yet. I was thinking about making this a separate post, but I can bring
this up here as well.

It might be possible to have some general find_targets() which
essentially wraps a find_package() call and produce imported
targets. This could work for most of the general cases, but some
libraries need special-casing (Boost comes to mind, where thread has to
depend on system and as of a special version chrono, unless boost-cmake
is used, which virtually no distribution does).

>
> On Thu, Mar 6, 2014 at 9:38 AM, Philipp Möller <bootsarehax at gmail.com>wrote:
>
>> Stephen Kelly <steveire at gmail.com> writes:
>>
>> > Philipp Möller wrote:
>> >> It would be great, if I could export imported targets and if CMake could
>> >> walk the dependency tree automatically and import those targets on an
>> >> as-needed basis.
>> >
>> > Part of the problem is that the place where you import your dependent
>> > targets from (and the locations calculated) are not necessarily the same
>> for
>> > your downstreams.
>>
>> I understand the issue and have been fighting it in versions prior 3.0
>> as well. It also arises if you simply export targets that have been
>> target_link_librarie'd against full library paths returned by a
>> find_package.
>>
>> That's why I thought some build-in functionality could be helpful for
>> this, e.g. exporting and imported target would lead to a definition in
>> the exports file that automatically triggers a corresponding
>> find_package call.
>>
>> > You export your targets to and -exports file, and presumably you import
>> that
>> > in a -config file. In the same config file, you should add code to find
>> your
>> > dependencies too.
>> >
>> >
>> http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#creating-packages
>> >
>> > The find_dependency macro can help with forwarding some find_package
>> > arguments.
>> >
>> >
>> http://www.cmake.org/cmake/help/v3.0/module/CMakeFindDependencyMacro.html
>>
>> The documentation is a little sparse, but I think I understand the
>> purpose. I still need to traverse IMPORTED_LINK_INTERFACE_LIBRARIES and
>> figure out which of the list members constitutes a target that needs to
>> trigger a find_dependency and what a full library path is, correct?
>>
>> I can also not rely on a find_package call to actually produce imported
>> targets and need to ship the code that turns the results of find_package
>> in targets.
>>
>> Thanks for your help,
>> Philipp
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers




More information about the cmake-developers mailing list