cmState::GetInitializedCacheValue: return cmProp

cmProp alias is used; no actual change in type
This commit is contained in:
Vitaly Stakhovsky 2020-04-30 22:00:00 -04:00
parent c09efe074d
commit e267c3fddf
8 changed files with 24 additions and 30 deletions

View File

@ -69,8 +69,7 @@ const char* cmCommandArgumentParserHelper::ExpandSpecialVariable(
return "";
}
if (strcmp(key, "CACHE") == 0) {
if (const std::string* c =
this->Makefile->GetState()->GetInitializedCacheValue(var)) {
if (cmProp c = this->Makefile->GetState()->GetInitializedCacheValue(var)) {
if (this->EscapeQuotes) {
return this->AddString(cmEscapeQuotes(*c));
}

View File

@ -243,8 +243,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
const bool envVarSet = cmSystemTools::GetEnv(envVar, envVarValue);
std::string cacheEntryName = cmStrCat("CMAKE_ECLIPSE_ENVVAR_", envVar);
const std::string* cacheValue =
lg.GetState()->GetInitializedCacheValue(cacheEntryName);
cmProp cacheValue = lg.GetState()->GetInitializedCacheValue(cacheEntryName);
// now we have both, decide which one to use
std::string valueToUse;

View File

@ -232,7 +232,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
if (!optional && (path.empty() || !cmSystemTools::FileExists(path))) {
return;
}
const std::string* cname =
cmProp cname =
this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp);
std::string changeVars;
if (cname && !optional) {
@ -2057,9 +2057,8 @@ void cmGlobalGenerator::AddMakefile(std::unique_ptr<cmMakefile> mf)
// update progress
// estimate how many lg there will be
const std::string* numGenC =
this->CMakeInstance->GetState()->GetInitializedCacheValue(
"CMAKE_NUMBER_OF_MAKEFILES");
cmProp numGenC = this->CMakeInstance->GetState()->GetInitializedCacheValue(
"CMAKE_NUMBER_OF_MAKEFILES");
if (!numGenC) {
// If CMAKE_NUMBER_OF_MAKEFILES is not set

View File

@ -1880,8 +1880,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
cmStateEnums::CacheEntryType type,
bool force)
{
const std::string* existingValue =
this->GetState()->GetInitializedCacheValue(name);
cmProp existingValue = this->GetState()->GetInitializedCacheValue(name);
// must be outside the following if() to keep it alive long enough
std::string nvalue;
@ -2682,7 +2681,7 @@ const std::string& cmMakefile::GetRequiredDefinition(
bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
const std::string* def = this->StateSnapshot.GetDefinition(name);
cmProp def = this->StateSnapshot.GetDefinition(name);
if (!def) {
def = this->GetState()->GetInitializedCacheValue(name);
}
@ -2699,7 +2698,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
const std::string* cmMakefile::GetDef(const std::string& name) const
{
const std::string* def = this->StateSnapshot.GetDefinition(name);
cmProp def = this->StateSnapshot.GetDefinition(name);
if (!def) {
def = this->GetState()->GetInitializedCacheValue(name);
}

View File

@ -26,6 +26,8 @@
#include "cmSystemTools.h"
#include "cmake.h"
using cmProp = const std::string*; // just to silence IWYU
// Get rid of some windows macros:
#undef max
@ -562,7 +564,7 @@ cmServerResponse cmServerProtocol1::ProcessConfigure(
if (cm->LoadCache(buildDir)) {
// build directory has been set up before
const std::string* cachedSourceDir =
cmProp cachedSourceDir =
cm->GetState()->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
if (!cachedSourceDir) {
return request.ReportError("No CMAKE_HOME_DIRECTORY found in cache.");
@ -572,7 +574,7 @@ cmServerResponse cmServerProtocol1::ProcessConfigure(
cm->SetHomeDirectory(sourceDir);
}
const std::string* cachedGenerator =
cmProp cachedGenerator =
cm->GetState()->GetInitializedCacheValue("CMAKE_GENERATOR");
if (cachedGenerator) {
if (gg && gg->GetName() != *cachedGenerator) {

View File

@ -155,8 +155,7 @@ std::string cmState::GetSafeCacheEntryValue(std::string const& key) const
return std::string();
}
const std::string* cmState::GetInitializedCacheValue(
std::string const& key) const
cmProp cmState::GetInitializedCacheValue(std::string const& key) const
{
return this->CacheManager->GetInitializedCacheValue(key);
}

View File

@ -92,7 +92,7 @@ public:
std::vector<std::string> GetCacheEntryKeys() const;
cmProp GetCacheEntryValue(std::string const& key) const;
std::string GetSafeCacheEntryValue(std::string const& key) const;
const std::string* GetInitializedCacheValue(std::string const& key) const;
cmProp GetInitializedCacheValue(std::string const& key) const;
cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const;
void SetCacheEntryValue(std::string const& key, std::string const& value);
void SetCacheValue(std::string const& key, std::string const& value);

View File

@ -313,8 +313,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
bool haveValue = false;
std::string cachedValue;
if (this->WarnUnusedCli) {
if (const std::string* v =
this->State->GetInitializedCacheValue(var)) {
if (cmProp v = this->State->GetInitializedCacheValue(var)) {
haveValue = true;
cachedValue = *v;
}
@ -1529,9 +1528,8 @@ int cmake::ActualConfigure()
// no generator specified on the command line
if (!this->GlobalGenerator) {
const std::string* genName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
const std::string* extraGenName =
cmProp genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
cmProp extraGenName =
this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
if (genName) {
std::string fullName =
@ -1554,8 +1552,7 @@ int cmake::ActualConfigure()
}
}
const std::string* genName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
cmProp genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
if (genName) {
if (!this->GlobalGenerator->MatchesGeneratorName(*genName)) {
std::string message =
@ -1577,7 +1574,7 @@ int cmake::ActualConfigure()
cmStateEnums::INTERNAL);
}
if (const std::string* instance =
if (cmProp instance =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_INSTANCE")) {
if (this->GeneratorInstanceSet && this->GeneratorInstance != *instance) {
std::string message =
@ -1594,7 +1591,7 @@ int cmake::ActualConfigure()
"Generator instance identifier.", cmStateEnums::INTERNAL);
}
if (const std::string* platformName =
if (cmProp platformName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) {
if (this->GeneratorPlatformSet &&
this->GeneratorPlatform != *platformName) {
@ -1612,7 +1609,7 @@ int cmake::ActualConfigure()
"Name of generator platform.", cmStateEnums::INTERNAL);
}
if (const std::string* tsName =
if (cmProp tsName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) {
if (this->GeneratorToolsetSet && this->GeneratorToolset != *tsName) {
std::string message =
@ -1983,7 +1980,7 @@ std::string cmake::StripExtension(const std::string& file) const
const char* cmake::GetCacheDefinition(const std::string& name) const
{
const std::string* p = this->State->GetInitializedCacheValue(name);
cmProp p = this->State->GetInitializedCacheValue(name);
return p ? p->c_str() : nullptr;
}
@ -2190,7 +2187,7 @@ void cmake::PrintGeneratorList()
void cmake::UpdateConversionPathTable()
{
// Update the path conversion table with any specified file:
const std::string* tablepath =
cmProp tablepath =
this->State->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE");
if (tablepath) {
@ -2834,7 +2831,7 @@ bool cmake::Open(const std::string& dir, bool dryRun)
std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
return false;
}
const std::string* extraGenName =
cmProp extraGenName =
this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
std::string fullName =
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(