15 January 2012 20:06:51 Alexander Neundorf written: > Hi, > > 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.
Basically, my goal is a macro that writes and installs *Config.cmake files in
"simple" cases and makes library available to find_package() both from another
subdirectory of the same project and after installation. What do you think
about this approach?
The proposed syntax is:
install_cmake_config_files(Package
LIBRARY_TARGETS (target|NAME=target)+ [EXECUTABLE_TARGETS (NAME=target)+]
[VERSION version=PACKAGE_VERSION] [VERSION_STRING <var|value>]
[EXPORT_NAME name=Package] [EXPORT_NAMESPACE ns="" or Package?]
[DESTINATION destination=platform-specific default]
[INSTALLED_INCLUDES dirs=${INCLUDE_INSTALL_DIR} or
${CMAKE_INSTALL_INCLUDEDIR}]
[BUILD_INCLUDES dirs=${CMAKE_CURRENT_SOURCE_DIR}]
[EXTRA_VARS (name|name=value)*] [EXTRA_CONFIG_FILE file])
The macros will:
0. Set all unspecified parameters to sane defaults, so in many cases you'll
just have to set package name, LIBRARY_TARGETS, EXPORT_NAME and
EXPORT_NAMESPACE. BTW, is it possible to query which EXPORT does the given
target belongs to? Or the other way around, the
1. Write PackageConfig-external.cmake and install it to
DESTINATION/PackageConfig.cmake.
2. Write PackageConfig.cmake and call export(PACKAGE Package).
3. Call install(EXPORT).
The PackageConfig-external.cmake will contain (pseudo-cmake.in, @ONLY):
set(@PACKAGE@_VERSION @PACKAGE_VERSION@)
set(@PACKAGE@_VERSION_STRING @PACKAGE_VERSION_STRING@) // if present
get_filename_component(ICCF_CWD ${CMAKE_CURRENT_LIST_FILE} PATH)
set(@PACKAGE@_INCLUDE_DIRS ${ICCF_CWD}/@RELATIVE_PATH_TO_INSTALLED_INCLUDES@)
include(@[email protected]) // Export file
// Next line for each NAME=target in EXECUTABLE_TARGETS
set(@PACKAGE@_@NAME@_EXECUTABLE @EXPORT_NAMESPACE@@target@)
// Next line for each NAME=target in LIBRARY_TARGETS
set(PACKAGE_@NAME@_LIBRARY @EXPORT_NAMESPACE@@target@)
set(PACKAGE_LIBRARIES @EXPORT_NAMESPACE@@ALL_LIBRARIES_IN_LIBRARY_TARGETS@)
// Next line for each NAME=value in EXTRA_VARS
set(@NAME@ @value@)
// Next line for each 'var' in EXTRA_VARS
set(@var@ @${var}@)
@EXTRA_CONFIG_FILE_CONFIGURED@
The PackageConfig.cmake will contain the same information adjusted for
"internal" usage.
--
Yury G. Kudryashov,
mailto: [email protected]
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Kde-buildsystem mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-buildsystem
