[CMake] transitive linking with separate projects
Michael Hertling
mhertling at online.de
Wed Mar 7 06:39:29 EST 2012
On 03/07/2012 11:29 AM, Alexander Dahl wrote:
> Hello Michael,
>
> Am 2012-03-06 16:46, schrieb Michael Hertling:
>> or possibly better:
>>
>> # libbar/bar-config.cmake.in:
>> FIND_PACKAGE(FOO PATHS @FOO_DIR@ NO_DEFAULT_PATH)
>
> I used
>
> FIND_PACKAGE(FOO 0.1.0 REQUIRED)
>
> in the package config file now, which works, too.
Actually, FIND_PACKAGE(FOO PATHS @FOO_DIR@ NO_DEFAULT_PATH) is meant
to ensure that bar-config.cmake loads the *same* foo-config.cmake as
bar's CMakeLists.txt has before. Possibly, it's even the best to use
exactly the same parameters - apart from PATHS and NO_DEFAULT_PATH -
i.e., version, components, external variables etc., in order to
guarantee that really the same foo-targets.cmake is included.
>> BTW, find modules / config files should provide a *_LIBRARIES variable
>> even if they use imported targets, e.g.: SET(FOO_LIBRARIES foo-shared)
>
> I added this. Let me guess, this is for convenience with find rules
> using the same variables?
Yes, in this way, it works with imported targets as well as full paths.
>> PS: The baz project on GitHub only contains a README.
>
> I forgot to push this one.
>
> Thanks very much, I guess this solves this kind of problem with my
> packages. :-)
See also [1].
Regards,
Michael
[1] http://public.kitware.com/Bug/view.php?id=12588
More information about the CMake
mailing list