ENH: Add UNSUITABLE result to package version test
Package version test files may now declare that they are unsuitable for use with the project testing them. This is important when the version being tested does not provide a compatible ABI with the project target environment.
This commit is contained in:
parent
79e9b75558
commit
0ae545ebad
|
@ -190,6 +190,7 @@ cmFindPackageCommand::cmFindPackageCommand()
|
||||||
" PACKAGE_VERSION = full provided version string\n"
|
" PACKAGE_VERSION = full provided version string\n"
|
||||||
" PACKAGE_VERSION_EXACT = true if version is exact match\n"
|
" PACKAGE_VERSION_EXACT = true if version is exact match\n"
|
||||||
" PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n"
|
" PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n"
|
||||||
|
" PACKAGE_VERSION_UNSUITABLE = true if unsuitable as any version\n"
|
||||||
"These variables are checked by the find_package command to determine "
|
"These variables are checked by the find_package command to determine "
|
||||||
"whether the configuration file provides an acceptable version. "
|
"whether the configuration file provides an acceptable version. "
|
||||||
"They are not available after the find_package call returns. "
|
"They are not available after the find_package call returns. "
|
||||||
|
@ -1273,6 +1274,7 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file)
|
||||||
|
|
||||||
// Clear the output variables.
|
// Clear the output variables.
|
||||||
this->Makefile->RemoveDefinition("PACKAGE_VERSION");
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION");
|
||||||
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION_UNSUITABLE");
|
||||||
this->Makefile->RemoveDefinition("PACKAGE_VERSION_COMPATIBLE");
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION_COMPATIBLE");
|
||||||
this->Makefile->RemoveDefinition("PACKAGE_VERSION_EXACT");
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION_EXACT");
|
||||||
|
|
||||||
|
@ -1293,16 +1295,21 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file)
|
||||||
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf);
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf);
|
||||||
|
|
||||||
// Load the version check file.
|
// Load the version check file.
|
||||||
bool found = false;
|
bool suitable = false;
|
||||||
if(this->ReadListFile(version_file.c_str()))
|
if(this->ReadListFile(version_file.c_str()))
|
||||||
{
|
{
|
||||||
// Check the output variables.
|
// Check the output variables.
|
||||||
found = this->Makefile->IsOn("PACKAGE_VERSION_EXACT");
|
bool okay = this->Makefile->IsOn("PACKAGE_VERSION_EXACT");
|
||||||
if(!found && !this->VersionExact)
|
bool unsuitable = this->Makefile->IsOn("PACKAGE_VERSION_UNSUITABLE");
|
||||||
|
if(!okay && !this->VersionExact)
|
||||||
{
|
{
|
||||||
found = this->Makefile->IsOn("PACKAGE_VERSION_COMPATIBLE");
|
okay = this->Makefile->IsOn("PACKAGE_VERSION_COMPATIBLE");
|
||||||
}
|
}
|
||||||
if(found || this->Version.empty())
|
|
||||||
|
// The package is suitable if the version is okay and not
|
||||||
|
// explicitly unsuitable.
|
||||||
|
suitable = !unsuitable && (okay || this->Version.empty());
|
||||||
|
if(suitable)
|
||||||
{
|
{
|
||||||
// Get the version found.
|
// Get the version found.
|
||||||
this->VersionFound =
|
this->VersionFound =
|
||||||
|
@ -1332,8 +1339,8 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file)
|
||||||
// Restore the original scope.
|
// Restore the original scope.
|
||||||
this->Makefile->PopScope();
|
this->Makefile->PopScope();
|
||||||
|
|
||||||
// Succeed if the version was found or no version was requested.
|
// Succeed if the version is suitable.
|
||||||
return found || this->Version.empty();
|
return suitable;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# This version should never, ever be used.
|
||||||
|
SET(PACKAGE_VERSION_UNSUITABLE 1)
|
||||||
|
SET(PACKAGE_VERSION 3.1)
|
||||||
|
IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3)
|
||||||
|
SET(PACKAGE_VERSION_COMPATIBLE 1)
|
||||||
|
IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1)
|
||||||
|
SET(PACKAGE_VERSION_EXACT 1)
|
||||||
|
ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1)
|
||||||
|
ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Test config file that is unsuitable.
|
||||||
|
MESSAGE(FATAL_ERROR "Unsuitable version of zot was found")
|
Loading…
Reference in New Issue