diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2018-11-13 14:39:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-03-15 14:24:47 (GMT) |
commit | 9bede5c4cecd71fba7ce6a0687c4a68e1c84a54b (patch) | |
tree | 57e94c1e43b25ea3706b55cccff48d57b25dfc6d /Source/cmExportCommand.cxx | |
parent | 0df31d99ae44e1e151feb4df977a4332833ea872 (diff) | |
download | CMake-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 'Source/cmExportCommand.cxx')
-rw-r--r-- | Source/cmExportCommand.cxx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 722831a..c25e1f4 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -13,6 +13,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmPolicies.h" #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -243,10 +244,23 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args) return false; } - // If the CMAKE_EXPORT_NO_PACKAGE_REGISTRY variable is set the command - // export(PACKAGE) does nothing. - if (this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) { - return true; + // CMP0090 decides both the default and what variable changes it. + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0090)) { + case cmPolicies::WARN: + case cmPolicies::OLD: + // Default is to export, but can be disabled. + if (this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) { + return true; + } + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Default is to not export, but can be enabled. + if (!this->Makefile->IsOn("CMAKE_EXPORT_PACKAGE_REGISTRY")) { + return true; + } + break; } // We store the current build directory in the registry as a value |