diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-29 11:02:23 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-29 11:06:09 (GMT) |
commit | 212b0afb66d293bb88261710a3365f95b8104898 (patch) | |
tree | f41da17c590f760f171b068701970bda08ebc030 /Source | |
parent | 1382002ae2e78ea8bcda7f97be9130246ea40b11 (diff) | |
download | CMake-212b0afb66d293bb88261710a3365f95b8104898.zip CMake-212b0afb66d293bb88261710a3365f95b8104898.tar.gz CMake-212b0afb66d293bb88261710a3365f95b8104898.tar.bz2 |
find_package: raise error on empty version range
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 15 |
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; |