Merge topic 'find-doc-init'

5303fbf Speedup find_* commands (#11412)
This commit is contained in:
David Cole 2010-11-16 14:46:38 -05:00 committed by CMake Topic Stage
commit cb727a20df
14 changed files with 88 additions and 42 deletions

View File

@ -13,10 +13,16 @@
cmFindBase::cmFindBase() cmFindBase::cmFindBase()
{ {
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
"FIND_ARGS_XXX", "<VAR> NAMES name");
this->AlreadyInCache = false; this->AlreadyInCache = false;
this->AlreadyInCacheWithoutMetaInfo = false; this->AlreadyInCacheWithoutMetaInfo = false;
}
//----------------------------------------------------------------------------
void cmFindBase::GenerateDocumentation()
{
this->cmFindCommon::GenerateDocumentation();
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
"FIND_ARGS_XXX", "<VAR> NAMES name");
this->GenericDocumentation = this->GenericDocumentation =
" FIND_XXX(<VAR> name1 [path1 path2 ...])\n" " FIND_XXX(<VAR> name1 [path1 path2 ...])\n"
"This is the short-hand signature for the command that " "This is the short-hand signature for the command that "
@ -98,6 +104,17 @@ cmFindBase::cmFindBase()
this->GenericDocumentation += this->GenericDocumentationPathsOrder; this->GenericDocumentation += this->GenericDocumentationPathsOrder;
} }
//----------------------------------------------------------------------------
const char* cmFindBase::GetFullDocumentation()
{
if(this->GenericDocumentation.empty())
{
this->GenerateDocumentation();
}
return this->GenericDocumentation.c_str();
}
//----------------------------------------------------------------------------
bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
{ {
if(argsIn.size() < 2 ) if(argsIn.size() < 2 )

View File

@ -31,10 +31,10 @@ public:
virtual bool ParseArguments(std::vector<std::string> const& args); virtual bool ParseArguments(std::vector<std::string> const& args);
cmTypeMacro(cmFindBase, cmFindCommon); cmTypeMacro(cmFindBase, cmFindCommon);
virtual const char* GetFullDocumentation() virtual const char* GetFullDocumentation();
{return this->GenericDocumentation.c_str();}
protected: protected:
virtual void GenerateDocumentation();
void PrintFindStuff(); void PrintFindStuff();
void ExpandPaths(); void ExpandPaths();
void AddPathSuffixes(); void AddPathSuffixes();

View File

@ -34,7 +34,11 @@ cmFindCommon::cmFindCommon()
this->SearchFrameworkLast = false; this->SearchFrameworkLast = false;
this->SearchAppBundleOnly = false; this->SearchAppBundleOnly = false;
this->SearchAppBundleLast = false; this->SearchAppBundleLast = false;
}
//----------------------------------------------------------------------------
void cmFindCommon::GenerateDocumentation()
{
// Documentation components. // Documentation components.
this->GenericDocumentationMacPolicy = this->GenericDocumentationMacPolicy =
"On Darwin or systems supporting OS X Frameworks, the cmake variable" "On Darwin or systems supporting OS X Frameworks, the cmake variable"

View File

@ -56,6 +56,8 @@ protected:
/** Compute the current default bundle/framework search policy. */ /** Compute the current default bundle/framework search policy. */
void SelectDefaultMacMode(); void SelectDefaultMacMode();
virtual void GenerateDocumentation();
cmStdString CMakePathName; cmStdString CMakePathName;
RootPathMode FindRootPathMode; RootPathMode FindRootPathMode;

View File

@ -15,6 +15,11 @@
cmFindFileCommand::cmFindFileCommand() cmFindFileCommand::cmFindFileCommand()
{ {
this->IncludeFileInPath = true; this->IncludeFileInPath = true;
}
void cmFindFileCommand::GenerateDocumentation()
{
this->cmFindPathCommand::GenerateDocumentation();
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"find_path", "find_file"); "find_path", "find_file");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,

View File

@ -44,6 +44,8 @@ public:
} }
cmTypeMacro(cmFindFileCommand, cmFindPathCommand); cmTypeMacro(cmFindFileCommand, cmFindPathCommand);
protected:
virtual void GenerateDocumentation();
}; };

View File

@ -16,6 +16,13 @@
cmFindLibraryCommand::cmFindLibraryCommand() cmFindLibraryCommand::cmFindLibraryCommand()
{ {
this->EnvironmentPath = "LIB";
}
//----------------------------------------------------------------------------
void cmFindLibraryCommand::GenerateDocumentation()
{
this->cmFindBase::GenerateDocumentation();
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"FIND_XXX", "find_library"); "FIND_XXX", "find_library");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
@ -40,8 +47,6 @@ cmFindLibraryCommand::cmFindLibraryCommand()
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_XXX",
"CMAKE_FIND_ROOT_PATH_MODE_LIBRARY"); "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY");
this->EnvironmentPath = "LIB";
this->GenericDocumentation += this->GenericDocumentation +=
"\n" "\n"
"If the library found is a framework, then VAR will be set to " "If the library found is a framework, then VAR will be set to "

