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:
parent
16ce84b067
commit
07f029d6ef
|
@ -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)
|
||||
|
|
|
@ -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)
|
|
@ -0,0 +1 @@
|
|||
# Test config 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()
|
|
@ -0,0 +1 @@
|
|||
int main() { return 0; }
|
Loading…
Reference in New Issue