diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-19 09:08:38 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-24 09:11:25 (GMT) |
commit | f2ba968ef2a1c46e117dcd8eec34a55775f3d5f4 (patch) | |
tree | 8fe55d2760291f1ab684afbb052fcc8aee266872 | |
parent | 9b5cc4253135c7811936b05525e013e04a390d02 (diff) | |
download | CMake-f2ba968ef2a1c46e117dcd8eec34a55775f3d5f4.zip CMake-f2ba968ef2a1c46e117dcd8eec34a55775f3d5f4.tar.gz CMake-f2ba968ef2a1c46e117dcd8eec34a55775f3d5f4.tar.bz2 |
cmMakefile: Simplify and rename AddDefinitionBool
This simplifies the `cmMakefile::AddDefinition` method with bool value
overload to call the string based `cmMakefile::AddDefinition` method
with either an "ON" or "OFF" string.
Also the method is renamed to `cmMakefile::AddDefinitionBool`
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmIncludeGuardCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 22 | ||||
-rw-r--r-- | Source/cmMakefile.h | 9 | ||||
-rw-r--r-- | Source/cmVariableRequiresCommand.cxx | 2 |
6 files changed, 13 insertions, 26 deletions
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 85040dd..fc319b3 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -360,7 +360,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetCTestCommand().c_str()); this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", cmSystemTools::GetCMakeCommand().c_str()); - this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); + this->Makefile->AddDefinitionBool("CTEST_RUN_CURRENT_SCRIPT", true); this->SetRunCurrentScript(true); this->UpdateElapsedTime(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ec4107b..baa8559 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -511,7 +511,7 @@ void cmGlobalGenerator::EnableLanguage( bool fatalError = false; - mf->AddDefinition("RUN_CONFIGURE", true); + mf->AddDefinitionBool("RUN_CONFIGURE", true); std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory(); rootBin += "/CMakeFiles"; diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx index 505b07c..3b126b0 100644 --- a/Source/cmIncludeGuardCommand.cxx +++ b/Source/cmIncludeGuardCommand.cxx @@ -85,7 +85,7 @@ bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args, status.SetReturnInvoked(); return true; } - mf->AddDefinition(includeGuardVar, true); + mf->AddDefinitionBool(includeGuardVar, true); break; case DIRECTORY: if (CheckIncludeGuardIsSet(mf, includeGuardVar)) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3177adc..1867809 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1803,6 +1803,11 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) #endif } +void cmMakefile::AddDefinitionBool(const std::string& name, bool value) +{ + this->AddDefinition(name, value ? "ON" : "OFF"); +} + void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmStateEnums::CacheEntryType type, @@ -1848,23 +1853,6 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->StateSnapshot.RemoveDefinition(name); } -void cmMakefile::AddDefinition(const std::string& name, bool value) -{ - if (this->VariableInitialized(name)) { - this->LogUnused("changing definition", name); - } - - this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF"); - -#ifdef CMAKE_BUILD_WITH_CMAKE - cmVariableWatch* vv = this->GetVariableWatch(); - if (vv) { - vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS, - value ? "ON" : "OFF", this); - } -#endif -} - void cmMakefile::CheckForUnusedVariables() const { if (!this->WarnUnused) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1eca18c..e685644 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -264,17 +264,16 @@ public: * can be used in CMake to refer to lists, directories, etc. */ void AddDefinition(const std::string& name, const char* value); + /** + * Add bool variable definition to the build. + */ + void AddDefinitionBool(const std::string& name, bool value); //! Add a definition to this makefile and the global cmake cache. void AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmStateEnums::CacheEntryType type, bool force = false); /** - * Add bool variable definition to the build. - */ - void AddDefinition(const std::string& name, bool); - - /** * Remove a variable definition from the build. This is not valid * for cache entries, and will only affect the current makefile. */ diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index c02157a..9878ff1 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -42,7 +42,7 @@ bool cmVariableRequiresCommand::InitialPass( // if reqVar is set to true, but requirementsMet is false , then // set reqVar to false. if (!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) { - this->Makefile->AddDefinition(resultVariable, requirementsMet); + this->Makefile->AddDefinitionBool(resultVariable, requirementsMet); } if (!requirementsMet) { |