summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2018-11-13 14:39:27 (GMT)
committerBrad King <brad.king@kitware.com>2019-03-15 14:24:47 (GMT)
commit9bede5c4cecd71fba7ce6a0687c4a68e1c84a54b (patch)
tree57e94c1e43b25ea3706b55cccff48d57b25dfc6d /Tests
parent0df31d99ae44e1e151feb4df977a4332833ea872 (diff)
downloadCMake-9bede5c4cecd71fba7ce6a0687c4a68e1c84a54b.zip
CMake-9bede5c4cecd71fba7ce6a0687c4a68e1c84a54b.tar.gz
CMake-9bede5c4cecd71fba7ce6a0687c4a68e1c84a54b.tar.bz2
export: Disable PACKAGE mode user package registry by default
The user package registry populated by the `export()` command causes side effects outside the build and source directories. Such effects should be opt-in rather than op-out. Introduce a policy to change default behavior of `export(PACKAGE)` to do nothing.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/FindPackageTest/CMakeLists.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index f8b36c5..972580c 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -380,6 +380,7 @@ try_compile(EXPORTER_COMPILED
${FindPackageTest_SOURCE_DIR}/Exporter
CMakeTestExportPackage dummy
CMAKE_FLAGS "-UCMAKE_EXPORT_NO_PACKAGE_REGISTRY"
+ "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=OLD"
-Dversion=${version}
OUTPUT_VARIABLE output)
message(STATUS "Searching for export(PACKAGE) test project")
@@ -417,6 +418,25 @@ if(CMakeTestExportPackage_FOUND)
message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
endif()
+message(STATUS "Remove export(PACKAGE) test project")
+file(REMOVE_RECURSE ${FindPackageTest_BINARY_DIR}/Exporter-build)
+
+message(STATUS "Preparing export(PACKAGE) test project with POLICY CMP0090=NEW")
+try_compile(EXPORTER_COMPILED
+ ${FindPackageTest_BINARY_DIR}/Exporter-build
+ ${FindPackageTest_SOURCE_DIR}/Exporter
+ CMakeTestExportPackage dummy
+ CMAKE_FLAGS
+ "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=NEW"
+ -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().