summaryrefslogtreecommitdiff
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-09-29 13:02:23 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2020-09-29 13:06:09 +0200
commit212b0afb66d293bb88261710a3365f95b8104898 (patch)
treef41da17c590f760f171b068701970bda08ebc030 /Source/cmFindPackageCommand.cxx
parent1382002ae2e78ea8bcda7f97be9130246ea40b11 (diff)
downloadcmake-212b0afb66d293bb88261710a3365f95b8104898.tar.gz
find_package: raise error on empty version range
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 51137b3829..86251d2eb9 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;