Add find-package mode, which does nothing yet

-add command line argument --find-package and handle it,
 i.e. call an empty function cmake::FindPackage()
-add basic help

Alex
This commit is contained in:
Alex Neundorf 2011-07-02 17:50:05 +02:00
parent b976e70063
commit a91d662f46
4 changed files with 45 additions and 2 deletions

View File

@ -384,7 +384,9 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
// Decide whether to invoke the command. // Decide whether to invoke the command.
if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() &&
(!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) (this->GetCMakeInstance()->GetFindPackageMode()
|| !this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable()))
{ {
// if trace is one, print out invoke information // if trace is one, print out invoke information
if(this->GetCMakeInstance()->GetTrace()) if(this->GetCMakeInstance()->GetTrace())

View File

@ -181,6 +181,7 @@ cmake::cmake()
this->ProgressCallback = 0; this->ProgressCallback = 0;
this->ProgressCallbackClientData = 0; this->ProgressCallbackClientData = 0;
this->ScriptMode = false; this->ScriptMode = false;
this->FindPackageMode = false;
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch = new cmVariableWatch; this->VariableWatch = new cmVariableWatch;
@ -353,6 +354,7 @@ void cmake::RemoveUnscriptableCommands()
// Parse the args // Parse the args
bool cmake::SetCacheArgs(const std::vector<std::string>& args) bool cmake::SetCacheArgs(const std::vector<std::string>& args)
{ {
bool findPackageMode = false;
for(unsigned int i=1; i < args.size(); ++i) for(unsigned int i=1; i < args.size(); ++i)
{ {
std::string arg = args[i]; std::string arg = args[i];
@ -480,7 +482,17 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
} }
this->ReadListFile(args, path.c_str()); this->ReadListFile(args, path.c_str());
} }
else if (arg.find("--find-package",0) == 0)
{
findPackageMode = true;
}
} }
if (findPackageMode)
{
return this->FindPackage(args);
}
return true; return true;
} }
@ -532,6 +544,14 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
} }
} }
bool cmake::FindPackage(const std::vector<std::string>& args)
{
// create empty function for now, will be filled later
return true;
}
// Parse the args // Parse the args
void cmake::SetArgs(const std::vector<std::string>& args, void cmake::SetArgs(const std::vector<std::string>& args,
bool directoriesSetBefore) bool directoriesSetBefore)
@ -604,6 +624,11 @@ void cmake::SetArgs(const std::vector<std::string>& args,
// skip for now // skip for now
i++; i++;
} }
else if(arg.find("--find-package",0) == 0)
{
// skip for now
i++;
}
else if(arg.find("-Wno-dev",0) == 0) else if(arg.find("-Wno-dev",0) == 0)
{ {
// skip for now // skip for now

View File

@ -282,6 +282,9 @@ class cmake
void SetScriptMode(bool mode) { this->ScriptMode = mode; } void SetScriptMode(bool mode) { this->ScriptMode = mode; }
bool GetScriptMode() { return this->ScriptMode; } bool GetScriptMode() { return this->ScriptMode; }
void SetFindPackageMode(bool mode) {this->FindPackageMode = mode; }
bool GetFindPackageMode() {return this->FindPackageMode;}
///! Debug the try compile stuff by not delelting the files ///! Debug the try compile stuff by not delelting the files
bool GetDebugTryCompile(){return this->DebugTryCompile;} bool GetDebugTryCompile(){return this->DebugTryCompile;}
void DebugTryCompileOn(){this->DebugTryCompile = true;} void DebugTryCompileOn(){this->DebugTryCompile = true;}
@ -407,6 +410,7 @@ protected:
///! read in a cmake list file to initialize the cache ///! read in a cmake list file to initialize the cache
void ReadListFile(const std::vector<std::string>& args, const char *path); void ReadListFile(const std::vector<std::string>& args, const char *path);
bool FindPackage(const std::vector<std::string>& args);
///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
/// If it is set, truncate it to 50kb /// If it is set, truncate it to 50kb
@ -461,6 +465,7 @@ private:
bool Verbose; bool Verbose;
bool InTryCompile; bool InTryCompile;
bool ScriptMode; bool ScriptMode;
bool FindPackageMode;
bool DebugOutput; bool DebugOutput;
bool Trace; bool Trace;
bool WarnUninitialized; bool WarnUninitialized;

View File

@ -102,6 +102,9 @@ static const char * cmDocumentationOptions[][3] =
"No configure or generate step is performed and the cache is not" "No configure or generate step is performed and the cache is not"
" modified. If variables are defined using -D, this must be done " " modified. If variables are defined using -D, this must be done "
"before the -P argument."}, "before the -P argument."},
{"--find-package", "Run in pkg-config like mode.",
"Search a package using find_package() and print the resulting flags "
"to stdout. "},
{"--graphviz=[file]", "Generate graphviz of dependencies.", {"--graphviz=[file]", "Generate graphviz of dependencies.",
"Generate a graphviz input file that will contain all the library and " "Generate a graphviz input file that will contain all the library and "
"executable dependencies in the project."}, "executable dependencies in the project."},
@ -434,6 +437,7 @@ int do_cmake(int ac, char** av)
bool list_help = false; bool list_help = false;
bool view_only = false; bool view_only = false;
bool script_mode = false; bool script_mode = false;
bool find_package_mode = false;
std::vector<std::string> args; std::vector<std::string> args;
for(int i =0; i < ac; ++i) for(int i =0; i < ac; ++i)
{ {
@ -487,6 +491,12 @@ int do_cmake(int ac, char** av)
args.push_back(av[i]); args.push_back(av[i]);
} }
} }
else if (!command && strncmp(av[i], "--find-package",
strlen("--find-package")) == 0)
{
find_package_mode = true;
args.push_back(av[i]);
}
else else
{ {
args.push_back(av[i]); args.push_back(av[i]);
@ -511,7 +521,8 @@ int do_cmake(int ac, char** av)
cmake cm; cmake cm;
cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm);
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
cm.SetScriptMode(script_mode); cm.SetScriptMode(script_mode || find_package_mode);
cm.SetFindPackageMode(find_package_mode);
int res = cm.Run(args, view_only); int res = cm.Run(args, view_only);
if ( list_cached || list_all_cached ) if ( list_cached || list_all_cached )