diff options
author | Brad King <brad.king@kitware.com> | 2014-05-12 14:45:51 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-05-12 14:45:51 (GMT) |
commit | 58fcd57c40144ccacc990ad15a290021104bb919 (patch) | |
tree | 94a0aa5033b3b8d3a94cce54ab901ad4e114d932 /Tests | |
parent | e506f1f16e53915c42b4a0198dc91f232e1d1b9a (diff) | |
parent | ba387cb87129ae9e131d82040eac59a9349f8810 (diff) | |
download | CMake-58fcd57c40144ccacc990ad15a290021104bb919.zip CMake-58fcd57c40144ccacc990ad15a290021104bb919.tar.gz CMake-58fcd57c40144ccacc990ad15a290021104bb919.tar.bz2 |
Merge topic 'package-disable-registry'
ba387cb8 Help: Add notes for topic 'package-disable-registry'
be8ae960 Allow the Package Registry to be disabled (#14849)
d09fda5d Tests: Improve FindPackageTest for in-source builds
ac24a1c0 Tests: Improve FindPackageTest exported package version
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindPackageTest/CMakeLists.txt | 41 | ||||
-rw-r--r-- | Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in | 2 |
2 files changed, 40 insertions, 3 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index a77713f..092bf20 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -320,18 +320,55 @@ endif() #----------------------------------------------------------------------------- # Test export(PACKAGE) with find_package. + +# Choose a unique version. +string(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) +string(RANDOM LENGTH 4 ALPHABET "0123456789" v) +set(version "${version}.${v}") + message(STATUS "Preparing export(PACKAGE) test project") try_compile(EXPORTER_COMPILED - ${FindPackageTest_BINARY_DIR}/Exporter + ${FindPackageTest_BINARY_DIR}/Exporter-build ${FindPackageTest_SOURCE_DIR}/Exporter CMakeTestExportPackage dummy + CMAKE_FLAGS "-UCMAKE_EXPORT_NO_PACKAGE_REGISTRY" + -Dversion=${version} OUTPUT_VARIABLE output) message(STATUS "Searching for export(PACKAGE) test project") set(CMakeTestExportPackage_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) -string(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED) +message(STATUS "Searching for export(PACKAGE) test project with CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=TRUE") +set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY TRUE) +set(CMakeTestExportPackage_DIR "" CACHE FILEPATH + "Wipe out find results for testing." FORCE) +find_package(CMakeTestExportPackage 1.${version} EXACT QUIET) +if(CMakeTestExportPackage_FOUND) + message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!") +endif() +unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY) + +message(STATUS "Remove export(PACKAGE) test project") +file(REMOVE_RECURSE ${FindPackageTest_BINARY_DIR}/Exporter-build) +set(CMakeTestExportPackage_DIR "" CACHE FILEPATH + "Wipe out find results for testing." FORCE) +find_package(CMakeTestExportPackage QUIET) # Should clean the user package cache +# +message(STATUS "Preparing export(PACKAGE) test project with CMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE") +try_compile(EXPORTER_COMPILED + ${FindPackageTest_BINARY_DIR}/Exporter-build + ${FindPackageTest_SOURCE_DIR}/Exporter + CMakeTestExportPackage dummy + CMAKE_FLAGS "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY:BOOL=TRUE" + -Dversion=${version} + OUTPUT_VARIABLE output) +message(STATUS "Searching for export(PACKAGE) test project") +find_package(CMakeTestExportPackage 1.${version} EXACT QUIET) +if(CMakeTestExportPackage_FOUND) + message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!") +endif() + #----------------------------------------------------------------------------- # Test configure_package_config_file(). diff --git a/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in index 42bd84e..6eac6e6 100644 --- a/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in +++ b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in @@ -1,5 +1,5 @@ # Test config file. -set(PACKAGE_VERSION "1.@CMAKE_VERSION@") +set(PACKAGE_VERSION "1.@version@") if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}") set(PACKAGE_VERSION_COMPATIBLE 1) set(PACKAGE_VERSION_EXACT 1) |