CMakePackageConfigHelpers: Add unit tests for INSTALL_PREFIX option

This commit is contained in:
Daniele E. Domenichelli 2014-07-15 19:51:16 +02:00 committed by Brad King
parent d057bf85a6
commit e3007c92e0
1 changed files with 38 additions and 0 deletions

View File

@ -374,6 +374,7 @@ endif()
include(CMakePackageConfigHelpers)
# Generate a config file ready to be installed.
set(INCLUDE_INSTALL_DIR include )
set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/" )
set(CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
@ -407,6 +408,43 @@ if(Relocatable_FOUND)
message(SEND_ERROR "Relocatable_FOUND set to TRUE !")
endif()
# Generate a config file for the build tree.
set(INCLUDE_INSTALL_DIR include )
set(SHARE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/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_CURRENT_BINARY_DIR}"
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
)
set(Relocatable_FIND_COMPONENTS AComp BComp CComp)
set(Relocatable_FIND_REQUIRED_BComp 1)
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()
if(NOT DEFINED Relocatable_FOUND)
message(SEND_ERROR "Relocatable_FOUND not defined !")
endif()
if(Relocatable_FOUND)
message(SEND_ERROR "Relocatable_FOUND set to TRUE !")
endif()
#-----------------------------------------------------------------------------
# Test write_basic_config_version_file().