diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindPackageTest/CMakeLists.txt | 37 | ||||
-rw-r--r-- | Tests/FindPackageTest/RelocatableConfig.cmake.in | 5 |
2 files changed, 37 insertions, 5 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 9a4bdfe..a4f213b 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -305,13 +305,39 @@ STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED) #----------------------------------------------------------------------------- -# Test write_basic_config_version_file(). +# Test configure_package_config_file(). -include(WriteBasicConfigVersionFile) +include(CMakePackageConfigHelpers) -write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake - VERSION 1.2.3 - COMPATIBILITY AnyNewerVersion) +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(). + +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY AnyNewerVersion) set(PACKAGE_FIND_VERSION 2.3.4) include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) @@ -345,6 +371,7 @@ endif() ####################### +include(WriteBasicConfigVersionFile) write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake VERSION 1.2.3 diff --git a/Tests/FindPackageTest/RelocatableConfig.cmake.in b/Tests/FindPackageTest/RelocatableConfig.cmake.in new file mode 100644 index 0000000..7a34b2f --- /dev/null +++ b/Tests/FindPackageTest/RelocatableConfig.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +set(RELOC_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set(RELOC_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@") +set_and_check(RELOC_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@") |