summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePolicyCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-16 16:42:36 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-21 12:00:28 (GMT)
commit45408b5ea1e3654b5d4f6289ca1a0b5c0f1ac4e9 (patch)
tree73dd09488de4a0559bd3e3dd1828f8c75278f31c /Source/cmCMakePolicyCommand.cxx
parent6a41aa2abd75ceaa9081edc1c7f8510d2c17dd7e (diff)
downloadCMake-45408b5ea1e3654b5d4f6289ca1a0b5c0f1ac4e9.zip
CMake-45408b5ea1e3654b5d4f6289ca1a0b5c0f1ac4e9.tar.gz
CMake-45408b5ea1e3654b5d4f6289ca1a0b5c0f1ac4e9.tar.bz2
cmake_minimum_required: Optionally set policies with version range
Teach `cmake_minimum_required` and `cmake_policy(VERSION)` to support a version range of the form `<min>[...<max>]`. Define this to mean that version `<min>` is required, but known policies up to those introduced by `<max>` will be set to `NEW`. This will allow projects to easily specify a range of versions for which they have been updated.
Diffstat (limited to 'Source/cmCMakePolicyCommand.cxx')
-rw-r--r--Source/cmCMakePolicyCommand.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 3ccc815..7ca1cbc 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -156,6 +156,23 @@ bool cmCMakePolicyCommand::HandleVersionMode(
this->SetError("VERSION given too many arguments");
return false;
}
- this->Makefile->SetPolicyVersion(args[1].c_str());
+ std::string const& version_string = args[1];
+
+ // Separate the <min> version and any trailing ...<max> component.
+ std::string::size_type const dd = version_string.find("...");
+ std::string const version_min = version_string.substr(0, dd);
+ std::string const version_max = dd != std::string::npos
+ ? version_string.substr(dd + 3, std::string::npos)
+ : std::string();
+ if (dd != std::string::npos &&
+ (version_min.empty() || version_max.empty())) {
+ std::ostringstream e;
+ e << "VERSION \"" << version_string
+ << "\" does not have a version on both sides of \"...\".";
+ this->SetError(e.str());
+ return false;
+ }
+
+ this->Makefile->SetPolicyVersion(version_min, version_max);
return true;
}