[cmake-developers] Making Config.cmake files easier to write

Eric Noulard eric.noulard at gmail.com
Fri Feb 17 02:58:36 EST 2012


2012/2/16 Brad King <brad.king at kitware.com>:
> On 2/16/2012 4:13 PM, David Cole wrote:
>
>> On Thu, Feb 16, 2012 at 3:52 PM, Eric Noulard <eric.noulard at gmail.com
>> <mailto:eric.noulard at gmail.com>> wrote:
>>    I'm not convinced, yet I'll have to try with the example provided by
>> Alex
>>    by adding proper CPack usage in it.
>>
>>    Currently I see in BarConfig.cmake
>>    get_filename_component(BAR_HELPER_PREFIX_DIR
>>    "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
>
> [snip]
>
>> It can't work with CPack, not in the sense of "work" as in "the
>> software will run from its DESTDIR-based intermediate CPack
>> driven install location"
>
> It can.  The main feature of what Alex wrote based on a combination
> of his, Yury's, and my ideas is that the generated BarConfig.cmake has
> no hard-coded paths containing the installation prefix in any form,
> DESTDIR or not.  The line
>
>
>  get_filename_component(BAR_HELPER_PREFIX_DIR
>   "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
>
> is evaluated when BarConfig.cmake is *loaded* at which point the
> ${CMAKE_CURRENT_LIST_DIR} will be replaced with the *current* location
> of the file as it exists when loaded.

Yes right I got that, my point was that the "/../../../"
which was computed at configure time was computed w.r.t. CMAKE_INSTALL_PREFIX
know at CMake-time.

> It doesn't matter if it is in
> the real install location, DESTDIR, or a tarball that was extracted
> at an arbitrary location on another machine.  The load-time prefix
> is computed relative to the file's location.  Under that prefix the
> file refers to all the other pieces (include, etc.) which exist at
> a fixed location relative to BarConfig.cmake.

Right I did not realize that relative position should still be valid.
In fact I'm pretty sure you can break this if you mess-up with
absolute install destination, but if ones to that there is no point in using
this so...

Ok thank you (and David) for enlighting me on this.


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the cmake-developers mailing list