summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-07-11 16:56:24 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-07-11 16:56:24 (GMT)
commitd7d6fcea7ae9b8d9fcd03789a41f57b0c9a88f2f (patch)
tree58619cbedc894a414916b3ff2bf435adfe06f588
parent930aeabbed9b9694fe23a5e3c3156e3c5b85724a (diff)
downloadlibkolabxml-d7d6fcea7ae9b8d9fcd03789a41f57b0c9a88f2f.tar.gz
Deal with relative as well as absolute install paths.
-rw-r--r--CMakeLists.txt15
-rw-r--r--cmake/modules/LibkolabxmlConfig.cmake.in17
2 files changed, 21 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3256556..c1bd505 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,6 +80,14 @@ set(INCLUDE_INSTALL_DIR include CACHE STRING "The directory where to install hea
set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/kolabxml)
set(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/Libkolabxml )
+# Make relative paths absolute (needed later on)
+foreach(p LIB INCLUDE CMAKECONFIG)
+ set(var ${p}_INSTALL_DIR)
+ if(NOT IS_ABSOLUTE "${${var}}")
+ set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
+ endif()
+endforeach()
+
configure_file(libkolabxml-version.h.cmake "${CMAKE_BINARY_DIR}/libkolabxml-version.h" @ONLY)
set(Boost_USE_MULTITHREADED ON)
@@ -189,9 +197,12 @@ if (BUILD_TESTS)
add_subdirectory(tests)
endif()
-install(EXPORT LibkolabxmlExport DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE LibkolabxmlTargets.cmake )
+#Get the include directory relative to CMAKECONFIG_INSTALL_DIR
+file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKECONFIG_INSTALL_DIR}" "${INCLUDE_INSTALL_DIR}")
+#Assemble the full relative path. This will be used in the LibkolabxmlConfig.cmake, which will be installed in CMAKECONFIG_INSTALL_DIR
+set(CONF_INCLUDE_DIRS "\${Libkolabxml_CMAKE_DIR}/${REL_INCLUDE_DIR}")
-file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX} )
+install(EXPORT LibkolabxmlExport DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE LibkolabxmlTargets.cmake )
configure_file(${Libkolabxml_MODULE_DIR}/LibkolabxmlConfig.cmake.in ${Libkolabxml_BINARY_DIR}/LibkolabxmlConfig.cmake @ONLY )
configure_file(${Libkolabxml_MODULE_DIR}/LibkolabxmlConfigVersion.cmake.in ${Libkolabxml_BINARY_DIR}/LibkolabxmlConfigVersion.cmake @ONLY )
diff --git a/cmake/modules/LibkolabxmlConfig.cmake.in b/cmake/modules/LibkolabxmlConfig.cmake.in
index f42726f..40f30a4 100644
--- a/cmake/modules/LibkolabxmlConfig.cmake.in
+++ b/cmake/modules/LibkolabxmlConfig.cmake.in
@@ -1,18 +1,17 @@
-get_filename_component(myDir ${CMAKE_CURRENT_LIST_FILE} PATH) # get the directory where I myself am
-get_filename_component(rootDir ${myDir}/@relInstallDir@ ABSOLUTE) # get the chosen install prefix
+get_filename_component(Libkolabxml_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) #get the directory where this *Config.cmake file is installed
-# set the version of myself
+# set the version
set(Libkolabxml_VERSION_MAJOR @Libkolabxml_VERSION_MAJOR@)
set(Libkolabxml_VERSION_MINOR @Libkolabxml_VERSION_MINOR@)
set(Libkolabxml_VERSION_PATCH @Libkolabxml_VERSION_PATCH@)
-set(Libkolabxml_VERSION ${Libkolabxml_VERSION_MAJOR}.${Libkolabxml_VERSION_MINOR}.${Libkolabxml_VERSION_PATCH} )
+set(Libkolabxml_VERSION ${Libkolabxml_VERSION_MAJOR}.${Libkolabxml_VERSION_MINOR}.${Libkolabxml_VERSION_PATCH})
-# what is my include directory
-set(Libkolabxml_INSTALL_PREFIX "${rootDir}")
-set(Libkolabxml_INCLUDES "${rootDir}/@INCLUDE_INSTALL_DIR@")
+# Set the include directory
+set(Libkolabxml_INCLUDES "@CONF_INCLUDE_DIRS@")
# import the exported targets
-include(${myDir}/LibkolabxmlTargets.cmake)
+include(${Libkolab_CMAKE_DIR}/LibkolabxmlTargets.cmake)
# set the expected library variable
-set(Libkolabxml_LIBRARIES kolabxml )
+set(Libkolabxml_LIBRARIES kolabxml)
+