View File

@ -64,6 +64,7 @@ protected:
void AddArchitecturePaths(const char* suffix); void AddArchitecturePaths(const char* suffix);
void AddLib64Paths(); void AddLib64Paths();
std::string FindLibrary(); std::string FindLibrary();
virtual void GenerateDocumentation();
private: private:
std::string FindNormalLibrary(); std::string FindNormalLibrary();
std::string FindFrameworkLibrary(); std::string FindFrameworkLibrary();

View File

@ -51,13 +51,6 @@ void cmFindPackageNeedBackwardsCompatibility(const std::string& variable,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmFindPackageCommand::cmFindPackageCommand() 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->CMakePathName = "PACKAGE";
this->Quiet = false; this->Quiet = false;
this->Required = false; this->Required = false;
@ -78,6 +71,19 @@ cmFindPackageCommand::cmFindPackageCommand()
this->VersionFoundPatch = 0; this->VersionFoundPatch = 0;
this->VersionFoundTweak = 0; this->VersionFoundTweak = 0;
this->VersionFoundCount = 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 = this->CommandDocumentation =
" find_package(<package> [version] [EXACT] [QUIET]\n" " find_package(<package> [version] [EXACT] [QUIET]\n"
" [[REQUIRED|COMPONENTS] [components...]]\n" " [[REQUIRED|COMPONENTS] [components...]]\n"
@ -318,6 +324,10 @@ cmFindPackageCommand::cmFindPackageCommand()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmFindPackageCommand::GetFullDocumentation() const char* cmFindPackageCommand::GetFullDocumentation()
{ {
if(this->CommandDocumentation.empty())
{
this->GenerateDocumentation();
}
return this->CommandDocumentation.c_str(); return this->CommandDocumentation.c_str();
} }

View File

@ -65,6 +65,8 @@ public:
virtual const char* GetFullDocumentation(); virtual const char* GetFullDocumentation();
cmTypeMacro(cmFindPackageCommand, cmFindCommon); cmTypeMacro(cmFindPackageCommand, cmFindCommon);
protected:
virtual void GenerateDocumentation();
private: private:
void AppendSuccessInformation(); void AppendSuccessInformation();
void AppendToProperty(const char* propertyName); void AppendToProperty(const char* propertyName);

View File

@ -18,6 +18,11 @@ cmFindPathCommand::cmFindPathCommand()
{ {
this->EnvironmentPath = "INCLUDE"; this->EnvironmentPath = "INCLUDE";
this->IncludeFileInPath = false; this->IncludeFileInPath = false;
}
void cmFindPathCommand::GenerateDocumentation()
{
this->cmFindBase::GenerateDocumentation();
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"FIND_XXX", "find_path"); "FIND_XXX", "find_path");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
@ -43,13 +48,7 @@ cmFindPathCommand::cmFindPathCommand()
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_XXX",
"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"); "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE");
if(!this->IncludeFileInPath)
this->ExtraDocAdded = false;
}
const char* cmFindPathCommand::GetFullDocumentation()
{
if(!this->ExtraDocAdded && !this->IncludeFileInPath)
{ {
this->GenericDocumentation += this->GenericDocumentation +=
"\n" "\n"
@ -59,9 +58,7 @@ const char* cmFindPathCommand::GetFullDocumentation()
"If that is found the path will be set to the path to the framework. " "If that is found the path will be set to the path to the framework. "
"CMake will convert this to the correct -F option to include the " "CMake will convert this to the correct -F option to include the "
"file. "; "file. ";
this->ExtraDocAdded = true;
} }
return this->GenericDocumentation.c_str();
} }
// cmFindPathCommand // cmFindPathCommand

View File

@ -59,10 +59,10 @@ public:
return "Find the directory containing a file."; return "Find the directory containing a file.";
} }
virtual const char* GetFullDocumentation();
cmTypeMacro(cmFindPathCommand, cmFindBase); cmTypeMacro(cmFindPathCommand, cmFindBase);
bool IncludeFileInPath; bool IncludeFileInPath;
bool ExtraDocAdded; protected:
virtual void GenerateDocumentation();
private: private:
std::string FindHeaderInFramework(std::string const& file, std::string FindHeaderInFramework(std::string const& file,
std::string const& dir); std::string const& dir);

View File

@ -17,8 +17,9 @@
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
cmFindProgramCommand::cmFindProgramCommand() void cmFindProgramCommand::GenerateDocumentation()
{ {
this->cmFindBase::GenerateDocumentation();
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"FIND_XXX", "find_program"); "FIND_XXX", "find_program");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,

View File

@ -25,7 +25,6 @@
class cmFindProgramCommand : public cmFindBase class cmFindProgramCommand : public cmFindBase
{ {
public: public:
cmFindProgramCommand();
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
@ -63,6 +62,7 @@ public:
protected: protected:
std::string FindProgram(std::vector<std::string> names); std::string FindProgram(std::vector<std::string> names);
virtual void GenerateDocumentation();
private: private:
std::string FindAppBundle(std::vector<std::string> names); std::string FindAppBundle(std::vector<std::string> names);