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

Eric Noulard eric.noulard at gmail.com
Thu Feb 16 15:29:33 EST 2012


2012/2/14 Alexander Neundorf <neundorf at kde.org>:
> On Tuesday 14 February 2012, Brad King wrote:
>> On 2/14/2012 1:26 PM, Alexander Neundorf wrote:
>> > Well, CMakeConfigHelpers.cmake would be shipped with cmake, so as long as
>> > the Config.cmake file says
>> > cmake_minimum_required(VERSION 2.8.8)
>> > it would be fine.
>>
>> ...and we have to maintain compatibility in the module no matter what.
>> It is much easier if the config files are standalone.
>
> Yes, that's a good point.
> Another option would be to install the included file along the Config.cmake
> file.

Since you are wanting to generate the Config file may be you can simply
write whatever CMake macros/function you need in it directly.
>From my point of view a generated file does not necessarily have to  be
as small as possible.
This would waste some place but make the Config file totally standalone.

>> >> (2) The content of a relocatable BarConfig.cmake should not depend on
>> >> where it happened to be installed when the package was built.
>> >
>> > I don't see a real problem with this.
>> > Actually it is a good thing if the Config.cmake file can detect whether
>> > it is in the location where it should be according to
>> > CMAKE_INSTALL_PREFIX, e.g. to ensure that the libraries are installed in
>> > the right location (so the builtin RPATHs point to the right location).
>>
>> Leaving remnants of the original build/install location is a no-no for
>> packagers.
>
> I don't know, we could ask them.
> Actually I don't think it would be a problem for a Linux distro packager,
> since in this case the original install destination will be also the final
> actual install location.
> I mean, they build the package for a place where it should be installed, and
> if you install the package via the normal package managers, this is where they
> will end up.

Yes must be true, but you are right you need to ask to some packager.
On the other hand assuming that CMAKE_INSTALL_PREFIX should contain
the final location is ignoring the CPack use case totally....

First CPack use "CPACK_PACKAGING_INSTALL_PREFIX" and not "CMAKE_INSTALL_PREFIX".
Second what would you do if relocate the package using for example
rpm --prefix or --relocate  (or dpkg -i --instdir ...) ?

Remember that "install time" may not be the same as "package install time".

>From a packager (the one building rpm or deb for example) point of view creating
such file may [?only?] be done as a post-install rule.

What are you targeting?

install-time i.e. "make install" usage?
package install time prodduced with cpack usage?
package install time NOT produced with cpack usage?
a subset of this?

Trying to comment on other answers as well.


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



More information about the cmake-developers mailing list