summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-04-02 15:20:12 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-04-02 15:20:46 (GMT)
commite95d274f3031180103ee8c88f51432c8d93a5a02 (patch)
treebc4e03e2b8d0a2004bf3ef8f9e9feea0fc002e71 /Source
parent525bd2d5e6b6fef64f7eeee0df331e19f94d9298 (diff)
parentaba23c747b4a7fb342ae77d67b8b5cfbe9a67c8c (diff)
downloadCMake-e95d274f3031180103ee8c88f51432c8d93a5a02.zip
CMake-e95d274f3031180103ee8c88f51432c8d93a5a02.tar.gz
CMake-e95d274f3031180103ee8c88f51432c8d93a5a02.tar.bz2
Merge topic 'cmprop-makefile'
aba23c747b cmMakefile::GetProperty: return cmProp Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4559
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx4
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx8
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx4
-rw-r--r--Source/cmGetPropertyCommand.cxx3
-rw-r--r--Source/cmGlobalGenerator.cxx8
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx6
-rw-r--r--Source/cmLocalGenerator.cxx17
-rw-r--r--Source/cmLocalNinjaGenerator.cxx11
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx8
-rw-r--r--Source/cmMakefile.cxx74
-rw-r--r--Source/cmMakefile.h9
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
-rw-r--r--Source/cmQtAutoGenInitializer.cxx17
-rw-r--r--Source/cmSourceFile.cxx4
-rw-r--r--Source/cmTest.cxx4
-rw-r--r--Source/cmVariableWatchCommand.cxx2
17 files changed, 104 insertions, 87 deletions
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 737b0e5..1c5bcaa 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -754,11 +754,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
emmited.clear();
for (const auto& lgen : this->GlobalGenerator->GetLocalGenerators()) {
- if (const char* cdefs =
+ if (cmProp cdefs =
lgen->GetMakefile()->GetProperty("COMPILE_DEFINITIONS")) {
// Expand the list.
std::vector<std::string> defs;
- cmGeneratorExpression::Split(cdefs, defs);
+ cmGeneratorExpression::Split(*cdefs, defs);
for (std::string const& d : defs) {
if (cmGeneratorExpression::Find(d) != std::string::npos) {
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index 4a9509b..0480876 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -23,13 +23,13 @@ bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
std::string output = "NOTFOUND";
if (args[1] == "VARIABLES") {
- if (const char* varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
- output = varsProp;
+ if (cmProp varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
+ output = *varsProp;
}
} else if (args[1] == "MACROS") {
output.clear();
- if (const char* macrosProp = status.GetMakefile().GetProperty("MACROS")) {
- output = macrosProp;
+ if (cmProp macrosProp = status.GetMakefile().GetProperty("MACROS")) {
+ output = *macrosProp;
}
} else if (args[1] == "COMPONENTS") {
const std::set<std::string>* components =
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 65b3457..2833977 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -85,7 +85,9 @@ bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
break;
}
}
- prop = dir->GetProperty(*i);
+ if (cmProp p = dir->GetProperty(*i)) {
+ prop = p->c_str();
+ }
}
StoreResult(status.GetMakefile(), variable, prop);
return true;
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index c704803..c3ac672 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -289,8 +289,9 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
}
// Get the property.
+ cmProp p = mf->GetProperty(propertyName);
return StoreResult(infoType, status.GetMakefile(), variable,
- mf->GetProperty(propertyName));
+ p ? p->c_str() : nullptr);
}
bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 152e294..ccbbf53 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1678,8 +1678,8 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
for (std::string const& c : configs) {
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(c));
- if (const char* val = mf->GetProperty(defPropName)) {
- t->AppendProperty(defPropName, val);
+ if (cmProp val = mf->GetProperty(defPropName)) {
+ t->AppendProperty(defPropName, *val);
}
}
}
@@ -3034,7 +3034,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
#ifndef CMAKE_BOOTSTRAP
// Check whether labels are enabled for this target.
const char* targetLabels = target->GetProperty("LABELS");
- const char* directoryLabels =
+ cmProp directoryLabels =
target->Target->GetMakefile()->GetProperty("LABELS");
const char* cmakeDirectoryLabels =
target->Target->GetMakefile()->GetDefinition("CMAKE_DIRECTORY_LABELS");
@@ -3068,7 +3068,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
std::vector<std::string> cmakeDirectoryLabelsList;
if (directoryLabels) {
- cmExpandList(directoryLabels, directoryLabelsList);
+ cmExpandList(*directoryLabels, directoryLabelsList);
}
if (cmakeDirectoryLabels) {
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 9a9900a..4b8010a 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -526,8 +526,8 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
extensibilityAddInsOverridden = true;
}
fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
- std::vector<std::string> keyValuePairs =
- cmExpandedList(root->GetMakefile()->GetProperty(it));
+ cmProp p = root->GetMakefile()->GetProperty(it);
+ std::vector<std::string> keyValuePairs = cmExpandedList(p ? *p : "");
for (std::string const& itPair : keyValuePairs) {
const std::string::size_type posEqual = itPair.find('=');
if (posEqual != std::string::npos) {
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 1ec1559..d2f9760 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -507,9 +507,9 @@ std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(
std::string cmGlobalVisualStudioGenerator::GetStartupProjectName(
cmLocalGenerator const* root) const
{
- const char* n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT");
- if (n && *n) {
- std::string startup = n;
+ cmProp n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT");
+ if (n && !n->empty()) {
+ std::string startup = *n;
if (this->FindTarget(startup)) {
return startup;
} else {
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 55f61ea..a80bc7c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -301,16 +301,14 @@ void cmLocalGenerator::GenerateTestFiles()
"# testing this directory and lists subdirectories to "
"be tested as well.\n";
- const char* testIncludeFile =
- this->Makefile->GetProperty("TEST_INCLUDE_FILE");
+ cmProp testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE");
if (testIncludeFile) {
- fout << "include(\"" << testIncludeFile << "\")\n";
+ fout << "include(\"" << *testIncludeFile << "\")\n";
}
- const char* testIncludeFiles =
- this->Makefile->GetProperty("TEST_INCLUDE_FILES");
+ cmProp testIncludeFiles = this->Makefile->GetProperty("TEST_INCLUDE_FILES");
if (testIncludeFiles) {
- std::vector<std::string> includesList = cmExpandedList(testIncludeFiles);
+ std::vector<std::string> includesList = cmExpandedList(*testIncludeFiles);
for (std::string const& i : includesList) {
fout << "include(\"" << i << "\")\n";
}
@@ -335,12 +333,12 @@ void cmLocalGenerator::GenerateTestFiles()
// Add directory labels property
const char* directoryLabels =
this->Makefile->GetDefinition("CMAKE_DIRECTORY_LABELS");
- const char* labels = this->Makefile->GetProperty("LABELS");
+ cmProp labels = this->Makefile->GetProperty("LABELS");
if (labels || directoryLabels) {
fout << "set_directory_properties(PROPERTIES LABELS ";
if (labels) {
- fout << cmOutputConverter::EscapeForCMake(labels);
+ fout << cmOutputConverter::EscapeForCMake(*labels);
}
if (labels && directoryLabels) {
fout << ";";
@@ -775,7 +773,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
if (target) {
return target->GetProperty(prop);
}
- return this->Makefile->GetProperty(prop);
+ cmProp p = this->Makefile->GetProperty(prop);
+ return p ? p->c_str() : nullptr;
}
std::string cmLocalGenerator::ConvertToIncludeReference(
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index e62371d..d1944a4 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -628,10 +628,9 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements(
std::string cmLocalNinjaGenerator::MakeCustomLauncher(
cmCustomCommandGenerator const& ccg)
{
- const char* property_value =
- this->Makefile->GetProperty("RULE_LAUNCH_CUSTOM");
+ cmProp property_value = this->Makefile->GetProperty("RULE_LAUNCH_CUSTOM");
- if (!property_value || !*property_value) {
+ if (!property_value || property_value->empty()) {
return std::string();
}
@@ -653,7 +652,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander());
- std::string launcher = property_value;
+ std::string launcher = *property_value;
rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars);
if (!launcher.empty()) {
launcher += " ";
@@ -664,11 +663,11 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
void cmLocalNinjaGenerator::AdditionalCleanFiles(const std::string& config)
{
- if (const char* prop_value =
+ if (cmProp prop_value =
this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) {
std::vector<std::string> cleanFiles;
{
- cmExpandList(cmGeneratorExpression::Evaluate(prop_value, this, config),
+ cmExpandList(cmGeneratorExpression::Evaluate(*prop_value, this, config),
cleanFiles);
}
std::string const& binaryDir = this->GetCurrentBinaryDirectory();
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 593a6d9..99428bc 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1099,10 +1099,10 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand(
{
std::vector<std::string> cleanFiles;
// Look for additional files registered for cleaning in this directory.
- if (const char* prop_value =
+ if (cmProp prop_value =
this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) {
cmExpandList(cmGeneratorExpression::Evaluate(
- prop_value, this,
+ *prop_value, this,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")),
cleanFiles);
}
@@ -1889,9 +1889,9 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
// Store include transform rule properties. Write the directory
// rules first because they may be overridden by later target rules.
std::vector<std::string> transformRules;
- if (const char* xform =
+ if (cmProp xform =
this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
- cmExpandList(xform, transformRules);
+ cmExpandList(*xform, transformRules);
}
if (const char* xform =
target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index af6b44e..69f316d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1391,9 +1391,9 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
const char* define = def.c_str() + 2;
if (remove) {
- if (const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS")) {
+ if (cmProp cdefs = this->GetProperty("COMPILE_DEFINITIONS")) {
// Expand the list.
- std::vector<std::string> defs = cmExpandedList(cdefs);
+ std::vector<std::string> defs = cmExpandedList(*cdefs);
// Recompose the list without the definition.
auto defEnd = std::remove(defs.begin(), defs.end(), define);
@@ -1422,29 +1422,32 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
// Include transform property. There is no per-config version.
{
const char* prop = "IMPLICIT_DEPENDS_INCLUDE_TRANSFORM";
- this->SetProperty(prop, parent->GetProperty(prop));
+ cmProp p = parent->GetProperty(prop);
+ this->SetProperty(prop, p ? p->c_str() : nullptr);
}
// compile definitions property and per-config versions
cmPolicies::PolicyStatus polSt = this->GetPolicyStatus(cmPolicies::CMP0043);
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
- this->SetProperty("COMPILE_DEFINITIONS",
- parent->GetProperty("COMPILE_DEFINITIONS"));
+ cmProp p = parent->GetProperty("COMPILE_DEFINITIONS");
+ this->SetProperty("COMPILE_DEFINITIONS", p ? p->c_str() : nullptr);
std::vector<std::string> configs;
this->GetConfigurations(configs);
for (std::string const& config : configs) {
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
- const char* prop = parent->GetProperty(defPropName);
- this->SetProperty(defPropName, prop);
+ cmProp prop = parent->GetProperty(defPropName);
+ this->SetProperty(defPropName, prop ? prop->c_str() : nullptr);
}
}
// labels
- this->SetProperty("LABELS", parent->GetProperty("LABELS"));
+ cmProp p = parent->GetProperty("LABELS");
+ this->SetProperty("LABELS", p ? p->c_str() : nullptr);
// link libraries
- this->SetProperty("LINK_LIBRARIES", parent->GetProperty("LINK_LIBRARIES"));
+ p = parent->GetProperty("LINK_LIBRARIES");
+ this->SetProperty("LINK_LIBRARIES", p ? p->c_str() : nullptr);
// the initial project name
this->StateSnapshot.SetProjectName(parent->StateSnapshot.GetProjectName());
@@ -2006,8 +2009,8 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
default:;
}
- if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
- std::vector<std::string> linkLibs = cmExpandedList(linkLibsProp);
+ if (cmProp linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
+ std::vector<std::string> linkLibs = cmExpandedList(*linkLibsProp);
for (auto j = linkLibs.begin(); j != linkLibs.end(); ++j) {
std::string libraryName = *j;
@@ -2451,14 +2454,14 @@ void cmMakefile::ExpandVariablesCMP0019()
}
std::ostringstream w;
- const char* includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
- if (mightExpandVariablesCMP0019(includeDirs)) {
- std::string dirs = includeDirs;
+ cmProp includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
+ if (includeDirs && mightExpandVariablesCMP0019(includeDirs->c_str())) {
+ std::string dirs = *includeDirs;
this->ExpandVariablesInString(dirs, true, true);
- if (pol == cmPolicies::WARN && dirs != includeDirs) {
+ if (pol == cmPolicies::WARN && dirs != *includeDirs) {
/* clang-format off */
w << "Evaluated directory INCLUDE_DIRECTORIES\n"
- << " " << includeDirs << "\n"
+ << " " << *includeDirs << "\n"
<< "as\n"
<< " " << dirs << "\n";
/* clang-format on */
@@ -2473,14 +2476,14 @@ void cmMakefile::ExpandVariablesCMP0019()
t.GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
- cmProp includeDirs2 = t.GetProperty("INCLUDE_DIRECTORIES");
- if (includeDirs2 && mightExpandVariablesCMP0019(includeDirs2->c_str())) {
- std::string dirs = *includeDirs2;
+ includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
+ if (includeDirs && mightExpandVariablesCMP0019(includeDirs->c_str())) {
+ std::string dirs = *includeDirs;
this->ExpandVariablesInString(dirs, true, true);
- if (pol == cmPolicies::WARN && dirs != *includeDirs2) {
+ if (pol == cmPolicies::WARN && dirs != *includeDirs) {
/* clang-format off */
w << "Evaluated target " << t.GetName() << " INCLUDE_DIRECTORIES\n"
- << " " << *includeDirs2 << "\n"
+ << " " << *includeDirs << "\n"
<< "as\n"
<< " " << dirs << "\n";
/* clang-format on */
@@ -2489,9 +2492,9 @@ void cmMakefile::ExpandVariablesCMP0019()
}
}
- if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
- if (mightExpandVariablesCMP0019(linkDirsProp)) {
- std::string d = linkDirsProp;
+ if (cmProp linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
+ if (mightExpandVariablesCMP0019(linkDirsProp->c_str())) {
+ std::string d = *linkDirsProp;
const std::string orig = d;
this->ExpandVariablesInString(d, true, true);
if (pol == cmPolicies::WARN && d != orig) {
@@ -2505,8 +2508,8 @@ void cmMakefile::ExpandVariablesCMP0019()
}
}
- if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
- std::vector<std::string> linkLibs = cmExpandedList(linkLibsProp);
+ if (cmProp linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
+ std::vector<std::string> linkLibs = cmExpandedList(*linkLibsProp);
for (auto l = linkLibs.begin(); l != linkLibs.end(); ++l) {
std::string libName = *l;
@@ -4084,7 +4087,7 @@ void cmMakefile::AppendProperty(const std::string& prop,
this->Backtrace);
}
-const char* cmMakefile::GetProperty(const std::string& prop) const
+cmProp cmMakefile::GetProperty(const std::string& prop) const
{
// Check for computed properties.
static std::string output;
@@ -4097,22 +4100,21 @@ const char* cmMakefile::GetProperty(const std::string& prop) const
return pair.first;
});
output = cmJoin(keys, ";");
- return output.c_str();
+ return &output;
}
- cmProp retVal = this->StateSnapshot.GetDirectory().GetProperty(prop);
- return retVal ? retVal->c_str() : nullptr;
+ return this->StateSnapshot.GetDirectory().GetProperty(prop);
}
-const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const
+cmProp cmMakefile::GetProperty(const std::string& prop, bool chain) const
{
- cmProp retVal = this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
- return retVal ? retVal->c_str() : nullptr;
+ return this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
}
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
{
- return cmIsOn(this->GetProperty(prop));
+ cmProp p = this->GetProperty(prop);
+ return p && cmIsOn(*p);
}
std::vector<std::string> cmMakefile::GetPropertyKeys() const
@@ -4164,8 +4166,8 @@ void cmMakefile::GetTests(const std::string& config,
void cmMakefile::AddCMakeDependFilesFromUser()
{
std::vector<std::string> deps;
- if (const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) {
- cmExpandList(deps_str, deps);
+ if (cmProp deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) {
+ cmExpandList(*deps_str, deps);
}
for (std::string const& dep : deps) {
if (cmSystemTools::FileIsFullPath(dep)) {
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index d628681..9a7eff9 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -58,6 +58,8 @@ class cmTestGenerator;
class cmVariableWatch;
class cmake;
+using cmProp = const std::string*;
+
/** Flag if byproducts shall also be considered. */
enum class cmSourceOutputKind
{
@@ -417,7 +419,8 @@ public:
}
const char* GetIncludeRegularExpression() const
{
- return this->GetProperty("INCLUDE_REGULAR_EXPRESSION");
+ cmProp p = this->GetProperty("INCLUDE_REGULAR_EXPRESSION");
+ return p ? p->c_str() : nullptr;
}
/**
@@ -795,8 +798,8 @@ public:
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false);
- const char* GetProperty(const std::string& prop) const;
- const char* GetProperty(const std::string& prop, bool chain) const;
+ cmProp GetProperty(const std::string& prop) const;
+ cmProp GetProperty(const std::string& prop, bool chain) const;
bool GetPropertyAsBool(const std::string& prop) const;
std::vector<std::string> GetPropertyKeys() const;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4fb84ee..f687289 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -164,9 +164,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
};
// Look for additional files registered for cleaning in this directory.
- if (const char* prop_value =
+ if (cmProp prop_value =
this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) {
- std::vector<std::string> const files = evaluatedFiles(prop_value);
+ std::vector<std::string> const files = evaluatedFiles(*prop_value);
this->CleanFiles.insert(files.begin(), files.end());
}
@@ -183,8 +183,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
}
// add custom commands to the clean rules?
- const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
- bool clean = cmIsOff(clean_no_custom);
+ cmProp clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
+ bool clean = clean_no_custom ? cmIsOff(*clean_no_custom) : true;
// First generate the object rule files. Save a list of all object
// files for this target.
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index dddba0a..a5af810 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1670,6 +1670,13 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
}
return 0u;
};
+ auto toUInt2 = [](cmProp input) -> unsigned int {
+ unsigned long tmp = 0;
+ if (input != nullptr && cmStrToULong(*input, &tmp)) {
+ return static_cast<unsigned int>(tmp);
+ }
+ return 0u;
+ };
// Initialize return value to a default
std::pair<IntegerVersion, unsigned int> res(
@@ -1691,9 +1698,9 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
knownQtVersions.reserve(keys.size() * 2);
// Adds a version to the result (nullptr safe)
- auto addVersion = [&knownQtVersions, &toUInt](const char* major,
- const char* minor) {
- cmQtAutoGen::IntegerVersion ver(toUInt(major), toUInt(minor));
+ auto addVersion = [&knownQtVersions, &toUInt2](cmProp major,
+ cmProp minor) {
+ cmQtAutoGen::IntegerVersion ver(toUInt2(major), toUInt2(minor));
if (ver.Major != 0) {
knownQtVersions.emplace_back(ver);
}
@@ -1701,8 +1708,8 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
// Read versions from variables
for (auto const& keyPair : keys) {
- addVersion(target->Makefile->GetDefinition(std::string(keyPair.first)),
- target->Makefile->GetDefinition(std::string(keyPair.second)));
+ addVersion(target->Makefile->GetDef(std::string(keyPair.first)),
+ target->Makefile->GetDef(std::string(keyPair.second)));
}
// Read versions from directory properties
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 5dc8b05..ad59cd6 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -367,7 +367,9 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
const bool chain =
mf->GetState()->IsPropertyChained(prop, cmProperty::SOURCE_FILE);
if (chain) {
- return mf->GetProperty(prop, chain);
+ if (cmProp p = mf->GetProperty(prop, chain)) {
+ return p->c_str();
+ }
}
return nullptr;
}
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 56c441a..a26bef3 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -39,7 +39,9 @@ const char* cmTest::GetProperty(const std::string& prop) const
const bool chain =
this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
if (chain) {
- return this->Makefile->GetProperty(prop, chain);
+ if (cmProp p = this->Makefile->GetProperty(prop, chain)) {
+ return p->c_str();
+ }
}
return nullptr;
}
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 35b9a1d..ecae16d 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -42,7 +42,7 @@ void cmVariableWatchCommandVariableAccessed(const std::string& variable,
/// Ultra bad!!
cmMakefile* makefile = const_cast<cmMakefile*>(mf);
- std::string stack = makefile->GetProperty("LISTFILE_STACK");
+ std::string stack = *mf->GetProperty("LISTFILE_STACK");
if (!data->Command.empty()) {
cmListFileFunction newLFF;
const char* const currentListFile =