mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +08:00
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`
This commit is contained in:
@@ -360,7 +360,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
|
|||||||
cmSystemTools::GetCTestCommand().c_str());
|
cmSystemTools::GetCTestCommand().c_str());
|
||||||
this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
|
this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
|
||||||
cmSystemTools::GetCMakeCommand().c_str());
|
cmSystemTools::GetCMakeCommand().c_str());
|
||||||
this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true);
|
this->Makefile->AddDefinitionBool("CTEST_RUN_CURRENT_SCRIPT", true);
|
||||||
this->SetRunCurrentScript(true);
|
this->SetRunCurrentScript(true);
|
||||||
this->UpdateElapsedTime();
|
this->UpdateElapsedTime();
|
||||||
|
|
||||||
|
@@ -511,7 +511,7 @@ void cmGlobalGenerator::EnableLanguage(
|
|||||||
|
|
||||||
bool fatalError = false;
|
bool fatalError = false;
|
||||||
|
|
||||||
mf->AddDefinition("RUN_CONFIGURE", true);
|
mf->AddDefinitionBool("RUN_CONFIGURE", true);
|
||||||
std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory();
|
std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory();
|
||||||
rootBin += "/CMakeFiles";
|
rootBin += "/CMakeFiles";
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
status.SetReturnInvoked();
|
status.SetReturnInvoked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mf->AddDefinition(includeGuardVar, true);
|
mf->AddDefinitionBool(includeGuardVar, true);
|
||||||
break;
|
break;
|
||||||
case DIRECTORY:
|
case DIRECTORY:
|
||||||
if (CheckIncludeGuardIsSet(mf, includeGuardVar)) {
|
if (CheckIncludeGuardIsSet(mf, includeGuardVar)) {
|
||||||
|
@@ -1803,6 +1803,11 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
|
|||||||
#endif
|
#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,
|
void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
||||||
const char* doc,
|
const char* doc,
|
||||||
cmStateEnums::CacheEntryType type,
|
cmStateEnums::CacheEntryType type,
|
||||||
@@ -1848,23 +1853,6 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
|||||||
this->StateSnapshot.RemoveDefinition(name);
|
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
|
void cmMakefile::CheckForUnusedVariables() const
|
||||||
{
|
{
|
||||||
if (!this->WarnUnused) {
|
if (!this->WarnUnused) {
|
||||||
|
@@ -264,16 +264,15 @@ public:
|
|||||||
* can be used in CMake to refer to lists, directories, etc.
|
* can be used in CMake to refer to lists, directories, etc.
|
||||||
*/
|
*/
|
||||||
void AddDefinition(const std::string& name, const char* value);
|
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.
|
//! Add a definition to this makefile and the global cmake cache.
|
||||||
void AddCacheDefinition(const std::string& name, const char* value,
|
void AddCacheDefinition(const std::string& name, const char* value,
|
||||||
const char* doc, cmStateEnums::CacheEntryType type,
|
const char* doc, cmStateEnums::CacheEntryType type,
|
||||||
bool force = false);
|
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
|
* Remove a variable definition from the build. This is not valid
|
||||||
* for cache entries, and will only affect the current makefile.
|
* for cache entries, and will only affect the current makefile.
|
||||||
|
@@ -42,7 +42,7 @@ bool cmVariableRequiresCommand::InitialPass(
|
|||||||
// if reqVar is set to true, but requirementsMet is false , then
|
// if reqVar is set to true, but requirementsMet is false , then
|
||||||
// set reqVar to false.
|
// set reqVar to false.
|
||||||
if (!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) {
|
if (!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) {
|
||||||
this->Makefile->AddDefinition(resultVariable, requirementsMet);
|
this->Makefile->AddDefinitionBool(resultVariable, requirementsMet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!requirementsMet) {
|
if (!requirementsMet) {
|
||||||
|
Reference in New Issue
Block a user