Merge topic 'DisableSwitchForFindPackage'
4a50b5f Add a basic test for CMAKE_DISABLE_FIND_PACKAGE_<package> a66df08 Add documentation for the CMAKE_DISABLE_FIND_PACKAGE_<Name> switch 6e1d3ed Add a switch to disable a find_package() call completely
This commit is contained in:
commit
25a35f5686
@ -718,6 +718,20 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
|
|||||||
"CMAKE_SYSTEM_PREFIX_PATH.", false,
|
"CMAKE_SYSTEM_PREFIX_PATH.", false,
|
||||||
"Variables That Change Behavior");
|
"Variables That Change Behavior");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_DISABLE_FIND_PACKAGE_<PackageName>", cmProperty::VARIABLE,
|
||||||
|
"Variable for disabling find_package() calls.",
|
||||||
|
"Every non-REQUIRED find_package() call in a project can be disabled "
|
||||||
|
"by setting the variable CMAKE_DISABLE_FIND_PACKAGE_<PackageName> to "
|
||||||
|
"TRUE. This can be used to build a project without an optional package, "
|
||||||
|
"although that package is installed.\n"
|
||||||
|
"This switch should be used during the initial CMake run. Otherwise if "
|
||||||
|
"the package has already been found in a previous CMake run, the "
|
||||||
|
"variables which have been stored in the cache will still be there. "
|
||||||
|
"In the case it is recommended to remove the cache variables for "
|
||||||
|
"this package from the cache using the cache editor or cmake -U", false,
|
||||||
|
"Variables That Change Behavior");
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("CMAKE_USER_MAKE_RULES_OVERRIDE", cmProperty::VARIABLE,
|
("CMAKE_USER_MAKE_RULES_OVERRIDE", cmProperty::VARIABLE,
|
||||||
"Specify a CMake file that overrides platform information.",
|
"Specify a CMake file that overrides platform information.",
|
||||||
|
@ -335,6 +335,10 @@ void cmFindPackageCommand::GenerateDocumentation()
|
|||||||
this->CommandDocumentation += this->GenericDocumentationPathsOrder;
|
this->CommandDocumentation += this->GenericDocumentationPathsOrder;
|
||||||
this->CommandDocumentation +=
|
this->CommandDocumentation +=
|
||||||
"\n"
|
"\n"
|
||||||
|
"Every non-REQUIRED find_package() call can be disabled by setting the "
|
||||||
|
"variable CMAKE_DISABLE_FIND_PACKAGE_<package> to TRUE. See the "
|
||||||
|
"documentation for the CMAKE_DISABLE_FIND_PACKAGE_<package> variable for "
|
||||||
|
"more information.\n"
|
||||||
"See the cmake_policy() command documentation for discussion of the "
|
"See the cmake_policy() command documentation for discussion of the "
|
||||||
"NO_POLICY_SCOPE option."
|
"NO_POLICY_SCOPE option."
|
||||||
;
|
;
|
||||||
@ -607,6 +611,24 @@ bool cmFindPackageCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
|
||||||
|
disableFindPackageVar += this->Name;
|
||||||
|
if(this->Makefile->IsOn(disableFindPackageVar.c_str()))
|
||||||
|
{
|
||||||
|
if (this->Required)
|
||||||
|
{
|
||||||
|
cmOStringStream e;
|
||||||
|
e << "for module " << this->Name << " called with REQUIRED, but "
|
||||||
|
<< disableFindPackageVar
|
||||||
|
<< " is enabled. A REQUIRED package cannot be disabled.";
|
||||||
|
this->SetError(e.str().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this->SetModuleVariables(components);
|
this->SetModuleVariables(components);
|
||||||
|
|
||||||
// See if there is a Find<package>.cmake module.
|
// See if there is a Find<package>.cmake module.
|
||||||
|
@ -75,7 +75,7 @@ ENDIF()
|
|||||||
|
|
||||||
# For purposes of the test wipe out previous find results.
|
# For purposes of the test wipe out previous find results.
|
||||||
SET(PACKAGES
|
SET(PACKAGES
|
||||||
foo Foo Bar TFramework Tframework TApp Tapp Special
|
foo Foo Bar Blub TFramework Tframework TApp Tapp Special
|
||||||
VersionedA VersionedB VersionedC VersionedD VersionedE
|
VersionedA VersionedB VersionedC VersionedD VersionedE
|
||||||
WrongA WrongB WrongC WrongD
|
WrongA WrongB WrongC WrongD
|
||||||
wibbleA wibbleB
|
wibbleA wibbleB
|
||||||
@ -104,6 +104,8 @@ set(CMAKE_IGNORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-3.1)
|
|||||||
FIND_PACKAGE(foo NO_MODULE)
|
FIND_PACKAGE(foo NO_MODULE)
|
||||||
FIND_PACKAGE(Foo CONFIGS FooConfig.cmake)
|
FIND_PACKAGE(Foo CONFIGS FooConfig.cmake)
|
||||||
FIND_PACKAGE(Bar)
|
FIND_PACKAGE(Bar)
|
||||||
|
SET(CMAKE_DISABLE_FIND_PACKAGE_Blub TRUE)
|
||||||
|
FIND_PACKAGE(Blub NO_MODULE)
|
||||||
FIND_PACKAGE(TFramework CONFIGS TFrameworkConfig.cmake)
|
FIND_PACKAGE(TFramework CONFIGS TFrameworkConfig.cmake)
|
||||||
FIND_PACKAGE(Tframework)
|
FIND_PACKAGE(Tframework)
|
||||||
FIND_PACKAGE(TApp)
|
FIND_PACKAGE(TApp)
|
||||||
@ -169,6 +171,7 @@ ENDIF()
|
|||||||
SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake")
|
SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake")
|
||||||
SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake")
|
SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake")
|
||||||
SET(Bar_EXPECTED "lib/Bar/BarConfig.cmake")
|
SET(Bar_EXPECTED "lib/Bar/BarConfig.cmake")
|
||||||
|
SET(Blub_MISSING "")
|
||||||
SET(Special_EXPECTED "lib/suffix/test/SuffixTestConfig.cmake")
|
SET(Special_EXPECTED "lib/suffix/test/SuffixTestConfig.cmake")
|
||||||
SET(TFramework_EXPECTED
|
SET(TFramework_EXPECTED
|
||||||
"TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake")
|
"TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake")
|
||||||
|
1
Tests/FindPackageTest/lib/Blub/BlubConfig.cmake
Normal file
1
Tests/FindPackageTest/lib/Blub/BlubConfig.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Test config file.
|
Loading…
x
Reference in New Issue
Block a user