mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Merge topic 'enh-AddCacheEntry-accepts-new-types'
f84193292cUse new AddCacheEntry signatures3c2e58eeb8AddCacheEntry accept cmProp or std::string Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6495
This commit is contained in:
@@ -232,17 +232,17 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
||||
// before writing the cache, update the version numbers
|
||||
// to the
|
||||
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION",
|
||||
std::to_string(cmVersion::GetMajorVersion()).c_str(),
|
||||
std::to_string(cmVersion::GetMajorVersion()),
|
||||
"Major version of cmake used to create the "
|
||||
"current loaded cache",
|
||||
cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION",
|
||||
std::to_string(cmVersion::GetMinorVersion()).c_str(),
|
||||
std::to_string(cmVersion::GetMinorVersion()),
|
||||
"Minor version of cmake used to create the "
|
||||
"current loaded cache",
|
||||
cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION",
|
||||
std::to_string(cmVersion::GetPatchVersion()).c_str(),
|
||||
std::to_string(cmVersion::GetPatchVersion()),
|
||||
"Patch version of cmake used to create the "
|
||||
"current loaded cache",
|
||||
cmStateEnums::INTERNAL);
|
||||
@@ -256,7 +256,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
||||
currentcwd[0] = static_cast<char>(currentcwd[0] - 'A' + 'a');
|
||||
}
|
||||
cmSystemTools::ConvertToUnixSlashes(currentcwd);
|
||||
this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd.c_str(),
|
||||
this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd,
|
||||
"This is the directory where this CMakeCache.txt"
|
||||
" was created",
|
||||
cmStateEnums::INTERNAL);
|
||||
@@ -521,7 +521,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const
|
||||
"=================================================\n";
|
||||
}
|
||||
|
||||
void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
|
||||
void cmCacheManager::AddCacheEntry(const std::string& key, cmProp value,
|
||||
const char* helpString,
|
||||
cmStateEnums::CacheEntryType type)
|
||||
{
|
||||
@@ -550,10 +550,10 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
|
||||
: "(This variable does not exist and should not be used)");
|
||||
}
|
||||
|
||||
void cmCacheManager::CacheEntry::SetValue(const char* value)
|
||||
void cmCacheManager::CacheEntry::SetValue(cmProp value)
|
||||
{
|
||||
if (value) {
|
||||
this->Value = value;
|
||||
this->Value = *value;
|
||||
this->Initialized = true;
|
||||
} else {
|
||||
this->Value.clear();
|
||||
|
||||
@@ -31,7 +31,7 @@ class cmCacheManager
|
||||
|
||||
public:
|
||||
const std::string& GetValue() const { return this->Value; }
|
||||
void SetValue(const char*);
|
||||
void SetValue(cmProp);
|
||||
|
||||
cmStateEnums::CacheEntryType GetType() const { return this->Type; }
|
||||
void SetType(cmStateEnums::CacheEntryType ty) { this->Type = ty; }
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void SetCacheEntryValue(std::string const& key, std::string const& value)
|
||||
{
|
||||
if (auto* entry = this->GetCacheEntry(key)) {
|
||||
entry->SetValue(value.c_str());
|
||||
entry->SetValue(cmProp(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,18 @@ public:
|
||||
|
||||
//! 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 ? cmProp(std::string(value)) : cmProp(nullptr),
|
||||
helpString, type);
|
||||
}
|
||||
void AddCacheEntry(const std::string& key, const std::string& value,
|
||||
const char* helpString, cmStateEnums::CacheEntryType type)
|
||||
{
|
||||
this->AddCacheEntry(key, cmProp(value), helpString, type);
|
||||
}
|
||||
void AddCacheEntry(const std::string& key, cmProp value,
|
||||
const char* helpString,
|
||||
cmStateEnums::CacheEntryType type);
|
||||
|
||||
|
||||
@@ -358,8 +358,8 @@ void cmFindBase::NormalizeFindResult()
|
||||
// value.
|
||||
if (value != *existingValue || this->AlreadyInCacheWithoutMetaInfo) {
|
||||
this->Makefile->GetCMakeInstance()->AddCacheEntry(
|
||||
this->VariableName, value.c_str(),
|
||||
this->VariableDocumentation.c_str(), this->VariableType);
|
||||
this->VariableName, value, this->VariableDocumentation.c_str(),
|
||||
this->VariableType);
|
||||
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
|
||||
cmPolicies::NEW) {
|
||||
if (this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
|
||||
|
||||
@@ -117,7 +117,7 @@ std::string cmGlobalCommonGenerator::GetEditCacheCommand() const
|
||||
editCacheCommand = cmSystemTools::GetCMakeGUICommand();
|
||||
}
|
||||
if (!editCacheCommand.empty()) {
|
||||
cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
|
||||
cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand,
|
||||
"Path to cache edit program executable.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
@@ -2185,9 +2185,8 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator* gen,
|
||||
this->TryCompileOuterMakefile = mf;
|
||||
cmProp make =
|
||||
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
|
||||
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", cmToCStr(make),
|
||||
"make program",
|
||||
cmStateEnums::FILEPATH);
|
||||
this->GetCMakeInstance()->AddCacheEntry(
|
||||
"CMAKE_MAKE_PROGRAM", make, "make program", cmStateEnums::FILEPATH);
|
||||
// copy the enabled languages
|
||||
this->GetCMakeInstance()->GetState()->SetEnabledLanguages(
|
||||
gen->GetCMakeInstance()->GetState()->GetEnabledLanguages());
|
||||
|
||||
@@ -467,9 +467,9 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
|
||||
// Save the selected instance persistently.
|
||||
std::string genInstance = mf->GetSafeDefinition("CMAKE_GENERATOR_INSTANCE");
|
||||
if (vsInstance != genInstance) {
|
||||
this->CMakeInstance->AddCacheEntry(
|
||||
"CMAKE_GENERATOR_INSTANCE", vsInstance.c_str(),
|
||||
"Generator instance identifier.", cmStateEnums::INTERNAL);
|
||||
this->CMakeInstance->AddCacheEntry("CMAKE_GENERATOR_INSTANCE", vsInstance,
|
||||
"Generator instance identifier.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3241,9 +3241,8 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
|
||||
return *storedGUID;
|
||||
}
|
||||
|
||||
this->CMakeInstance->AddCacheEntry(guidStoreName, id.c_str(),
|
||||
"Stored Xcode object GUID",
|
||||
cmStateEnums::INTERNAL);
|
||||
this->CMakeInstance->AddCacheEntry(
|
||||
guidStoreName, id, "Stored Xcode object GUID", cmStateEnums::INTERNAL);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -77,9 +77,8 @@ bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
|
||||
|
||||
if (!customGuid.empty()) {
|
||||
std::string guidVariable = utility_name + "_GUID_CMAKE";
|
||||
mf.GetCMakeInstance()->AddCacheEntry(guidVariable, customGuid.c_str(),
|
||||
"Stored GUID",
|
||||
cmStateEnums::INTERNAL);
|
||||
mf.GetCMakeInstance()->AddCacheEntry(
|
||||
guidVariable, customGuid, "Stored GUID", cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
// Create a target instance for this utility.
|
||||
|
||||
@@ -2142,7 +2142,7 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
|
||||
std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
|
||||
// save the GUID in the cache
|
||||
this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
|
||||
guidStoreName, parser.GUID.c_str(), "Stored GUID", cmStateEnums::INTERNAL);
|
||||
guidStoreName, parser.GUID, "Stored GUID", cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
std::string cmLocalVisualStudio7Generator::GetTargetDirectory(
|
||||
|
||||
@@ -1927,7 +1927,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
||||
nvalue += files[cc];
|
||||
}
|
||||
|
||||
this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
|
||||
this->GetCMakeInstance()->AddCacheEntry(name, nvalue, doc, type);
|
||||
nvalue = *this->GetState()->GetInitializedCacheValue(name);
|
||||
value = nvalue.c_str();
|
||||
}
|
||||
@@ -3561,13 +3561,13 @@ int cmMakefile::TryCompile(const std::string& srcdir,
|
||||
// Tell the single-configuration generator which one to use.
|
||||
// Add this before the user-provided CMake arguments in case
|
||||
// one of the arguments is -DCMAKE_BUILD_TYPE=...
|
||||
cm.AddCacheEntry("CMAKE_BUILD_TYPE", config->c_str(),
|
||||
"Build configuration", cmStateEnums::STRING);
|
||||
cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, "Build configuration",
|
||||
cmStateEnums::STRING);
|
||||
}
|
||||
}
|
||||
cmProp recursionDepth = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH");
|
||||
if (recursionDepth) {
|
||||
cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth->c_str(),
|
||||
cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth,
|
||||
"Maximum recursion depth", cmStateEnums::STRING);
|
||||
}
|
||||
// if cmake args were provided then pass them in
|
||||
|
||||
@@ -206,7 +206,7 @@ bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
|
||||
return this->CacheManager->GetCacheEntryPropertyAsBool(key, propertyName);
|
||||
}
|
||||
|
||||
void cmState::AddCacheEntry(const std::string& key, const char* value,
|
||||
void cmState::AddCacheEntry(const std::string& key, cmProp value,
|
||||
const char* helpString,
|
||||
cmStateEnums::CacheEntryType type)
|
||||
{
|
||||
|
||||
@@ -219,6 +219,18 @@ public:
|
||||
private:
|
||||
friend class cmake;
|
||||
void AddCacheEntry(const std::string& key, const char* value,
|
||||
const char* helpString, cmStateEnums::CacheEntryType type)
|
||||
{
|
||||
this->AddCacheEntry(key,
|
||||
value ? cmProp(std::string(value)) : cmProp(nullptr),
|
||||
helpString, type);
|
||||
}
|
||||
void AddCacheEntry(const std::string& key, const std::string& value,
|
||||
const char* helpString, cmStateEnums::CacheEntryType type)
|
||||
{
|
||||
this->AddCacheEntry(key, cmProp(value), helpString, type);
|
||||
}
|
||||
void AddCacheEntry(const std::string& key, cmProp value,
|
||||
const char* helpString,
|
||||
cmStateEnums::CacheEntryType type);
|
||||
|
||||
|
||||
@@ -605,9 +605,8 @@ void cmake::ProcessCacheArg(const std::string& var, const std::string& value,
|
||||
}
|
||||
}
|
||||
|
||||
this->AddCacheEntry(var, value.c_str(),
|
||||
"No help, variable specified on the command line.",
|
||||
type);
|
||||
this->AddCacheEntry(
|
||||
var, value, "No help, variable specified on the command line.", type);
|
||||
|
||||
if (this->WarnUnusedCli) {
|
||||
if (!haveValue ||
|
||||
@@ -1517,16 +1516,15 @@ void cmake::SetDirectoriesFromFile(const std::string& arg)
|
||||
int cmake::AddCMakePaths()
|
||||
{
|
||||
// Save the value in the cache
|
||||
this->AddCacheEntry("CMAKE_COMMAND",
|
||||
cmSystemTools::GetCMakeCommand().c_str(),
|
||||
this->AddCacheEntry("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand(),
|
||||
"Path to CMake executable.", cmStateEnums::INTERNAL);
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
this->AddCacheEntry(
|
||||
"CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(),
|
||||
"Path to ctest program executable.", cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry(
|
||||
"CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(),
|
||||
"Path to cpack program executable.", cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand(),
|
||||
"Path to ctest program executable.",
|
||||
cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand(),
|
||||
"Path to cpack program executable.",
|
||||
cmStateEnums::INTERNAL);
|
||||
#endif
|
||||
if (!cmSystemTools::FileExists(
|
||||
(cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake"))) {
|
||||
@@ -1538,7 +1536,7 @@ int cmake::AddCMakePaths()
|
||||
cmSystemTools::GetCMakeRoot());
|
||||
return 0;
|
||||
}
|
||||
this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
|
||||
this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot(),
|
||||
"Path to CMake installation.", cmStateEnums::INTERNAL);
|
||||
|
||||
return 1;
|
||||
@@ -1886,7 +1884,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
|
||||
this->LoadCache();
|
||||
// restore the changed compilers
|
||||
for (SaveCacheEntry const& i : saved) {
|
||||
this->AddCacheEntry(i.key, i.value.c_str(), i.help.c_str(), i.type);
|
||||
this->AddCacheEntry(i.key, i.value, i.help.c_str(), i.type);
|
||||
}
|
||||
cmSystemTools::Message(warning.str());
|
||||
// avoid reconfigure if there were errors
|
||||
@@ -1993,7 +1991,7 @@ int cmake::ActualConfigure()
|
||||
}
|
||||
if (!res) {
|
||||
this->AddCacheEntry(
|
||||
"CMAKE_HOME_DIRECTORY", this->GetHomeDirectory().c_str(),
|
||||
"CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(),
|
||||
"Source directory with the top level CMakeLists.txt file for this "
|
||||
"project",
|
||||
cmStateEnums::INTERNAL);
|
||||
@@ -2038,19 +2036,17 @@ int cmake::ActualConfigure()
|
||||
}
|
||||
}
|
||||
if (!this->State->GetInitializedCacheValue("CMAKE_GENERATOR")) {
|
||||
this->AddCacheEntry("CMAKE_GENERATOR",
|
||||
this->GlobalGenerator->GetName().c_str(),
|
||||
this->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName(),
|
||||
"Name of generator.", cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
|
||||
this->GlobalGenerator->GetExtraGeneratorName().c_str(),
|
||||
"Name of external makefile project generator.",
|
||||
cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry(
|
||||
"CMAKE_EXTRA_GENERATOR", this->GlobalGenerator->GetExtraGeneratorName(),
|
||||
"Name of external makefile project generator.", cmStateEnums::INTERNAL);
|
||||
|
||||
if (!this->State->GetInitializedCacheValue("CMAKE_TOOLCHAIN_FILE")) {
|
||||
std::string envToolchain;
|
||||
if (cmSystemTools::GetEnv("CMAKE_TOOLCHAIN_FILE", envToolchain) &&
|
||||
!envToolchain.empty()) {
|
||||
this->AddCacheEntry("CMAKE_TOOLCHAIN_FILE", envToolchain.c_str(),
|
||||
this->AddCacheEntry("CMAKE_TOOLCHAIN_FILE", envToolchain,
|
||||
"The CMake toolchain file",
|
||||
cmStateEnums::FILEPATH);
|
||||
}
|
||||
@@ -2069,9 +2065,9 @@ int cmake::ActualConfigure()
|
||||
return -2;
|
||||
}
|
||||
} else {
|
||||
this->AddCacheEntry(
|
||||
"CMAKE_GENERATOR_INSTANCE", this->GeneratorInstance.c_str(),
|
||||
"Generator instance identifier.", cmStateEnums::INTERNAL);
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_INSTANCE", this->GeneratorInstance,
|
||||
"Generator instance identifier.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
if (cmProp platformName =
|
||||
@@ -2087,8 +2083,7 @@ int cmake::ActualConfigure()
|
||||
return -2;
|
||||
}
|
||||
} else {
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM",
|
||||
this->GeneratorPlatform.c_str(),
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", this->GeneratorPlatform,
|
||||
"Name of generator platform.", cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
@@ -2104,8 +2099,7 @@ int cmake::ActualConfigure()
|
||||
return -2;
|
||||
}
|
||||
} else {
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
|
||||
this->GeneratorToolset.c_str(),
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", this->GeneratorToolset,
|
||||
"Name of generator toolset.", cmStateEnums::INTERNAL);
|
||||
}
|
||||
|
||||
@@ -2416,7 +2410,7 @@ int cmake::Generate()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cmake::AddCacheEntry(const std::string& key, const char* value,
|
||||
void cmake::AddCacheEntry(const std::string& key, cmProp value,
|
||||
const char* helpString, int type)
|
||||
{
|
||||
this->State->AddCacheEntry(key, value, helpString,
|
||||
@@ -3540,7 +3534,7 @@ void cmake::SetSuppressDevWarnings(bool b)
|
||||
value = "FALSE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", value.c_str(),
|
||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", value,
|
||||
"Suppress Warnings that are meant for"
|
||||
" the author of the CMakeLists.txt files.",
|
||||
cmStateEnums::INTERNAL);
|
||||
@@ -3564,7 +3558,7 @@ void cmake::SetSuppressDeprecatedWarnings(bool b)
|
||||
value = "TRUE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value.c_str(),
|
||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value,
|
||||
"Whether to issue warnings for deprecated "
|
||||
"functionality.",
|
||||
cmStateEnums::INTERNAL);
|
||||
@@ -3588,7 +3582,7 @@ void cmake::SetDevWarningsAsErrors(bool b)
|
||||
value = "TRUE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", value.c_str(),
|
||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", value,
|
||||
"Suppress errors that are meant for"
|
||||
" the author of the CMakeLists.txt files.",
|
||||
cmStateEnums::INTERNAL);
|
||||
@@ -3612,7 +3606,7 @@ void cmake::SetDeprecatedWarningsAsErrors(bool b)
|
||||
value = "FALSE";
|
||||
}
|
||||
|
||||
this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value.c_str(),
|
||||
this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value,
|
||||
"Whether to issue deprecation errors for macros"
|
||||
" and functions.",
|
||||
cmStateEnums::INTERNAL);
|
||||
|
||||
@@ -332,6 +332,18 @@ public:
|
||||
cmProp GetCacheDefinition(const std::string&) const;
|
||||
//! Add an entry into the cache
|
||||
void AddCacheEntry(const std::string& key, const char* value,
|
||||
const char* helpString, int type)
|
||||
{
|
||||
this->AddCacheEntry(key,
|
||||
value ? cmProp(std::string(value)) : cmProp(nullptr),
|
||||
helpString, type);
|
||||
}
|
||||
void AddCacheEntry(const std::string& key, const std::string& value,
|
||||
const char* helpString, int type)
|
||||
{
|
||||
this->AddCacheEntry(key, cmProp(value), helpString, type);
|
||||
}
|
||||
void AddCacheEntry(const std::string& key, cmProp value,
|
||||
const char* helpString, int type);
|
||||
|
||||
bool DoWriteGlobVerifyTarget() const;
|
||||
|
||||
Reference in New Issue
Block a user