aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-07-26 20:39:12 +0200
committerAlex Neundorf <neundorf@kde.org>2011-07-26 20:39:12 +0200
commitc195f8d0b9d4788daa0cf3d890008106ff296810 (patch)
treef2867cd01163b7ed301c5ca6c85c31b8e4b3d779
parentcfa5ab513b179ab6122879e6c5375449e0e80c3e (diff)
downloadextra-cmake-modules-c195f8d0b9d4788daa0cf3d890008106ff296810.tar.gz
extra-cmake-modules-c195f8d0b9d4788daa0cf3d890008106ff296810.tar.bz2
Install a Config.cmake file and a version-file along with it
Alex
-rw-r--r--CMakeLists.txt21
-rw-r--r--extra-cmake-modules-config-version.cmake.in24
-rw-r--r--extra-cmake-modules-config.cmake.in9
3 files changed, 52 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d820fec4..6d8f6493 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,11 @@ set(ECM_PATCH_VERSION 1 )
set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION} )
+set(SHARE_INSTALL_DIR share/extra-cmake-modules-${ECM_VERSION} )
+set(MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/modules/ )
+set(CMAKECONFIG_INSTALL_DIR ${SHARE_INSTALL_DIR}/cmake/ )
+set(DOC_INSTALL_DIR ${SHARE_INSTALL_DIR}/doc/ )
+
# create and install docs
add_custom_target(ManPage ALL
COMMAND ${CMAKE_COMMAND} -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/modules --help-custom-modules "${CMAKE_BINARY_DIR}/extra-cmake-modules.1"
@@ -18,12 +23,24 @@ add_custom_target(ManPage ALL
install(FILES "${CMAKE_BINARY_DIR}/extra-cmake-modules.1" DESTINATION man/man1/ )
install(FILES "${CMAKE_BINARY_DIR}/extra-cmake-modules.txt" "${CMAKE_BINARY_DIR}/extra-cmake-modules.html"
- DESTINATION share/extra-cmake-modules-${ECM_VERSION}/doc/ )
+ DESTINATION ${DOC_INSTALL_DIR} )
file(GLOB installFiles ${CMAKE_SOURCE_DIR}/modules/*cmake )
-install(FILES ${installFiles} DESTINATION share/extra-cmake-modules-${ECM_VERSION}/modules/ )
+install(FILES ${installFiles} DESTINATION ${MODULES_INSTALL_DIR} )
+
+# figure out the relative path from the installed Config.cmake file to the install prefix (which may be at
+# runtime different from the chosen CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere)
+# This relative path will be configured into the BarConfig.cmake
+file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX} )
+
+configure_file(extra-cmake-modules-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/extra-cmake-modules-config.cmake @ONLY)
+configure_file(extra-cmake-modules-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/extra-cmake-modules-config-version.cmake @ONLY)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/extra-cmake-modules-config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/extra-cmake-modules-config-version.cmake
+ DESTINATION ${CMAKECONFIG_INSTALL_DIR} )
# need to install a Config.cmake file
diff --git a/extra-cmake-modules-config-version.cmake.in b/extra-cmake-modules-config-version.cmake.in
new file mode 100644
index 00000000..ad0bdab2
--- /dev/null
+++ b/extra-cmake-modules-config-version.cmake.in
@@ -0,0 +1,24 @@
+# This is a very basic file for the new style find_package() search mode,
+# i.e. Config-mode.
+# In this mode find_package() searches for a <package>Config.cmake
+# file and an associated <package>Version.cmake file, which it loads to check
+# the version number.
+# This file can be used with configure_file() to generate such a file for a project
+# with very basic logic.
+# It sets PACKAGE_VERSION_EXACT if the current version string and the requested
+# version string are exactly the same and it sets PACKAGE_VERSION_COMPATIBLE
+# if the current version is >= requested version.
+# If this is not good enough for your project, you need to write your own
+# improved <package>Version.cmake file.
+
+
+set(PACKAGE_VERSION @ECM_MAJOR_VERSION@.@ECM_MINOR_VERSION@.@ECM_PATCH_VERSION@)
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
diff --git a/extra-cmake-modules-config.cmake.in b/extra-cmake-modules-config.cmake.in
new file mode 100644
index 00000000..e3b29990
--- /dev/null
+++ b/extra-cmake-modules-config.cmake.in
@@ -0,0 +1,9 @@
+get_filename_component(rootDir ${CMAKE_CURRENT_LIST_DIR}/@relInstallDir@ ABSOLUTE) # get the chosen install prefix
+
+# set the version of myself
+set(EXTRA_CMAKE_MODULES_VERSION_MAJOR @ECM_MAJOR_VERSION@)
+set(EXTRA_CMAKE_MODULES_VERSION_MINOR @ECM_MINOR_VERSION@)
+set(EXTRA_CMAKE_MODULES_VERSION_PATCH @ECM_PATCH_VERSION@)
+set(EXTRA_CMAKE_MODULES_VERSION ${EXTRA_CMAKE_MODULES_VERSION_MAJOR}.${EXTRA_CMAKE_MODULES_VERSION_MINOR}.${EXTRA_CMAKE_MODULES_VERSION_PATCH} )
+
+set(EXTRA_CMAKE_MODULES_MODULE_PATH "${rootDir}/@MODULES_INSTALL_DIR@")