summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2020-09-30 12:22:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-09-30 12:22:49 (GMT)
commitf002c1cfc7f66edb9c9821524671574c23f92cd2 (patch)
tree35244a9e4a630d12df182842b66a5daa536b0ca7 /Source
parent1c3244ca30d3139c61f7c8d99481d5c00295e97c (diff)
parent212b0afb66d293bb88261710a3365f95b8104898 (diff)
downloadCMake-f002c1cfc7f66edb9c9821524671574c23f92cd2.zip
CMake-f002c1cfc7f66edb9c9821524671574c23f92cd2.tar.gz
CMake-f002c1cfc7f66edb9c9821524671574c23f92cd2.tar.bz2
Merge topic 'find-package-check-empty-version-range'
212b0afb66 find_package: raise error on empty version range Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5294
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFindPackageCommand.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 51137b3..86251d2 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -426,7 +426,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
// fill various parts of version specification
if (!this->VersionComplete.empty()) {
if (!versionRegex.find(this->VersionComplete)) {
- this->SetError("called with invalid version specification");
+ this->SetError("called with invalid version specification.");
return false;
}
@@ -440,6 +440,19 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
}
}
+ if (!this->VersionRange.empty()) {
+ // version range must not be empty
+ if ((this->VersionRangeMax == VERSION_ENDPOINT_INCLUDED &&
+ cmSystemTools::VersionCompareGreater(this->Version,
+ this->VersionMax)) ||
+ (this->VersionRangeMax == VERSION_ENDPOINT_EXCLUDED &&
+ cmSystemTools::VersionCompareGreaterEq(this->Version,
+ this->VersionMax))) {
+ this->SetError("specified version range is empty.");
+ return false;
+ }
+ }
+
if (this->VersionExact && !this->VersionRange.empty()) {
this->SetError("EXACT cannot be specified with a version range.");
return false;