AddCacheEntry: Suppress raw pointer usage
This commit is contained in:
parent
b0d1ddb723
commit
4fc322bab4
@ -359,19 +359,19 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
|
|||||||
if (s.Type == QCMakeProperty::BOOL) {
|
if (s.Type == QCMakeProperty::BOOL) {
|
||||||
this->CMakeInstance->AddCacheEntry(
|
this->CMakeInstance->AddCacheEntry(
|
||||||
s.Key.toStdString(), s.Value.toBool() ? "ON" : "OFF",
|
s.Key.toStdString(), s.Value.toBool() ? "ON" : "OFF",
|
||||||
s.Help.toStdString().c_str(), cmStateEnums::BOOL);
|
s.Help.toStdString(), cmStateEnums::BOOL);
|
||||||
} else if (s.Type == QCMakeProperty::STRING) {
|
} else if (s.Type == QCMakeProperty::STRING) {
|
||||||
this->CMakeInstance->AddCacheEntry(
|
this->CMakeInstance->AddCacheEntry(
|
||||||
s.Key.toStdString(), s.Value.toString().toStdString(),
|
s.Key.toStdString(), s.Value.toString().toStdString(),
|
||||||
s.Help.toStdString().c_str(), cmStateEnums::STRING);
|
s.Help.toStdString(), cmStateEnums::STRING);
|
||||||
} else if (s.Type == QCMakeProperty::PATH) {
|
} else if (s.Type == QCMakeProperty::PATH) {
|
||||||
this->CMakeInstance->AddCacheEntry(
|
this->CMakeInstance->AddCacheEntry(
|
||||||
s.Key.toStdString(), s.Value.toString().toStdString(),
|
s.Key.toStdString(), s.Value.toString().toStdString(),
|
||||||
s.Help.toStdString().c_str(), cmStateEnums::PATH);
|
s.Help.toStdString(), cmStateEnums::PATH);
|
||||||
} else if (s.Type == QCMakeProperty::FILEPATH) {
|
} else if (s.Type == QCMakeProperty::FILEPATH) {
|
||||||
this->CMakeInstance->AddCacheEntry(
|
this->CMakeInstance->AddCacheEntry(
|
||||||
s.Key.toStdString(), s.Value.toString().toStdString(),
|
s.Key.toStdString(), s.Value.toString().toStdString(),
|
||||||
s.Help.toStdString().c_str(), cmStateEnums::FILEPATH);
|
s.Help.toStdString(), cmStateEnums::FILEPATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
|
#include "cmValue.h"
|
||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
|
|
||||||
#ifdef __QNX__
|
#ifdef __QNX__
|
||||||
@ -78,25 +79,37 @@ static void CCONV cmAddCacheDefinition(void* arg, const char* name,
|
|||||||
int type)
|
int type)
|
||||||
{
|
{
|
||||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||||
|
std::string valueString;
|
||||||
|
std::string docString;
|
||||||
|
cmValue v;
|
||||||
|
cmValue d;
|
||||||
|
if (value != nullptr) {
|
||||||
|
valueString = value;
|
||||||
|
v = cmValue{ valueString };
|
||||||
|
}
|
||||||
|
if (doc != nullptr) {
|
||||||
|
docString = doc;
|
||||||
|
d = cmValue{ docString };
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CM_CACHE_BOOL:
|
case CM_CACHE_BOOL:
|
||||||
mf->AddCacheDefinition(name, value, doc, cmStateEnums::BOOL);
|
mf->AddCacheDefinition(name, v, d, cmStateEnums::BOOL);
|
||||||
break;
|
break;
|
||||||
case CM_CACHE_PATH:
|
case CM_CACHE_PATH:
|
||||||
mf->AddCacheDefinition(name, value, doc, cmStateEnums::PATH);
|
mf->AddCacheDefinition(name, v, d, cmStateEnums::PATH);
|
||||||
break;
|
break;
|
||||||
case CM_CACHE_FILEPATH:
|
case CM_CACHE_FILEPATH:
|
||||||
mf->AddCacheDefinition(name, value, doc, cmStateEnums::FILEPATH);
|
mf->AddCacheDefinition(name, v, d, cmStateEnums::FILEPATH);
|
||||||
break;
|
break;
|
||||||
case CM_CACHE_STRING:
|
case CM_CACHE_STRING:
|
||||||
mf->AddCacheDefinition(name, value, doc, cmStateEnums::STRING);
|
mf->AddCacheDefinition(name, v, d, cmStateEnums::STRING);
|
||||||
break;
|
break;
|
||||||
case CM_CACHE_INTERNAL:
|
case CM_CACHE_INTERNAL:
|
||||||
mf->AddCacheDefinition(name, value, doc, cmStateEnums::INTERNAL);
|
mf->AddCacheDefinition(name, v, d, cmStateEnums::INTERNAL);
|
||||||
break;
|
break;
|
||||||
case CM_CACHE_STATIC:
|
case CM_CACHE_STATIC:
|
||||||
mf->AddCacheDefinition(name, value, doc, cmStateEnums::STATIC);
|
mf->AddCacheDefinition(name, v, d, cmStateEnums::STATIC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmCacheManager::AddCacheEntry(const std::string& key, cmValue value,
|
void cmCacheManager::AddCacheEntry(const std::string& key, cmValue value,
|
||||||
const char* helpString,
|
cmValue helpString,
|
||||||
cmStateEnums::CacheEntryType type)
|
cmStateEnums::CacheEntryType type)
|
||||||
{
|
{
|
||||||
CacheEntry& e = this->Cache[key];
|
CacheEntry& e = this->Cache[key];
|
||||||
@ -543,7 +543,7 @@ void cmCacheManager::AddCacheEntry(const std::string& key, cmValue value,
|
|||||||
}
|
}
|
||||||
e.SetProperty(
|
e.SetProperty(
|
||||||
"HELPSTRING",
|
"HELPSTRING",
|
||||||
helpString ? std::string{ helpString }
|
helpString ? *helpString
|
||||||
: std::string{
|
: std::string{
|
||||||
"(This variable does not exist and should not be used)" });
|
"(This variable does not exist and should not be used)" });
|
||||||
}
|
}
|
||||||
|
@ -173,20 +173,19 @@ public:
|
|||||||
unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; }
|
unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; }
|
||||||
|
|
||||||
//! Add an entry into the cache
|
//! Add an entry into the cache
|
||||||
void AddCacheEntry(const std::string& key, const char* value,
|
|
||||||
const char* helpString, cmStateEnums::CacheEntryType type)
|
|
||||||
{
|
|
||||||
this->AddCacheEntry(key,
|
|
||||||
value ? cmValue(std::string(value)) : cmValue(nullptr),
|
|
||||||
helpString, type);
|
|
||||||
}
|
|
||||||
void AddCacheEntry(const std::string& key, const std::string& value,
|
void AddCacheEntry(const std::string& key, const std::string& value,
|
||||||
const char* helpString, cmStateEnums::CacheEntryType type)
|
const std::string& helpString,
|
||||||
|
cmStateEnums::CacheEntryType type)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry(key, cmValue(value), helpString, type);
|
this->AddCacheEntry(key, cmValue{ value }, cmValue{ helpString }, type);
|
||||||
}
|
}
|
||||||
void AddCacheEntry(const std::string& key, cmValue value,
|
void AddCacheEntry(const std::string& key, cmValue value,
|
||||||
const char* helpString,
|
const std::string& helpString,
|
||||||
|
cmStateEnums::CacheEntryType type)
|
||||||
|
{
|
||||||
|
this->AddCacheEntry(key, value, cmValue{ helpString }, type);
|
||||||
|
}
|
||||||
|
void AddCacheEntry(const std::string& key, cmValue value, cmValue helpString,
|
||||||
cmStateEnums::CacheEntryType type);
|
cmStateEnums::CacheEntryType type);
|
||||||
|
|
||||||
//! Remove an entry from the cache
|
//! Remove an entry from the cache
|
||||||
|
@ -257,7 +257,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
|
|||||||
// The variable is in the env, but not in the cache. Use it and put it
|
// The variable is in the env, but not in the cache. Use it and put it
|
||||||
// in the cache
|
// in the cache
|
||||||
valueToUse = envVarValue;
|
valueToUse = envVarValue;
|
||||||
mf->AddCacheDefinition(cacheEntryName, valueToUse, cacheEntryName.c_str(),
|
mf->AddCacheDefinition(cacheEntryName, valueToUse, cacheEntryName,
|
||||||
cmStateEnums::STRING, true);
|
cmStateEnums::STRING, true);
|
||||||
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
|
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
|
||||||
} else if (!envVarSet && cacheValue) {
|
} else if (!envVarSet && cacheValue) {
|
||||||
@ -272,9 +272,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
|
|||||||
valueToUse = *cacheValue;
|
valueToUse = *cacheValue;
|
||||||
if (valueToUse.find(envVarValue) == std::string::npos) {
|
if (valueToUse.find(envVarValue) == std::string::npos) {
|
||||||
valueToUse = envVarValue;
|
valueToUse = envVarValue;
|
||||||
mf->AddCacheDefinition(cacheEntryName, valueToUse,
|
mf->AddCacheDefinition(cacheEntryName, valueToUse, cacheEntryName,
|
||||||
cacheEntryName.c_str(), cmStateEnums::STRING,
|
cmStateEnums::STRING, true);
|
||||||
true);
|
|
||||||
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
|
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,7 @@ void cmFindBase::NormalizeFindResult()
|
|||||||
// value.
|
// value.
|
||||||
if (value != *existingValue || this->AlreadyInCacheWithoutMetaInfo) {
|
if (value != *existingValue || this->AlreadyInCacheWithoutMetaInfo) {
|
||||||
this->Makefile->GetCMakeInstance()->AddCacheEntry(
|
this->Makefile->GetCMakeInstance()->AddCacheEntry(
|
||||||
this->VariableName, value, this->VariableDocumentation.c_str(),
|
this->VariableName, value, this->VariableDocumentation,
|
||||||
this->VariableType);
|
this->VariableType);
|
||||||
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
||||||
cmPolicies::NEW) {
|
cmPolicies::NEW) {
|
||||||
@ -534,7 +534,7 @@ void cmFindBase::NormalizeFindResult()
|
|||||||
if (this->StoreResultInCache) {
|
if (this->StoreResultInCache) {
|
||||||
if (this->AlreadyInCacheWithoutMetaInfo) {
|
if (this->AlreadyInCacheWithoutMetaInfo) {
|
||||||
this->Makefile->AddCacheDefinition(this->VariableName, "",
|
this->Makefile->AddCacheDefinition(this->VariableName, "",
|
||||||
this->VariableDocumentation.c_str(),
|
this->VariableDocumentation,
|
||||||
this->VariableType);
|
this->VariableType);
|
||||||
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
||||||
cmPolicies::NEW &&
|
cmPolicies::NEW &&
|
||||||
@ -564,7 +564,7 @@ void cmFindBase::StoreFindResult(const std::string& value)
|
|||||||
if (!value.empty()) {
|
if (!value.empty()) {
|
||||||
if (this->StoreResultInCache) {
|
if (this->StoreResultInCache) {
|
||||||
this->Makefile->AddCacheDefinition(this->VariableName, value,
|
this->Makefile->AddCacheDefinition(this->VariableName, value,
|
||||||
this->VariableDocumentation.c_str(),
|
this->VariableDocumentation,
|
||||||
this->VariableType, force);
|
this->VariableType, force);
|
||||||
if (updateNormalVariable &&
|
if (updateNormalVariable &&
|
||||||
this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
|
this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
|
||||||
@ -580,7 +580,7 @@ void cmFindBase::StoreFindResult(const std::string& value)
|
|||||||
auto notFound = cmStrCat(this->VariableName, "-NOTFOUND");
|
auto notFound = cmStrCat(this->VariableName, "-NOTFOUND");
|
||||||
if (this->StoreResultInCache) {
|
if (this->StoreResultInCache) {
|
||||||
this->Makefile->AddCacheDefinition(this->VariableName, notFound,
|
this->Makefile->AddCacheDefinition(this->VariableName, notFound,
|
||||||
this->VariableDocumentation.c_str(),
|
this->VariableDocumentation,
|
||||||
this->VariableType, force);
|
this->VariableType, force);
|
||||||
if (updateNormalVariable &&
|
if (updateNormalVariable &&
|
||||||
this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
|
this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
|
||||||
|
@ -1728,7 +1728,7 @@ void cmFindPackageCommand::SetConfigDirCacheVariable(const std::string& value)
|
|||||||
std::string const help =
|
std::string const help =
|
||||||
cmStrCat("The directory containing a CMake configuration file for ",
|
cmStrCat("The directory containing a CMake configuration file for ",
|
||||||
this->Name, '.');
|
this->Name, '.');
|
||||||
this->Makefile->AddCacheDefinition(this->Variable, value, help.c_str(),
|
this->Makefile->AddCacheDefinition(this->Variable, value, help,
|
||||||
cmStateEnums::PATH, true);
|
cmStateEnums::PATH, true);
|
||||||
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
||||||
cmPolicies::NEW &&
|
cmPolicies::NEW &&
|
||||||
|
@ -1357,11 +1357,9 @@ void cmGlobalGenerator::Configure()
|
|||||||
|
|
||||||
// update the cache entry for the number of local generators, this is used
|
// update the cache entry for the number of local generators, this is used
|
||||||
// for progress
|
// for progress
|
||||||
char num[100];
|
this->GetCMakeInstance()->AddCacheEntry(
|
||||||
snprintf(num, sizeof(num), "%d", static_cast<int>(this->Makefiles.size()));
|
"CMAKE_NUMBER_OF_MAKEFILES", std::to_string(this->Makefiles.size()),
|
||||||
this->GetCMakeInstance()->AddCacheEntry("CMAKE_NUMBER_OF_MAKEFILES", num,
|
"number of local generators", cmStateEnums::INTERNAL);
|
||||||
"number of local generators",
|
|
||||||
cmStateEnums::INTERNAL);
|
|
||||||
|
|
||||||
auto endTime = std::chrono::steady_clock::now();
|
auto endTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
@ -1939,8 +1939,8 @@ void cmMakefile::AddDefinitionBool(const std::string& name, bool value)
|
|||||||
this->AddDefinition(name, value ? "ON" : "OFF");
|
this->AddDefinition(name, value ? "ON" : "OFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
void cmMakefile::AddCacheDefinition(const std::string& name, cmValue value,
|
||||||
const char* doc,
|
cmValue doc,
|
||||||
cmStateEnums::CacheEntryType type,
|
cmStateEnums::CacheEntryType type,
|
||||||
bool force)
|
bool force)
|
||||||
{
|
{
|
||||||
@ -1954,22 +1954,20 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
|||||||
// if this is not a force, then use the value from the cache
|
// if this is not a force, then use the value from the cache
|
||||||
// if it is a force, then use the value being passed in
|
// if it is a force, then use the value being passed in
|
||||||
if (!force) {
|
if (!force) {
|
||||||
value = existingValue->c_str();
|
value = existingValue;
|
||||||
}
|
}
|
||||||
if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) {
|
if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) {
|
||||||
nvalue = value ? value : "";
|
cmList files(value);
|
||||||
|
|
||||||
cmList files(nvalue);
|
|
||||||
for (auto& file : files) {
|
for (auto& file : files) {
|
||||||
if (!cmIsOff(file)) {
|
if (!cmIsOff(file)) {
|
||||||
file = cmSystemTools::CollapseFullPath(file);
|
file = cmSystemTools::CollapseFullPath(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nvalue = files.to_string();
|
nvalue = files.to_string();
|
||||||
|
value = cmValue{ nvalue };
|
||||||
|
|
||||||
this->GetCMakeInstance()->AddCacheEntry(name, nvalue, doc, type);
|
this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
|
||||||
nvalue = *this->GetState()->GetInitializedCacheValue(name);
|
value = this->GetState()->GetInitializedCacheValue(name);
|
||||||
value = nvalue.c_str();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
|
this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
|
||||||
|
@ -302,14 +302,23 @@ public:
|
|||||||
*/
|
*/
|
||||||
void AddDefinitionBool(const std::string& name, bool);
|
void AddDefinitionBool(const std::string& name, bool);
|
||||||
//! 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, cmValue value, cmValue doc,
|
||||||
const char* doc, cmStateEnums::CacheEntryType type,
|
cmStateEnums::CacheEntryType type,
|
||||||
bool force = false);
|
bool force = false);
|
||||||
void AddCacheDefinition(const std::string& name, const std::string& value,
|
void AddCacheDefinition(const std::string& name, cmValue value,
|
||||||
const char* doc, cmStateEnums::CacheEntryType type,
|
const std::string& doc,
|
||||||
|
cmStateEnums::CacheEntryType type,
|
||||||
bool force = false)
|
bool force = false)
|
||||||
{
|
{
|
||||||
this->AddCacheDefinition(name, value.c_str(), doc, type, force);
|
this->AddCacheDefinition(name, value, cmValue{ doc }, type, force);
|
||||||
|
}
|
||||||
|
void AddCacheDefinition(const std::string& name, const std::string& value,
|
||||||
|
const std::string& doc,
|
||||||
|
cmStateEnums::CacheEntryType type,
|
||||||
|
bool force = false)
|
||||||
|
{
|
||||||
|
this->AddCacheDefinition(name, cmValue{ value }, cmValue{ doc }, type,
|
||||||
|
force);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,8 @@ bool cmMarkAsAdvancedCommand(std::vector<std::string> const& args,
|
|||||||
if (oldBehavior) {
|
if (oldBehavior) {
|
||||||
if (!state->GetCacheEntryValue(variable)) {
|
if (!state->GetCacheEntryValue(variable)) {
|
||||||
status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
|
status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
|
||||||
variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED);
|
variable, cmValue{ nullptr }, cmValue{ nullptr },
|
||||||
|
cmStateEnums::UNINITIALIZED);
|
||||||
overwrite = true;
|
overwrite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ bool cmOptionCommand(std::vector<std::string> const& args,
|
|||||||
}
|
}
|
||||||
bool init = cmIsOn(initialValue);
|
bool init = cmIsOn(initialValue);
|
||||||
status.GetMakefile().AddCacheDefinition(args[0], init ? "ON" : "OFF",
|
status.GetMakefile().AddCacheDefinition(args[0], init ? "ON" : "OFF",
|
||||||
args[1].c_str(), cmStateEnums::BOOL);
|
args[1], cmStateEnums::BOOL);
|
||||||
if (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0077) !=
|
if (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0077) !=
|
||||||
cmPolicies::NEW &&
|
cmPolicies::NEW &&
|
||||||
status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0126) ==
|
status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0126) ==
|
||||||
|
@ -79,8 +79,8 @@ bool cmSetCommand(std::vector<std::string> const& args,
|
|||||||
bool force = false; // optional
|
bool force = false; // optional
|
||||||
bool parentScope = false;
|
bool parentScope = false;
|
||||||
cmStateEnums::CacheEntryType type =
|
cmStateEnums::CacheEntryType type =
|
||||||
cmStateEnums::STRING; // required if cache
|
cmStateEnums::STRING; // required if cache
|
||||||
const char* docstring = nullptr; // required if cache
|
cmValue docstring; // required if cache
|
||||||
|
|
||||||
unsigned int ignoreLastArgs = 0;
|
unsigned int ignoreLastArgs = 0;
|
||||||
// look for PARENT_SCOPE argument
|
// look for PARENT_SCOPE argument
|
||||||
@ -131,7 +131,7 @@ bool cmSetCommand(std::vector<std::string> const& args,
|
|||||||
// ensure that the type is actually converting to a string.
|
// ensure that the type is actually converting to a string.
|
||||||
type = cmStateEnums::STRING;
|
type = cmStateEnums::STRING;
|
||||||
}
|
}
|
||||||
docstring = args[cacheStart + 2].c_str();
|
docstring = cmValue{ args[cacheStart + 2] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if this is already in the cache
|
// see if this is already in the cache
|
||||||
@ -150,8 +150,8 @@ bool cmSetCommand(std::vector<std::string> const& args,
|
|||||||
|
|
||||||
// if it is meant to be in the cache then define it in the cache
|
// if it is meant to be in the cache then define it in the cache
|
||||||
if (cache) {
|
if (cache) {
|
||||||
status.GetMakefile().AddCacheDefinition(variable, value, docstring, type,
|
status.GetMakefile().AddCacheDefinition(variable, cmValue{ value },
|
||||||
force);
|
docstring, type, force);
|
||||||
} else {
|
} else {
|
||||||
// add the definition
|
// add the definition
|
||||||
status.GetMakefile().AddDefinition(variable, value);
|
status.GetMakefile().AddDefinition(variable, value);
|
||||||
|
@ -209,7 +209,7 @@ bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmState::AddCacheEntry(const std::string& key, cmValue value,
|
void cmState::AddCacheEntry(const std::string& key, cmValue value,
|
||||||
const char* helpString,
|
const std::string& helpString,
|
||||||
cmStateEnums::CacheEntryType type)
|
cmStateEnums::CacheEntryType type)
|
||||||
{
|
{
|
||||||
this->CacheManager->AddCacheEntry(key, value, helpString, type);
|
this->CacheManager->AddCacheEntry(key, value, helpString, type);
|
||||||
|
@ -254,7 +254,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class cmake;
|
friend class cmake;
|
||||||
void AddCacheEntry(const std::string& key, cmValue value,
|
void AddCacheEntry(const std::string& key, cmValue value,
|
||||||
const char* helpString,
|
const std::string& helpString,
|
||||||
cmStateEnums::CacheEntryType type);
|
cmStateEnums::CacheEntryType type);
|
||||||
|
|
||||||
bool DoWriteGlobVerifyTarget() const;
|
bool DoWriteGlobVerifyTarget() const;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmTryRunCommand.h"
|
#include "cmTryRunCommand.h"
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <cm/optional>
|
#include <cm/optional>
|
||||||
@ -293,11 +292,9 @@ void TryRunCommandImpl::RunExecutable(const std::string& runArgs,
|
|||||||
workDir ? workDir->c_str() : nullptr, cmSystemTools::OUTPUT_NONE,
|
workDir ? workDir->c_str() : nullptr, cmSystemTools::OUTPUT_NONE,
|
||||||
cmDuration::zero());
|
cmDuration::zero());
|
||||||
// set the run var
|
// set the run var
|
||||||
char retChar[16];
|
std::string retStr;
|
||||||
const char* retStr;
|
|
||||||
if (worked) {
|
if (worked) {
|
||||||
snprintf(retChar, sizeof(retChar), "%i", retVal);
|
retStr = std::to_string(retVal);
|
||||||
retStr = retChar;
|
|
||||||
} else {
|
} else {
|
||||||
retStr = "FAILED_TO_RUN";
|
retStr = "FAILED_TO_RUN";
|
||||||
}
|
}
|
||||||
@ -351,7 +348,7 @@ void TryRunCommandImpl::DoNotRunExecutable(
|
|||||||
detailsString);
|
detailsString);
|
||||||
this->Makefile->AddCacheDefinition(this->RunResultVariable,
|
this->Makefile->AddCacheDefinition(this->RunResultVariable,
|
||||||
"PLEASE_FILL_OUT-FAILED_TO_RUN",
|
"PLEASE_FILL_OUT-FAILED_TO_RUN",
|
||||||
comment.c_str(), cmStateEnums::STRING);
|
comment, cmStateEnums::STRING);
|
||||||
|
|
||||||
cmState* state = this->Makefile->GetState();
|
cmState* state = this->Makefile->GetState();
|
||||||
cmValue existingValue = state->GetCacheEntryValue(this->RunResultVariable);
|
cmValue existingValue = state->GetCacheEntryValue(this->RunResultVariable);
|
||||||
@ -372,9 +369,9 @@ void TryRunCommandImpl::DoNotRunExecutable(
|
|||||||
"would have printed on stdout on its target platform.\n",
|
"would have printed on stdout on its target platform.\n",
|
||||||
detailsString);
|
detailsString);
|
||||||
|
|
||||||
this->Makefile->AddCacheDefinition(
|
this->Makefile->AddCacheDefinition(internalRunOutputStdOutName,
|
||||||
internalRunOutputStdOutName, "PLEASE_FILL_OUT-NOTFOUND",
|
"PLEASE_FILL_OUT-NOTFOUND", comment,
|
||||||
comment.c_str(), cmStateEnums::STRING);
|
cmStateEnums::STRING);
|
||||||
cmState* state = this->Makefile->GetState();
|
cmState* state = this->Makefile->GetState();
|
||||||
cmValue existing =
|
cmValue existing =
|
||||||
state->GetCacheEntryValue(internalRunOutputStdOutName);
|
state->GetCacheEntryValue(internalRunOutputStdOutName);
|
||||||
@ -394,9 +391,9 @@ void TryRunCommandImpl::DoNotRunExecutable(
|
|||||||
"would have printed on stderr on its target platform.\n",
|
"would have printed on stderr on its target platform.\n",
|
||||||
detailsString);
|
detailsString);
|
||||||
|
|
||||||
this->Makefile->AddCacheDefinition(
|
this->Makefile->AddCacheDefinition(internalRunOutputStdErrName,
|
||||||
internalRunOutputStdErrName, "PLEASE_FILL_OUT-NOTFOUND",
|
"PLEASE_FILL_OUT-NOTFOUND", comment,
|
||||||
comment.c_str(), cmStateEnums::STRING);
|
cmStateEnums::STRING);
|
||||||
cmState* state = this->Makefile->GetState();
|
cmState* state = this->Makefile->GetState();
|
||||||
cmValue existing =
|
cmValue existing =
|
||||||
state->GetCacheEntryValue(internalRunOutputStdErrName);
|
state->GetCacheEntryValue(internalRunOutputStdErrName);
|
||||||
@ -416,9 +413,9 @@ void TryRunCommandImpl::DoNotRunExecutable(
|
|||||||
"would have printed on stdout and stderr on its target platform.\n",
|
"would have printed on stdout and stderr on its target platform.\n",
|
||||||
detailsString);
|
detailsString);
|
||||||
|
|
||||||
this->Makefile->AddCacheDefinition(
|
this->Makefile->AddCacheDefinition(internalRunOutputName,
|
||||||
internalRunOutputName, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(),
|
"PLEASE_FILL_OUT-NOTFOUND", comment,
|
||||||
cmStateEnums::STRING);
|
cmStateEnums::STRING);
|
||||||
cmState* state = this->Makefile->GetState();
|
cmState* state = this->Makefile->GetState();
|
||||||
cmValue existing = state->GetCacheEntryValue(internalRunOutputName);
|
cmValue existing = state->GetCacheEntryValue(internalRunOutputName);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
@ -2205,7 +2205,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
|
|||||||
this->LoadCache();
|
this->LoadCache();
|
||||||
// restore the changed compilers
|
// restore the changed compilers
|
||||||
for (SaveCacheEntry const& i : saved) {
|
for (SaveCacheEntry const& i : saved) {
|
||||||
this->AddCacheEntry(i.key, i.value, i.help.c_str(), i.type);
|
this->AddCacheEntry(i.key, i.value, i.help, i.type);
|
||||||
}
|
}
|
||||||
cmSystemTools::Message(warning.str());
|
cmSystemTools::Message(warning.str());
|
||||||
// avoid reconfigure if there were errors
|
// avoid reconfigure if there were errors
|
||||||
@ -2775,7 +2775,7 @@ int cmake::Generate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmake::AddCacheEntry(const std::string& key, cmValue value,
|
void cmake::AddCacheEntry(const std::string& key, cmValue value,
|
||||||
const char* helpString, int type)
|
cmValue helpString, int type)
|
||||||
{
|
{
|
||||||
this->State->AddCacheEntry(key, value, helpString,
|
this->State->AddCacheEntry(key, value, helpString,
|
||||||
static_cast<cmStateEnums::CacheEntryType>(type));
|
static_cast<cmStateEnums::CacheEntryType>(type));
|
||||||
|
@ -328,20 +328,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
cmValue GetCacheDefinition(const std::string&) const;
|
cmValue GetCacheDefinition(const std::string&) const;
|
||||||
//! Add an entry into the cache
|
//! Add an entry into the cache
|
||||||
void AddCacheEntry(const std::string& key, const char* value,
|
|
||||||
const char* helpString, int type)
|
|
||||||
{
|
|
||||||
this->AddCacheEntry(key,
|
|
||||||
value ? cmValue(std::string(value)) : cmValue(nullptr),
|
|
||||||
helpString, type);
|
|
||||||
}
|
|
||||||
void AddCacheEntry(const std::string& key, const std::string& value,
|
void AddCacheEntry(const std::string& key, const std::string& value,
|
||||||
const char* helpString, int type)
|
const std::string& helpString, int type)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry(key, cmValue(value), helpString, type);
|
this->AddCacheEntry(key, cmValue{ value }, cmValue{ helpString }, type);
|
||||||
}
|
}
|
||||||
void AddCacheEntry(const std::string& key, cmValue value,
|
void AddCacheEntry(const std::string& key, cmValue value,
|
||||||
const char* helpString, int type);
|
const std::string& helpString, int type)
|
||||||
|
{
|
||||||
|
this->AddCacheEntry(key, value, cmValue{ helpString }, type);
|
||||||
|
}
|
||||||
|
void AddCacheEntry(const std::string& key, cmValue value, cmValue helpString,
|
||||||
|
int type);
|
||||||
|
|
||||||
bool DoWriteGlobVerifyTarget() const;
|
bool DoWriteGlobVerifyTarget() const;
|
||||||
std::string const& GetGlobVerifyScript() const;
|
std::string const& GetGlobVerifyScript() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user