summaryrefslogtreecommitdiff
path: root/Tests/FindPackageTest/CMakeLists.txt
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2012-02-16 23:12:14 +0100
committerBrad King <brad.king@kitware.com>2012-03-07 11:23:11 -0500
commit204f5d443c68317b8a24439035bf1f6c39cc001c (patch)
tree81b4467962c18126c2e5adedf447a67751bd811c /Tests/FindPackageTest/CMakeLists.txt
parenta8b57149351168425f4040c8b99167238cca041d (diff)
downloadcmake-204f5d443c68317b8a24439035bf1f6c39cc001c.tar.gz
add CMakePackageConfigHelpers: configure_package_config_file()
The function configure_package_config_file() may be used instead of configure_file() for generating the Config.cmake files for installation, they help to make those files relocatable. Alex
Diffstat (limited to 'Tests/FindPackageTest/CMakeLists.txt')
-rw-r--r--Tests/FindPackageTest/CMakeLists.txt28
1 files changed, 28 insertions, 0 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index 9a4bdfeb5d..19255bfec2 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -305,6 +305,34 @@ STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION})
FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
#-----------------------------------------------------------------------------
+# Test configure_package_config_file().
+
+include(CMakePackageConfigHelpers)
+
+set(INCLUDE_INSTALL_DIR include )
+set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/" )
+set(CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
+
+configure_package_config_file(RelocatableConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake"
+ INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}"
+ PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
+ )
+
+include("${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake")
+
+if(NOT "${RELOC_INCLUDE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/include")
+ message(SEND_ERROR "RELOC_INCLUDE_DIR set by configure_package_config_file() is set to \"${RELOC_INCLUDE_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}/include\")")
+endif()
+
+if(NOT "${RELOC_SHARE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/share/")
+ message(SEND_ERROR "RELOC_SHARE_DIR set by configure_package_config_file() is set to \"${RELOC_SHARE_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}/share/\")")
+endif()
+
+if(NOT "${RELOC_BUILD_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
+ message(SEND_ERROR "RELOC_BUILD_DIR set by configure_package_config_file() is set to \"${RELOC_BUILD_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}\")")
+endif()
+
+#-----------------------------------------------------------------------------
# Test write_basic_config_version_file().
include(WriteBasicConfigVersionFile)