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.
This commit is contained in:
Brad King 2009-09-01 14:05:42 -04:00
parent 16ce84b067
commit 07f029d6ef
5 changed files with 33 additions and 0 deletions

View File

@ -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)

View File

@ -0,0 +1,12 @@
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)

View File

@ -0,0 +1 @@
# Test config file.

View File

@ -0,0 +1,6 @@
# 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()

View File

@ -0,0 +1 @@
int main() { return 0; }