Autogen: Use default and remove custom GetSafeProperty functions

This commit is contained in:
Sebastian Holtermann
2018-07-02 12:53:44 +02:00
parent 127094f2f0
commit 42cc0644d5

View File

@@ -42,18 +42,6 @@ inline static const char* SafeString(const char* value)
return (value != nullptr) ? 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 GetParallelCPUCount()
{ {
static std::size_t count = 0; static std::size_t count = 0;
@@ -249,7 +237,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
cmSystemTools::ConvertToUnixSlashes(this->DirInfo); cmSystemTools::ConvertToUnixSlashes(this->DirInfo);
// Autogen build dir // Autogen build dir
this->DirBuild = GetSafeProperty(this->Target, "AUTOGEN_BUILD_DIR"); this->DirBuild = this->Target->GetSafeProperty("AUTOGEN_BUILD_DIR");
if (this->DirBuild.empty()) { if (this->DirBuild.empty()) {
this->DirBuild = cbd; this->DirBuild = cbd;
this->DirBuild += '/'; this->DirBuild += '/';
@@ -281,7 +269,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
} }
// Inherit FOLDER property from target (#13688) // Inherit FOLDER property from target (#13688)
if (folder == nullptr) { if (folder == nullptr) {
folder = SafeString(this->Target->Target->GetProperty("FOLDER")); folder = this->Target->GetProperty("FOLDER");
} }
if (folder != nullptr) { if (folder != nullptr) {
this->AutogenFolder = folder; this->AutogenFolder = folder;
@@ -432,7 +420,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
qrc.Generated = sf->GetPropertyAsBool("GENERATED"); qrc.Generated = sf->GetPropertyAsBool("GENERATED");
// RCC options // RCC options
{ {
std::string const opts = GetSafeProperty(sf, "AUTORCC_OPTIONS"); std::string const opts = sf->GetSafeProperty("AUTORCC_OPTIONS");
if (!opts.empty()) { if (!opts.empty()) {
cmSystemTools::ExpandListArgument(opts, qrc.Options); cmSystemTools::ExpandListArgument(opts, qrc.Options);
} }
@@ -568,7 +556,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
// Target rcc options // Target rcc options
std::vector<std::string> optionsTarget; std::vector<std::string> optionsTarget;
cmSystemTools::ExpandListArgument( cmSystemTools::ExpandListArgument(
GetSafeProperty(this->Target, "AUTORCC_OPTIONS"), optionsTarget); this->Target->GetSafeProperty("AUTORCC_OPTIONS"), optionsTarget);
// Check if file name is unique // Check if file name is unique
for (Qrc& qrc : this->Qrcs) { for (Qrc& qrc : this->Qrcs) {
@@ -734,7 +722,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
// Add user defined autogen target dependencies // Add user defined autogen target dependencies
{ {
std::string const deps = std::string const deps =
GetSafeProperty(this->Target, "AUTOGEN_TARGET_DEPENDS"); this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
if (!deps.empty()) { if (!deps.empty()) {
std::vector<std::string> extraDeps; std::vector<std::string> extraDeps;
cmSystemTools::ExpandListArgument(deps, extraDeps); cmSystemTools::ExpandListArgument(deps, extraDeps);
@@ -907,7 +895,7 @@ void cmQtAutoGenInitializer::SetupCustomTargets()
} }
// Parallel processing // Parallel processing
this->Parallel = GetSafeProperty(this->Target, "AUTOGEN_PARALLEL"); this->Parallel = this->Target->GetSafeProperty("AUTOGEN_PARALLEL");
if (this->Parallel.empty() || (this->Parallel == "AUTO")) { if (this->Parallel.empty() || (this->Parallel == "AUTO")) {
// Autodetect number of CPUs // Autodetect number of CPUs
this->Parallel = std::to_string(GetParallelCPUCount()); this->Parallel = std::to_string(GetParallelCPUCount());
@@ -1000,12 +988,12 @@ void cmQtAutoGenInitializer::SetupCustomTargets()
CWrite("AM_MOC_INCLUDES", this->MocIncludes); CWrite("AM_MOC_INCLUDES", this->MocIncludes);
CWriteMap("AM_MOC_INCLUDES", this->MocIncludesConfig); CWriteMap("AM_MOC_INCLUDES", this->MocIncludesConfig);
CWrite("AM_MOC_OPTIONS", 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_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE"));
CWrite("AM_MOC_MACRO_NAMES", CWrite("AM_MOC_MACRO_NAMES",
GetSafeProperty(this->Target, "AUTOMOC_MACRO_NAMES")); this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES"));
CWrite("AM_MOC_DEPEND_FILTERS", CWrite("AM_MOC_DEPEND_FILTERS",
GetSafeProperty(this->Target, "AUTOMOC_DEPEND_FILTERS")); this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
CWrite("AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); CWrite("AM_MOC_PREDEFS_CMD", this->MocPredefsCmd);
} }
@@ -1182,7 +1170,7 @@ void cmQtAutoGenInitializer::SetupCustomTargetsUic()
// Uic search paths // Uic search paths
{ {
std::string const usp = std::string const usp =
GetSafeProperty(this->Target, "AUTOUIC_SEARCH_PATHS"); this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
if (!usp.empty()) { if (!usp.empty()) {
cmSystemTools::ExpandListArgument(usp, this->UicSearchPaths); cmSystemTools::ExpandListArgument(usp, this->UicSearchPaths);
std::string const srcDir = makefile->GetCurrentSourceDirectory(); std::string const srcDir = makefile->GetCurrentSourceDirectory();
@@ -1231,7 +1219,7 @@ void cmQtAutoGenInitializer::SetupCustomTargetsUic()
this->UicSkip.insert(absFile); this->UicSkip.insert(absFile);
} }
// Check if the .ui file has uic options // 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()) { if (!uicOpts.empty()) {
// Check if file isn't skipped // Check if file isn't skipped
if (this->UicSkip.count(absFile) == 0) { if (this->UicSkip.count(absFile) == 0) {