Making writing Config.cmake files easier - updated example

Yury G. Kudryashov urkud.urkud at gmail.com
Mon Jan 16 10:25:20 UTC 2012


Yury G.  Kudryashov wrote:

> 15 January 2012 20:06:51 Alexander Neundorf written:
>> Hi,
> Hi,
> 
> Try #1 awaits moderator approval and can be safely deleted.
>> 
>> I create a new branch ImprovedConfigDotCMakeFile in the kdeexamples
>> repository, used by the buildsystem/HowToInstallALibrary/ example:
>> 
> 
http://quickgit.kde.org/?p=kdeexamples.git&a=tree&h=9c8e84b16079b35f15c50ea0
>> 
> 
27bbc95bd387bf90&hb=6caa67be56231d3017859a26db2097b8c8826f4e&f=buildsystem/H
>> owToInstallALibrary
>> 
>> It adds two new macros, currently called determine_installed_location()
> and
>> set_absolute() which should help with that.
>> Once polished, they should go into cmake (2.8.8), so everybody can use
> them.
> The only comment: there are 4 possible combinations of
> cmake -DLIB_INSTALL_DIR=relative_or_absolute -
> DINCLUDE_INSTALL_DIR=relative_or_absolute
> It seems that your library will not be relocatable if INCLUDE_INSTALL_DIR
> is set to an absolute path.
>> 
>> With these two new macros, the developer does not have to calculate the
>> relative and absolute paths himself anymore, but can rely on their logic.
>> Also the CMakeLists.txt becomes a bit simpler, by removing the IMO most
>> obscure part (the calculation of the relative install dir).
>> 
>> Comments ?
> I'm working on another way to solve the same problem. I'll commit results
> to kdeexamples tonight or tomorrow.
An alpha-version is attached.

Usage example:
 // Add EXPORT LibKexiv2 to kexiv2 target and
  INCLUDE(MacroWriteConfigFile)
  INSTALL_CMAKE_CONFIG_FILES(LibKexiv2
                       VERSION ${KEXIV2_LIB_VERSION}
                       VERSION_STRING ${KEXIV2_LIB_VERSION_STRING}
                       EXPORT_NAMESPACE LibKexiv2::
                       TARGETS kexiv2)

Actually, I'd prefer to have
install(EXPORT ... ... INSTALL_CONFIG [bool] PACKAGE_NAME [=ExportName])
or
install(EXPORT ...)
config_for_export(ExportName VERSION ... VERSION_STRING ... EXTRA_VARS ...).
What do you think about this?

I cannot implement config_for_export() because I don't know how to query 
cmake for the list of targets associated with given export (is it 
possible?).
-- 
Yury G. Kudryashov,
mailto: urkud at mccme.ru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MacroWriteConfigFile.cmake
Type: text/x-cmake
Size: 7058 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-buildsystem/attachments/20120116/3d96d749/attachment.bin>


More information about the Kde-buildsystem mailing list