Commit 07f029d6 authored by Brad King's avatar Brad King
Browse files

Test the user package registry

We teach the FindPackageTest to build a sample project that stores its
build tree in the user package registry using export(PACKAGE), and then
find it with find_package.
parent 16ce84b0
......@@ -180,3 +180,16 @@ ENDIF()
IF(NOT "1.2" VERSION_EQUAL "1.2.0.0")
MESSAGE(SEND_ERROR "1.2 VERSION_EQUAL 1.2.0.0 is not true!")
ENDIF()
#-----------------------------------------------------------------------------
# Test export(PACKAGE) with find_package.
MESSAGE(STATUS "Preparing export(PACKAGE) test project")
TRY_COMPILE(EXPORTER_COMPILED
${FindPackageTest_BINARY_DIR}/Exporter
${FindPackageTest_SOURCE_DIR}/Exporter
CMakeTestExportPackage dummy
OUTPUT_VARIABLE output)
MESSAGE(STATUS "Searching for export(PACKAGE) test project")
SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH
"Wipe out find results for testing." FORCE)
FIND_PACKAGE(CMakeTestExportPackage 1.${CMAKE_VERSION} EXACT REQUIRED)
cmake_minimum_required(VERSION 2.7.20090831)
project(CMakeTestExportPackage C)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeTestExportPackageConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeTestExportPackageConfig.cmake
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeTestExportPackageConfigVersion.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeTestExportPackageConfigVersion.cmake
@ONLY)
export(PACKAGE CMakeTestExportPackage)
add_executable(dummy dummy.c)
# Test config file.
SET(PACKAGE_VERSION "1.@CMAKE_VERSION@")
IF("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
SET(PACKAGE_VERSION_COMPATIBLE 1)
SET(PACKAGE_VERSION_EXACT 1)
ENDIF()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment