summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGeneratorTarget.cxx9
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmQtAutoGenInitializer.cxx34
-rw-r--r--Source/cmSourceFile.cxx9
-rw-r--r--Source/cmSourceFile.h3
-rw-r--r--Source/cmTarget.cxx9
-rw-r--r--Source/cmTarget.h3
7 files changed, 47 insertions, 23 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index e07ccd9..3989ebe 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -221,6 +221,15 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
return this->Target->GetProperty(prop);
}
+const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const
+{
+ const char* ret = this->GetProperty(prop);
+ if (!ret) {
+ return "";
+ }
+ return ret;
+}
+
const char* cmGeneratorTarget::GetOutputTargetType(
cmStateEnums::ArtifactType artifact) const
{
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 4cc0aac..6a36116 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -68,7 +68,10 @@ public:
std::string GetExportName() const;
std::vector<std::string> GetPropertyKeys() const;
+ ///! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
+ ///! Always returns a valid pointer
+ const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files,
const std::string& config) const;
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 37155fa..8ede960 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -42,18 +42,6 @@ inline static const char* SafeString(const char* value)
return (value != nullptr) ? value : "";
}
-inline static std::string GetSafeProperty(cmGeneratorTarget const* target,
- const char* key)
-{
- return std::string(SafeString(target->GetProperty(key)));
-}
-
-inline static std::string GetSafeProperty(cmSourceFile const* sf,
- const char* key)
-{
- return std::string(SafeString(sf->GetProperty(key)));
-}
-
static std::size_t GetParallelCPUCount()
{
static std::size_t count = 0;
@@ -249,7 +237,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
cmSystemTools::ConvertToUnixSlashes(this->DirInfo);
// Autogen build dir
- this->DirBuild = GetSafeProperty(this->Target, "AUTOGEN_BUILD_DIR");
+ this->DirBuild = this->Target->GetSafeProperty("AUTOGEN_BUILD_DIR");
if (this->DirBuild.empty()) {
this->DirBuild = cbd;
this->DirBuild += '/';
@@ -281,7 +269,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
}
// Inherit FOLDER property from target (#13688)
if (folder == nullptr) {
- folder = SafeString(this->Target->Target->GetProperty("FOLDER"));
+ folder = this->Target->GetProperty("FOLDER");
}
if (folder != nullptr) {
this->AutogenFolder = folder;
@@ -432,7 +420,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
qrc.Generated = sf->GetPropertyAsBool("GENERATED");
// RCC options
{
- std::string const opts = GetSafeProperty(sf, "AUTORCC_OPTIONS");
+ std::string const opts = sf->GetSafeProperty("AUTORCC_OPTIONS");
if (!opts.empty()) {
cmSystemTools::ExpandListArgument(opts, qrc.Options);
}
@@ -568,7 +556,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
// Target rcc options
std::vector<std::string> optionsTarget;
cmSystemTools::ExpandListArgument(
- GetSafeProperty(this->Target, "AUTORCC_OPTIONS"), optionsTarget);
+ this->Target->GetSafeProperty("AUTORCC_OPTIONS"), optionsTarget);
// Check if file name is unique
for (Qrc& qrc : this->Qrcs) {
@@ -734,7 +722,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
// Add user defined autogen target dependencies
{
std::string const deps =
- GetSafeProperty(this->Target, "AUTOGEN_TARGET_DEPENDS");
+ this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
if (!deps.empty()) {
std::vector<std::string> extraDeps;
cmSystemTools::ExpandListArgument(deps, extraDeps);
@@ -907,7 +895,7 @@ void cmQtAutoGenInitializer::SetupCustomTargets()
}
// Parallel processing
- this->Parallel = GetSafeProperty(this->Target, "AUTOGEN_PARALLEL");
+ this->Parallel = this->Target->GetSafeProperty("AUTOGEN_PARALLEL");
if (this->Parallel.empty() || (this->Parallel == "AUTO")) {
// Autodetect number of CPUs
this->Parallel = std::to_string(GetParallelCPUCount());
@@ -1000,12 +988,12 @@ void cmQtAutoGenInitializer::SetupCustomTargets()
CWrite("AM_MOC_INCLUDES", this->MocIncludes);
CWriteMap("AM_MOC_INCLUDES", this->MocIncludesConfig);
CWrite("AM_MOC_OPTIONS",
- GetSafeProperty(this->Target, "AUTOMOC_MOC_OPTIONS"));
+ this->Target->GetSafeProperty("AUTOMOC_MOC_OPTIONS"));
CWrite("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE"));
CWrite("AM_MOC_MACRO_NAMES",
- GetSafeProperty(this->Target, "AUTOMOC_MACRO_NAMES"));
+ this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES"));
CWrite("AM_MOC_DEPEND_FILTERS",
- GetSafeProperty(this->Target, "AUTOMOC_DEPEND_FILTERS"));
+ this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
CWrite("AM_MOC_PREDEFS_CMD", this->MocPredefsCmd);
}
@@ -1182,7 +1170,7 @@ void cmQtAutoGenInitializer::SetupCustomTargetsUic()
// Uic search paths
{
std::string const usp =
- GetSafeProperty(this->Target, "AUTOUIC_SEARCH_PATHS");
+ this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
if (!usp.empty()) {
cmSystemTools::ExpandListArgument(usp, this->UicSearchPaths);
std::string const srcDir = makefile->GetCurrentSourceDirectory();
@@ -1231,7 +1219,7 @@ void cmQtAutoGenInitializer::SetupCustomTargetsUic()
this->UicSkip.insert(absFile);
}
// Check if the .ui file has uic options
- std::string const uicOpts = GetSafeProperty(sf, "AUTOUIC_OPTIONS");
+ std::string const uicOpts = sf->GetSafeProperty("AUTOUIC_OPTIONS");
if (!uicOpts.empty()) {
// Check if file isn't skipped
if (this->UicSkip.count(absFile) == 0) {
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 6792d66..05e26ea 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -296,6 +296,15 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
return retVal;
}
+const char* cmSourceFile::GetSafeProperty(const std::string& prop) const
+{
+ const char* ret = this->GetProperty(prop);
+ if (!ret) {
+ return "";
+ }
+ return ret;
+}
+
bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 1516d98..ab0f229 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -45,7 +45,10 @@ public:
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
+ ///! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
+ ///! Always returns a valid pointer
+ const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
/** Implement getting a property when called from a CMake language
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1a6e1d1..803a0a9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1412,6 +1412,15 @@ const char* cmTarget::GetProperty(const std::string& prop) const
return retVal;
}
+const char* cmTarget::GetSafeProperty(const std::string& prop) const
+{
+ const char* ret = this->GetProperty(prop);
+ if (!ret) {
+ return "";
+ }
+ return ret;
+}
+
bool cmTarget::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 5f0b33c..7a3ab65 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -200,7 +200,10 @@ public:
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
+ ///! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
+ ///! Always returns a valid pointer
+ const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void CheckProperty(const std::string& prop, cmMakefile* context) const;
const char* GetComputedProperty(const std::string& prop,