Replace cmake::GetScriptMode() with GetWorkingMode()
GetWorkingMode() returns a new enum WorkingMode, which is one of NORMAL_MODE, SCRIPT_MODE and FIND_PACKAGE_MODE. Alex
This commit is contained in:
parent
e4f603b698
commit
7690edffd9
|
@ -782,7 +782,7 @@ void cmGlobalGenerator::Configure()
|
||||||
// so create the map from project name to vector of local generators
|
// so create the map from project name to vector of local generators
|
||||||
this->FillProjectMap();
|
this->FillProjectMap();
|
||||||
|
|
||||||
if ( !this->CMakeInstance->GetScriptMode() )
|
if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE)
|
||||||
{
|
{
|
||||||
const char* msg = "Configuring done";
|
const char* msg = "Configuring done";
|
||||||
if(cmSystemTools::GetErrorOccuredFlag())
|
if(cmSystemTools::GetErrorOccuredFlag())
|
||||||
|
|
|
@ -384,8 +384,8 @@ 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()->GetFindPackageMode()
|
(this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE
|
||||||
|| !this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable()))
|
|| pcmd->IsScriptable()))
|
||||||
|
|
||||||
{
|
{
|
||||||
// if trace is one, print out invoke information
|
// if trace is one, print out invoke information
|
||||||
|
@ -413,7 +413,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
|
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
|
||||||
}
|
}
|
||||||
result = false;
|
result = false;
|
||||||
if ( this->GetCMakeInstance()->GetScriptMode() )
|
if ( this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE)
|
||||||
{
|
{
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
this->UsedCommands.push_back(pcmd.release());
|
this->UsedCommands.push_back(pcmd.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( this->GetCMakeInstance()->GetScriptMode()
|
else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE
|
||||||
&& !pcmd->IsScriptable() )
|
&& !pcmd->IsScriptable() )
|
||||||
{
|
{
|
||||||
std::string error = "Command ";
|
std::string error = "Command ";
|
||||||
|
|
|
@ -180,8 +180,7 @@ cmake::cmake()
|
||||||
this->GlobalGenerator = 0;
|
this->GlobalGenerator = 0;
|
||||||
this->ProgressCallback = 0;
|
this->ProgressCallback = 0;
|
||||||
this->ProgressCallbackClientData = 0;
|
this->ProgressCallbackClientData = 0;
|
||||||
this->ScriptMode = false;
|
this->CurrentWorkingMode = NORMAL_MODE;
|
||||||
this->FindPackageMode = false;
|
|
||||||
|
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
this->VariableWatch = new cmVariableWatch;
|
this->VariableWatch = new cmVariableWatch;
|
||||||
|
@ -523,7 +522,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
|
||||||
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
||||||
lg->GetMakefile()->SetStartDirectory
|
lg->GetMakefile()->SetStartDirectory
|
||||||
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
||||||
if (this->GetScriptMode())
|
if (this->GetWorkingMode() != NORMAL_MODE)
|
||||||
{
|
{
|
||||||
std::string file(cmSystemTools::CollapseFullPath(path));
|
std::string file(cmSystemTools::CollapseFullPath(path));
|
||||||
cmSystemTools::ConvertToUnixSlashes(file);
|
cmSystemTools::ConvertToUnixSlashes(file);
|
||||||
|
@ -2147,7 +2146,7 @@ int cmake::ActualConfigure()
|
||||||
this->CleanupCommandsAndMacros();
|
this->CleanupCommandsAndMacros();
|
||||||
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if ( !this->ScriptMode )
|
if ( this->GetWorkingMode() == NORMAL_MODE )
|
||||||
{
|
{
|
||||||
res = this->DoPreConfigureChecks();
|
res = this->DoPreConfigureChecks();
|
||||||
}
|
}
|
||||||
|
@ -2335,7 +2334,7 @@ int cmake::ActualConfigure()
|
||||||
this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR");
|
this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR");
|
||||||
}
|
}
|
||||||
// only save the cache if there were no fatal errors
|
// only save the cache if there were no fatal errors
|
||||||
if ( !this->ScriptMode )
|
if ( this->GetWorkingMode() == NORMAL_MODE )
|
||||||
{
|
{
|
||||||
this->CacheManager->SaveCache(this->GetHomeOutputDirectory());
|
this->CacheManager->SaveCache(this->GetHomeOutputDirectory());
|
||||||
}
|
}
|
||||||
|
@ -2401,7 +2400,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
|
||||||
// set the cmake command
|
// set the cmake command
|
||||||
this->CMakeCommand = args[0];
|
this->CMakeCommand = args[0];
|
||||||
|
|
||||||
if ( !this->ScriptMode )
|
if ( this->GetWorkingMode() == NORMAL_MODE )
|
||||||
{
|
{
|
||||||
// load the cache
|
// load the cache
|
||||||
if(this->LoadCache() < 0)
|
if(this->LoadCache() < 0)
|
||||||
|
@ -2422,7 +2421,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
|
||||||
}
|
}
|
||||||
|
|
||||||
// In script mode we terminate after running the script.
|
// In script mode we terminate after running the script.
|
||||||
if(this->ScriptMode)
|
if(this->GetWorkingMode() != NORMAL_MODE)
|
||||||
{
|
{
|
||||||
if(cmSystemTools::GetErrorOccuredFlag())
|
if(cmSystemTools::GetErrorOccuredFlag())
|
||||||
{
|
{
|
||||||
|
@ -2468,7 +2467,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
|
||||||
this->SetStartDirectory(this->GetHomeDirectory());
|
this->SetStartDirectory(this->GetHomeDirectory());
|
||||||
this->SetStartOutputDirectory(this->GetHomeOutputDirectory());
|
this->SetStartOutputDirectory(this->GetHomeOutputDirectory());
|
||||||
int ret = this->Configure();
|
int ret = this->Configure();
|
||||||
if (ret || this->ScriptMode)
|
if (ret || this->GetWorkingMode() != NORMAL_MODE)
|
||||||
{
|
{
|
||||||
#if defined(CMAKE_HAVE_VS_GENERATORS)
|
#if defined(CMAKE_HAVE_VS_GENERATORS)
|
||||||
if(!this->VSSolutionFile.empty() && this->GlobalGenerator)
|
if(!this->VSSolutionFile.empty() && this->GlobalGenerator)
|
||||||
|
|
|
@ -64,6 +64,25 @@ class cmake
|
||||||
WARNING,
|
WARNING,
|
||||||
LOG
|
LOG
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Describes the working modes of cmake.
|
||||||
|
* NORMAL_MODE: cmake runs to create project files
|
||||||
|
* SCRIPT_MODE: in script mode there is no generator and no cache. Also,
|
||||||
|
* language are not enabled, so add_executable and things do
|
||||||
|
* not do anything. Started by using -P
|
||||||
|
* FIND_PACKAGE_MODE: cmake runs in pkg-config like mode, i.e. it just
|
||||||
|
* searches for a package and prints the results to stdout.
|
||||||
|
* This is similar to SCRIPT_MODE, but commands like
|
||||||
|
* add_library() work too, since they may be used e.g. in
|
||||||
|
* exported target files. Started via --find-package
|
||||||
|
*/
|
||||||
|
enum WorkingMode
|
||||||
|
{
|
||||||
|
NORMAL_MODE,
|
||||||
|
SCRIPT_MODE,
|
||||||
|
FIND_PACKAGE_MODE
|
||||||
|
};
|
||||||
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
|
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
|
||||||
|
|
||||||
///! construct an instance of cmake
|
///! construct an instance of cmake
|
||||||
|
@ -274,16 +293,8 @@ class cmake
|
||||||
///! Do all the checks before running configure
|
///! Do all the checks before running configure
|
||||||
int DoPreConfigureChecks();
|
int DoPreConfigureChecks();
|
||||||
|
|
||||||
/**
|
void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; }
|
||||||
* Set and get the script mode option. In script mode there is no
|
WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
|
||||||
* generator and no cache. Also, language are not enabled, so
|
|
||||||
* add_executable and things do not do anything.
|
|
||||||
*/
|
|
||||||
void SetScriptMode(bool mode) { this->ScriptMode = mode; }
|
|
||||||
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;}
|
||||||
|
@ -464,8 +475,7 @@ private:
|
||||||
void* ProgressCallbackClientData;
|
void* ProgressCallbackClientData;
|
||||||
bool Verbose;
|
bool Verbose;
|
||||||
bool InTryCompile;
|
bool InTryCompile;
|
||||||
bool ScriptMode;
|
WorkingMode CurrentWorkingMode;
|
||||||
bool FindPackageMode;
|
|
||||||
bool DebugOutput;
|
bool DebugOutput;
|
||||||
bool Trace;
|
bool Trace;
|
||||||
bool WarnUninitialized;
|
bool WarnUninitialized;
|
||||||
|
|
|
@ -436,8 +436,7 @@ int do_cmake(int ac, char** av)
|
||||||
bool list_all_cached = false;
|
bool list_all_cached = false;
|
||||||
bool list_help = false;
|
bool list_help = false;
|
||||||
bool view_only = false;
|
bool view_only = false;
|
||||||
bool script_mode = false;
|
cmake::WorkingMode workingMode = cmake::NORMAL_MODE;
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -485,7 +484,7 @@ int do_cmake(int ac, char** av)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
script_mode = true;
|
workingMode = cmake::SCRIPT_MODE;
|
||||||
args.push_back(av[i]);
|
args.push_back(av[i]);
|
||||||
i++;
|
i++;
|
||||||
args.push_back(av[i]);
|
args.push_back(av[i]);
|
||||||
|
@ -494,7 +493,7 @@ int do_cmake(int ac, char** av)
|
||||||
else if (!command && strncmp(av[i], "--find-package",
|
else if (!command && strncmp(av[i], "--find-package",
|
||||||
strlen("--find-package")) == 0)
|
strlen("--find-package")) == 0)
|
||||||
{
|
{
|
||||||
find_package_mode = true;
|
workingMode = cmake::FIND_PACKAGE_MODE;
|
||||||
args.push_back(av[i]);
|
args.push_back(av[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -521,8 +520,7 @@ 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 || find_package_mode);
|
cm.SetWorkingMode(workingMode);
|
||||||
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 )
|
||||||
|
|
Loading…
Reference in New Issue