Speedup find_* commands (#11412)

Delay computation of the command documentation until it is needed.
It is wasteful to do it in the constructor on every call.

Inspired-By: Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
This commit is contained in:
Brad King
2010-11-12 10:47:28 -05:00
parent e6975fe82f
commit 5303fbf09e
14 changed files with 88 additions and 42 deletions
+17 -7
View File
@@ -51,13 +51,6 @@ void cmFindPackageNeedBackwardsCompatibility(const std::string& variable,
//----------------------------------------------------------------------------
cmFindPackageCommand::cmFindPackageCommand()
{
cmSystemTools::ReplaceString(this->GenericDocumentationRootPath,
"CMAKE_FIND_ROOT_PATH_MODE_XXX",
"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE");
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
"FIND_ARGS_XXX", "<package>");
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
"FIND_XXX", "find_package");
this->CMakePathName = "PACKAGE";
this->Quiet = false;
this->Required = false;
@@ -78,6 +71,19 @@ cmFindPackageCommand::cmFindPackageCommand()
this->VersionFoundPatch = 0;
this->VersionFoundTweak = 0;
this->VersionFoundCount = 0;
}
//----------------------------------------------------------------------------
void cmFindPackageCommand::GenerateDocumentation()
{
this->cmFindCommon::GenerateDocumentation();
cmSystemTools::ReplaceString(this->GenericDocumentationRootPath,
"CMAKE_FIND_ROOT_PATH_MODE_XXX",
"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE");
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
"FIND_ARGS_XXX", "<package>");
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
"FIND_XXX", "find_package");
this->CommandDocumentation =
" find_package(<package> [version] [EXACT] [QUIET]\n"
" [[REQUIRED|COMPONENTS] [components...]]\n"
@@ -318,6 +324,10 @@ cmFindPackageCommand::cmFindPackageCommand()
//----------------------------------------------------------------------------
const char* cmFindPackageCommand::GetFullDocumentation()
{
if(this->CommandDocumentation.empty())
{
this->GenerateDocumentation();
}
return this->CommandDocumentation.c_str();
}