From f2ba968ef2a1c46e117dcd8eec34a55775f3d5f4 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Fri, 19 Jul 2019 11:08:38 +0200 Subject: 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` --- Source/CTest/cmCTestScriptHandler.cxx | 2 +- Source/cmGlobalGenerator.cxx | 2 +- Source/cmIncludeGuardCommand.cxx | 2 +- Source/cmMakefile.cxx | 22 +++++----------------- Source/cmMakefile.h | 9 ++++----- Source/cmVariableRequiresCommand.cxx | 2 +- 6 files changed, 13 insertions(+), 26 deletions(-) (limited to 'Source') diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 85040ddc96..fc319b3298 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 ec4107b470..baa8559297 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 505b07cad7..3b126b0c4a 100644 --- a/Source/cmIncludeGuardCommand.cxx +++ b/Source/cmIncludeGuardCommand.cxx @@ -85,7 +85,7 @@ bool cmIncludeGuardCommand::InitialPass(std::vector 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 3177adcb76..1867809d35 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 1eca18cd44..e685644667 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -264,16 +264,15 @@ 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 c02157ad1e..9878ff1366 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) { -- cgit v1.2.1