mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
cmMakefile::AddCacheDefinition: Add overload that accepts std::string value
This commit is contained in:
@@ -108,7 +108,7 @@ bool TwoArgsSignature(std::vector<std::string> const& args,
|
||||
if (cacheValue) {
|
||||
return true;
|
||||
}
|
||||
mf.AddCacheDefinition(define, makecommand.c_str(),
|
||||
mf.AddCacheDefinition(define, makecommand,
|
||||
"Command used to build entire project "
|
||||
"from the command line.",
|
||||
cmStateEnums::STRING);
|
||||
|
||||
@@ -28,7 +28,7 @@ bool cmBuildNameCommand(std::vector<std::string> const& args,
|
||||
std::replace(cv.begin(), cv.end(), '/', '_');
|
||||
std::replace(cv.begin(), cv.end(), '(', '_');
|
||||
std::replace(cv.begin(), cv.end(), ')', '_');
|
||||
mf.AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
|
||||
mf.AddCacheDefinition(args[0], cv, "Name of build.",
|
||||
cmStateEnums::STRING);
|
||||
}
|
||||
return true;
|
||||
@@ -54,7 +54,7 @@ bool cmBuildNameCommand(std::vector<std::string> const& args,
|
||||
std::replace(buildname.begin(), buildname.end(), '(', '_');
|
||||
std::replace(buildname.begin(), buildname.end(), ')', '_');
|
||||
|
||||
mf.AddCacheDefinition(args[0], buildname.c_str(), "Name of build.",
|
||||
mf.AddCacheDefinition(args[0], buildname, "Name of build.",
|
||||
cmStateEnums::STRING);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -255,8 +255,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
|
||||
// The variable is in the env, but not in the cache. Use it and put it
|
||||
// in the cache
|
||||
valueToUse = envVarValue;
|
||||
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
|
||||
cacheEntryName.c_str(), cmStateEnums::STRING, true);
|
||||
mf->AddCacheDefinition(cacheEntryName, valueToUse, cacheEntryName.c_str(),
|
||||
cmStateEnums::STRING, true);
|
||||
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
|
||||
} else if (!envVarSet && cacheValue != nullptr) {
|
||||
// It is already in the cache, but not in the env, so use it from the cache
|
||||
@@ -270,7 +270,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
|
||||
valueToUse = *cacheValue;
|
||||
if (valueToUse.find(envVarValue) == std::string::npos) {
|
||||
valueToUse = envVarValue;
|
||||
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
|
||||
mf->AddCacheDefinition(cacheEntryName, valueToUse,
|
||||
cacheEntryName.c_str(), cmStateEnums::STRING,
|
||||
true);
|
||||
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
|
||||
|
||||
@@ -76,13 +76,13 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||
std::string const library = this->FindLibrary();
|
||||
if (!library.empty()) {
|
||||
// Save the value in the cache
|
||||
this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(),
|
||||
this->Makefile->AddCacheDefinition(this->VariableName, library,
|
||||
this->VariableDocumentation.c_str(),
|
||||
cmStateEnums::FILEPATH);
|
||||
return true;
|
||||
}
|
||||
std::string notfound = this->VariableName + "-NOTFOUND";
|
||||
this->Makefile->AddCacheDefinition(this->VariableName, notfound.c_str(),
|
||||
this->Makefile->AddCacheDefinition(this->VariableName, notfound,
|
||||
this->VariableDocumentation.c_str(),
|
||||
cmStateEnums::FILEPATH);
|
||||
if (this->Required) {
|
||||
|
||||
@@ -1060,8 +1060,8 @@ bool cmFindPackageCommand::FindConfig()
|
||||
cmStrCat("The directory containing a CMake configuration file for ",
|
||||
this->Name, '.');
|
||||
// We force the value since we do not get here if it was already set.
|
||||
this->Makefile->AddCacheDefinition(this->Variable, init.c_str(),
|
||||
help.c_str(), cmStateEnums::PATH, true);
|
||||
this->Makefile->AddCacheDefinition(this->Variable, init, help.c_str(),
|
||||
cmStateEnums::PATH, true);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||
std::string result = this->FindHeader();
|
||||
if (!result.empty()) {
|
||||
this->Makefile->AddCacheDefinition(
|
||||
this->VariableName, result.c_str(), this->VariableDocumentation.c_str(),
|
||||
this->VariableName, result, this->VariableDocumentation.c_str(),
|
||||
(this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH);
|
||||
return true;
|
||||
}
|
||||
this->Makefile->AddCacheDefinition(
|
||||
this->VariableName, (this->VariableName + "-NOTFOUND").c_str(),
|
||||
this->VariableName, this->VariableName + "-NOTFOUND",
|
||||
this->VariableDocumentation.c_str(),
|
||||
(this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH);
|
||||
if (this->Required) {
|
||||
|
||||
@@ -128,14 +128,14 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||
std::string const result = FindProgram();
|
||||
if (!result.empty()) {
|
||||
// Save the value in the cache
|
||||
this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(),
|
||||
this->Makefile->AddCacheDefinition(this->VariableName, result,
|
||||
this->VariableDocumentation.c_str(),
|
||||
cmStateEnums::FILEPATH);
|
||||
|
||||
return true;
|
||||
}
|
||||
this->Makefile->AddCacheDefinition(
|
||||
this->VariableName, (this->VariableName + "-NOTFOUND").c_str(),
|
||||
this->VariableName, this->VariableName + "-NOTFOUND",
|
||||
this->VariableDocumentation.c_str(), cmStateEnums::FILEPATH);
|
||||
if (this->Required) {
|
||||
this->Makefile->IssueMessage(
|
||||
|
||||
@@ -120,11 +120,11 @@ bool cmGetFilenameComponentCommand(std::vector<std::string> const& args,
|
||||
if (args.size() >= 4 && args.back() == "CACHE") {
|
||||
if (!programArgs.empty() && !storeArgs.empty()) {
|
||||
status.GetMakefile().AddCacheDefinition(
|
||||
storeArgs, programArgs.c_str(), "",
|
||||
storeArgs, programArgs, "",
|
||||
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
|
||||
}
|
||||
status.GetMakefile().AddCacheDefinition(
|
||||
args.front(), result.c_str(), "",
|
||||
args.front(), result, "",
|
||||
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
|
||||
} else {
|
||||
if (!programArgs.empty() && !storeArgs.empty()) {
|
||||
|
||||
@@ -446,8 +446,8 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
|
||||
cmSystemTools::GetShortPath(makeProgram, makeProgram);
|
||||
cmSystemTools::SplitProgramPath(makeProgram, dir, file);
|
||||
makeProgram = cmStrCat(dir, '/', saveFile);
|
||||
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
|
||||
"make program", cmStateEnums::FILEPATH);
|
||||
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram, "make program",
|
||||
cmStateEnums::FILEPATH);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
|
||||
/* store the full toolset for later use
|
||||
* -- already done if -T<toolset> was specified
|
||||
*/
|
||||
mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp.c_str(),
|
||||
mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp,
|
||||
"Location of generator toolset.",
|
||||
cmStateEnums::INTERNAL);
|
||||
}
|
||||
@@ -113,8 +113,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
|
||||
}
|
||||
|
||||
/* store the toolset that is being used for this build */
|
||||
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
|
||||
"build program to use", cmStateEnums::INTERNAL, true);
|
||||
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild, "build program to use",
|
||||
cmStateEnums::INTERNAL, true);
|
||||
|
||||
mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsp);
|
||||
|
||||
@@ -133,7 +133,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
|
||||
/* store the platform name for later use
|
||||
* -- already done if -A<arch> was specified
|
||||
*/
|
||||
mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch.c_str(),
|
||||
mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch,
|
||||
"Name of generator platform.",
|
||||
cmStateEnums::INTERNAL);
|
||||
} else {
|
||||
@@ -167,7 +167,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
|
||||
if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) {
|
||||
bspName = "sim" + arch;
|
||||
/* write back the calculate name for next time */
|
||||
mf->AddCacheDefinition("GHS_BSP_NAME", bspName.c_str(),
|
||||
mf->AddCacheDefinition("GHS_BSP_NAME", bspName,
|
||||
"Name of GHS target platform.",
|
||||
cmStateEnums::STRING, true);
|
||||
std::string m = cmStrCat(
|
||||
|
||||
@@ -128,7 +128,7 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(
|
||||
// does not know about.
|
||||
std::string extraPath;
|
||||
if (cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH", extraPath)) {
|
||||
mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath.c_str(),
|
||||
mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath,
|
||||
"Saved environment variable CMAKE_MSVCIDE_RUN_PATH",
|
||||
cmStateEnums::STATIC);
|
||||
}
|
||||
|
||||
@@ -317,6 +317,12 @@ public:
|
||||
void AddCacheDefinition(const std::string& name, const char* value,
|
||||
const char* doc, cmStateEnums::CacheEntryType type,
|
||||
bool force = false);
|
||||
void AddCacheDefinition(const std::string& name, const std::string& value,
|
||||
const char* doc, cmStateEnums::CacheEntryType type,
|
||||
bool force = false)
|
||||
{
|
||||
AddCacheDefinition(name, value.c_str(), doc, type, force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a variable definition from the build. This is not valid
|
||||
|
||||
@@ -47,10 +47,10 @@ bool cmProjectCommand(std::vector<std::string> const& args,
|
||||
mf.SetProjectName(projectName);
|
||||
|
||||
mf.AddCacheDefinition(projectName + "_BINARY_DIR",
|
||||
mf.GetCurrentBinaryDirectory().c_str(),
|
||||
mf.GetCurrentBinaryDirectory(),
|
||||
"Value Computed by CMake", cmStateEnums::STATIC);
|
||||
mf.AddCacheDefinition(projectName + "_SOURCE_DIR",
|
||||
mf.GetCurrentSourceDirectory().c_str(),
|
||||
mf.GetCurrentSourceDirectory(),
|
||||
"Value Computed by CMake", cmStateEnums::STATIC);
|
||||
|
||||
mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory());
|
||||
@@ -66,7 +66,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
|
||||
// will work.
|
||||
if (!mf.GetDefinition("CMAKE_PROJECT_NAME") || mf.IsRootMakefile()) {
|
||||
mf.AddDefinition("CMAKE_PROJECT_NAME", projectName);
|
||||
mf.AddCacheDefinition("CMAKE_PROJECT_NAME", projectName.c_str(),
|
||||
mf.AddCacheDefinition("CMAKE_PROJECT_NAME", projectName,
|
||||
"Value Computed by CMake", cmStateEnums::STATIC);
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name,
|
||||
// CMakeLists.txt file, then go with the last one.
|
||||
if (!mf.GetDefinition(name) || mf.IsRootMakefile()) {
|
||||
mf.AddDefinition(name, value);
|
||||
mf.AddCacheDefinition(name, value.c_str(), "Value Computed by CMake",
|
||||
mf.AddCacheDefinition(name, value, "Value Computed by CMake",
|
||||
cmStateEnums::STATIC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +149,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 (cache) {
|
||||
status.GetMakefile().AddCacheDefinition(variable, value.c_str(), docstring,
|
||||
type, force);
|
||||
status.GetMakefile().AddCacheDefinition(variable, value, docstring, type,
|
||||
force);
|
||||
} else {
|
||||
// add the definition
|
||||
status.GetMakefile().AddDefinition(variable, value);
|
||||
|
||||
@@ -72,8 +72,7 @@ bool cmSiteNameCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
#endif
|
||||
status.GetMakefile().AddCacheDefinition(
|
||||
args[0], siteName.c_str(),
|
||||
"Name of the computer/site where compile is being run",
|
||||
args[0], siteName, "Name of the computer/site where compile is being run",
|
||||
cmStateEnums::STRING);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1007,7 +1007,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib,
|
||||
dependencies += ";";
|
||||
dependencies += lib;
|
||||
dependencies += ";";
|
||||
mf.AddCacheDefinition(targetEntry, dependencies.c_str(),
|
||||
mf.AddCacheDefinition(targetEntry, dependencies,
|
||||
"Dependencies for the target", cmStateEnums::STATIC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,15 +102,15 @@ bool cmUtilitySourceCommand(std::vector<std::string> const& args,
|
||||
cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
|
||||
|
||||
// Enter the value into the cache.
|
||||
status.GetMakefile().AddCacheDefinition(
|
||||
cacheEntry, utilityExecutable.c_str(), "Path to an internal program.",
|
||||
cmStateEnums::FILEPATH);
|
||||
status.GetMakefile().AddCacheDefinition(cacheEntry, utilityExecutable,
|
||||
"Path to an internal program.",
|
||||
cmStateEnums::FILEPATH);
|
||||
// add a value into the cache that maps from the
|
||||
// full path to the name of the project
|
||||
cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
|
||||
status.GetMakefile().AddCacheDefinition(
|
||||
utilityExecutable, utilityName.c_str(), "Executable to project name.",
|
||||
cmStateEnums::INTERNAL);
|
||||
status.GetMakefile().AddCacheDefinition(utilityExecutable, utilityName,
|
||||
"Executable to project name.",
|
||||
cmStateEnums::INTERNAL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user