cmake: initialize with Role that controls which commands to register
This commit is contained in:
parent
8986dec05d
commit
c36d63cd48
@ -620,7 +620,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
||||
<< installComponent << std::endl);
|
||||
}
|
||||
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -189,7 +189,7 @@ int main(int argc, char const* const* argv)
|
||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||
"Read CPack config file: " << cpackConfigFile << std::endl);
|
||||
|
||||
cmake cminst;
|
||||
cmake cminst(cmake::RoleScript);
|
||||
cminst.SetHomeDirectory("");
|
||||
cminst.SetHomeOutputDirectory("");
|
||||
cminst.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -167,7 +167,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
||||
return 1;
|
||||
}
|
||||
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleProject);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
std::string cmakeOutString;
|
||||
|
@ -623,7 +623,7 @@ int cmCTestLaunch::Main(int argc, const char* const argv[])
|
||||
|
||||
void cmCTestLaunch::LoadConfig()
|
||||
{
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -275,7 +275,7 @@ void cmCTestScriptHandler::CreateCMake()
|
||||
delete this->GlobalGenerator;
|
||||
delete this->Makefile;
|
||||
}
|
||||
this->CMake = new cmake;
|
||||
this->CMake = new cmake(cmake::RoleScript);
|
||||
this->CMake->SetHomeDirectory("");
|
||||
this->CMake->SetHomeOutputDirectory("");
|
||||
this->CMake->GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -1650,7 +1650,7 @@ void cmCTestTestHandler::GetListOfTests()
|
||||
}
|
||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Constructing a list of tests" << std::endl, this->Quiet);
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -81,7 +81,7 @@ int main(int argc, char const* const* argv)
|
||||
cmDocumentation doc;
|
||||
doc.addCMakeStandardDocSections();
|
||||
if (doc.CheckOptions(argc, argv)) {
|
||||
cmake hcm;
|
||||
cmake hcm(cmake::RoleInternal);
|
||||
hcm.SetHomeDirectory("");
|
||||
hcm.SetHomeOutputDirectory("");
|
||||
hcm.AddCMakePaths();
|
||||
|
@ -40,7 +40,7 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
|
||||
"Welcome to ccmake, curses based user interface for CMake.");
|
||||
this->HelpMessage.push_back("");
|
||||
this->HelpMessage.push_back(s_ConstHelpMessage);
|
||||
this->CMakeInstance = new cmake;
|
||||
this->CMakeInstance = new cmake(cmake::RoleProject);
|
||||
this->CMakeInstance->SetCMakeEditCommand(
|
||||
cmSystemTools::GetCMakeCursesCommand());
|
||||
|
||||
|
@ -59,7 +59,7 @@ int main(int argc, char** argv)
|
||||
doc.addCMakeStandardDocSections();
|
||||
if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) {
|
||||
// Construct and print requested documentation.
|
||||
cmake hcm;
|
||||
cmake hcm(cmake::RoleInternal);
|
||||
hcm.SetHomeDirectory("");
|
||||
hcm.SetHomeOutputDirectory("");
|
||||
hcm.AddCMakePaths();
|
||||
|
@ -27,7 +27,7 @@ QCMake::QCMake(QObject* p)
|
||||
cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this);
|
||||
cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this);
|
||||
|
||||
this->CMakeInstance = new cmake;
|
||||
this->CMakeInstance = new cmake(cmake::RoleProject);
|
||||
this->CMakeInstance->SetCMakeEditCommand(
|
||||
cmSystemTools::GetCMakeGUICommand());
|
||||
this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this);
|
||||
|
@ -416,7 +416,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
|
||||
}
|
||||
}
|
||||
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -1903,7 +1903,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
|
||||
}
|
||||
}
|
||||
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleInternal);
|
||||
cm.SetHomeDirectory(dir_top_src);
|
||||
cm.SetHomeOutputDirectory(dir_top_bld);
|
||||
CM_AUTO_PTR<cmGlobalNinjaGenerator> ggd(
|
||||
|
@ -61,7 +61,7 @@ cmGraphVizWriter::cmGraphVizWriter(
|
||||
void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
|
||||
const char* fallbackSettingsFileName)
|
||||
{
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -3187,7 +3187,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
|
||||
// make sure the same generator is used
|
||||
// use this program as the cmake to be run, it should not
|
||||
// be run that way but the cmake object requires a vailid path
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleProject);
|
||||
cm.SetIsInTryCompile(true);
|
||||
cmGlobalGenerator* gg =
|
||||
cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName());
|
||||
|
@ -286,7 +286,7 @@ cmQtAutoGenerators::cmQtAutoGenerators()
|
||||
bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
|
||||
const std::string& config)
|
||||
{
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript);
|
||||
cm.SetHomeOutputDirectory(targetDirectory);
|
||||
cm.SetHomeDirectory(targetDirectory);
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
|
@ -215,7 +215,7 @@ bool cmServerProtocol::Activate(cmServer* server,
|
||||
{
|
||||
assert(server);
|
||||
this->m_Server = server;
|
||||
this->m_CMakeInstance = std::make_unique<cmake>();
|
||||
this->m_CMakeInstance = std::make_unique<cmake>(cmake::RoleProject);
|
||||
const bool result = this->DoActivate(request, errorMessage);
|
||||
if (!result) {
|
||||
this->m_CMakeInstance = CM_NULLPTR;
|
||||
|
@ -136,7 +136,7 @@ void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
|
||||
cm->MarkCliAsUsed(variable);
|
||||
}
|
||||
|
||||
cmake::cmake()
|
||||
cmake::cmake(Role role)
|
||||
{
|
||||
this->Trace = false;
|
||||
this->TraceExpand = false;
|
||||
@ -174,8 +174,12 @@ cmake::cmake()
|
||||
|
||||
this->AddDefaultGenerators();
|
||||
this->AddDefaultExtraGenerators();
|
||||
this->AddScriptingCommands();
|
||||
this->AddProjectCommands();
|
||||
if (role == RoleScript || role == RoleProject) {
|
||||
this->AddScriptingCommands();
|
||||
}
|
||||
if (role == RoleProject) {
|
||||
this->AddProjectCommands();
|
||||
}
|
||||
|
||||
// Make sure we can capture the build tool output.
|
||||
cmSystemTools::EnableVSConsoleOutput();
|
||||
@ -1888,7 +1892,7 @@ int cmake::CheckBuildSystem()
|
||||
|
||||
// Read the rerun check file and use it to decide whether to do the
|
||||
// global generate.
|
||||
cmake cm;
|
||||
cmake cm(RoleScript); // Actually, all we need is the `set` command.
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
||||
@ -2419,6 +2423,9 @@ int cmake::Build(const std::string& dir, const std::string& target,
|
||||
std::string homeOutputOrig = this->GetHomeOutputDirectory();
|
||||
this->SetDirectoriesFromFile(cachePath.c_str());
|
||||
|
||||
this->AddScriptingCommands();
|
||||
this->AddProjectCommands();
|
||||
|
||||
int ret = this->Configure();
|
||||
if (ret) {
|
||||
cmSystemTools::Message("CMake Configure step failed. "
|
||||
|
@ -58,6 +58,13 @@ class cmake
|
||||
CM_DISABLE_COPY(cmake)
|
||||
|
||||
public:
|
||||
enum Role
|
||||
{
|
||||
RoleInternal, // no commands
|
||||
RoleScript, // script commands
|
||||
RoleProject // all commands
|
||||
};
|
||||
|
||||
enum MessageType
|
||||
{
|
||||
AUTHOR_WARNING,
|
||||
@ -112,7 +119,7 @@ public:
|
||||
typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;
|
||||
|
||||
/// Default constructor
|
||||
cmake();
|
||||
cmake(Role role);
|
||||
/// Destructor
|
||||
~cmake();
|
||||
|
||||
|
@ -201,7 +201,7 @@ int do_cmake(int ac, char const* const* av)
|
||||
doc.addCMakeStandardDocSections();
|
||||
if (doc.CheckOptions(ac, av)) {
|
||||
// Construct and print requested documentation.
|
||||
cmake hcm;
|
||||
cmake hcm(cmake::RoleInternal);
|
||||
hcm.SetHomeDirectory("");
|
||||
hcm.SetHomeOutputDirectory("");
|
||||
hcm.AddCMakePaths();
|
||||
@ -283,13 +283,13 @@ int do_cmake(int ac, char const* const* av)
|
||||
}
|
||||
}
|
||||
if (sysinfo) {
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleProject);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
int ret = cm.GetSystemInformation(args);
|
||||
return ret;
|
||||
}
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleProject);
|
||||
cm.SetHomeDirectory("");
|
||||
cm.SetHomeOutputDirectory("");
|
||||
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
|
||||
@ -407,7 +407,7 @@ static int do_build(int ac, char const* const* av)
|
||||
return 1;
|
||||
}
|
||||
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleInternal);
|
||||
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
|
||||
cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
|
||||
return cm.Build(dir, target, config, nativeOptions, clean);
|
||||
|
@ -583,7 +583,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||
std::cerr << "-E capabilities accepts no additional arguments\n";
|
||||
return 1;
|
||||
}
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleInternal);
|
||||
#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
|
||||
std::cout << cm.ReportCapabilities(true);
|
||||
#else
|
||||
@ -760,7 +760,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||
const bool verbose = isCMakeVerbose();
|
||||
|
||||
// Create a cmake object instance to process dependencies.
|
||||
cmake cm;
|
||||
cmake cm(cmake::RoleScript); // All we need is the `set` command.
|
||||
std::string gen;
|
||||
std::string homeDir;
|
||||
std::string startDir;
|
||||
|
Loading…
Reference in New Issue
Block a user