diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-04-29 19:28:14 (GMT) |
---|---|---|
committer | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-05-08 20:29:44 (GMT) |
commit | c36d63cd48fbfda57cd8cf25c029a3a175e10299 (patch) | |
tree | 979c1f66e94ad7850b2db7e92c98a96cd0f34313 | |
parent | 8986dec05dade19ee0f779c6c498dc0e04a8f8ee (diff) | |
download | CMake-c36d63cd48fbfda57cd8cf25c029a3a175e10299.zip CMake-c36d63cd48fbfda57cd8cf25c029a3a175e10299.tar.gz CMake-c36d63cd48fbfda57cd8cf25c029a3a175e10299.tar.bz2 |
cmake: initialize with Role that controls which commands to register
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/CPack/cpack.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestLaunch.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 2 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 2 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetup.cxx | 2 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 2 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGraphVizWriter.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 2 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 2 | ||||
-rw-r--r-- | Source/cmake.cxx | 15 | ||||
-rw-r--r-- | Source/cmake.h | 9 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 8 | ||||
-rw-r--r-- | Source/cmcmd.cxx | 4 |
20 files changed, 41 insertions, 27 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index c5495c6..c873529 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -620,7 +620,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << installComponent << std::endl); } - cmake cm; + cmake cm(cmake::RoleScript); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a48c8cd..bf25e65 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -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(); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index ed7dd5d..cc29071 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -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; diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index a782150..5b21351 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -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(); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 60e48b6..444d0e3 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -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(); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index a5cc1fa..349e91a 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -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(); diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 1698a84..28a0e95 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -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(); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index ca824c0..0fa7aa5 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -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()); diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index b955d77..7fa2ac6 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -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(); diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 28820a6..d473d9b 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -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); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 010221e..f469998 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -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(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 587e18a..d9a8cab 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -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( diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 1fcd3cb..7e953ce 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -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(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cb11060..ab0707e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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()); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index eec1fc6..7461a0a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -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(); diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 4e9e80f..defba77 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -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; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 737587d..87b3597 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -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. " diff --git a/Source/cmake.h b/Source/cmake.h index 16a2830..4ddacf7 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -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(); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 3d11241..f472b8a 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -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); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index cc954e6..dc267e7 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -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; |