diff options
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 13 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.cxx | 6 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 9 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 10 | ||||
-rw-r--r-- | Source/cmTarget.h | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmXCodeScheme.cxx | 5 |
12 files changed, 36 insertions, 28 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 6c1a476..5414409 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -77,7 +77,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( cmOutputConverter::FortranFormat format = cmOutputConverter::GetFortranFormat(srcfmt); if (format == cmOutputConverter::FortranFormatNone) { - const std::string tgtfmt = + std::string const& tgtfmt = this->GeneratorTarget->GetSafeProperty("Fortran_FORMAT"); format = cmOutputConverter::GetFortranFormat(tgtfmt); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 509df93..62f4d3e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -388,14 +388,16 @@ cmProp cmGeneratorTarget::GetProperty(const std::string& prop) const return this->Target->GetProperty(prop); } -const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const +std::string const& cmGeneratorTarget::GetSafeProperty( + std::string const& prop) const { cmProp ret = this->GetProperty(prop); - if (!ret) { - return ""; + if (ret) { + return *ret; } - return ret->c_str(); + static std::string const s_empty; + return s_empty; } const char* cmGeneratorTarget::GetOutputTargetType( @@ -3988,7 +3990,8 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions( const std::string useOptVar = cmStrCat(language, "_COMPILE_OPTIONS_USE_PCH"); - const std::string useOptionListProperty = this->GetSafeProperty(useOptVar); + std::string const& useOptionListProperty = + this->GetSafeProperty(useOptVar); useOptionList = cmStrCat( useOptionList, ";", diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index dc98407..2ef7b43 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -80,7 +80,7 @@ public: //! Might return a nullptr if the property is not set or invalid cmProp GetProperty(const std::string& prop) const; //! Always returns a valid pointer - const char* GetSafeProperty(const std::string& prop) const; + std::string const& GetSafeProperty(std::string const& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files, const std::string& config) const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2664fb0..5d42b55 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -384,9 +384,9 @@ bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const } } - const std::string reuseFrom = + std::string const& reuseFrom = target->GetSafeProperty("PRECOMPILE_HEADERS_REUSE_FROM"); - const std::string compilePdb = + std::string const& compilePdb = target->GetSafeProperty("COMPILE_PDB_NAME"); if (!reuseFrom.empty() && reuseFrom != compilePdb) { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 77fa6fa..cda3338 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -808,7 +808,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( // Add flags from target and source file properties. std::string flags; - const std::string srcfmt = sf->GetSafeProperty("Fortran_FORMAT"); + std::string const& srcfmt = sf->GetSafeProperty("Fortran_FORMAT"); switch (cmOutputConverter::GetFortranFormat(srcfmt)) { case cmOutputConverter::FortranFormatFixed: flags = "-fixed " + flags; @@ -2289,7 +2289,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Add Fortran source format attribute if property is set. const char* format = nullptr; - const std::string tgtfmt = gtgt->GetSafeProperty("Fortran_FORMAT"); + std::string const& tgtfmt = gtgt->GetSafeProperty("Fortran_FORMAT"); switch (cmOutputConverter::GetFortranFormat(tgtfmt)) { case cmOutputConverter::FortranFormatFixed: format = "fixed"; @@ -2416,7 +2416,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string attribute = prop.substr(16); this->FilterConfigurationAttribute(configName, attribute); if (!attribute.empty()) { - const std::string pr = gtgt->GetSafeProperty(prop); + std::string const& pr = gtgt->GetSafeProperty(prop); std::string processed = cmGeneratorExpression::Evaluate( pr, this->CurrentLocalGenerator, configName); buildSettings->AddAttribute(attribute, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a2208e5..b862449 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2670,7 +2670,8 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) std::string dest_file = to_file; - const std::string prefix = target->GetSafeProperty("PREFIX"); + std::string const& prefix = + target->GetSafeProperty("PREFIX"); if (!prefix.empty()) { dest_file = cmStrCat(to_dir, prefix, *ReuseFrom, extension); diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 18b135d..a32f3e7 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -95,11 +95,11 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( bool const uic = target->GetPropertyAsBool(kw().AUTOUIC); bool const rcc = target->GetPropertyAsBool(kw().AUTORCC); if (moc || uic || rcc) { - std::string const mocExec = + std::string const& mocExec = target->GetSafeProperty(kw().AUTOMOC_EXECUTABLE); - std::string const uicExec = + std::string const& uicExec = target->GetSafeProperty(kw().AUTOUIC_EXECUTABLE); - std::string const rccExec = + std::string const& rccExec = target->GetSafeProperty(kw().AUTORCC_EXECUTABLE); // We support Qt4, Qt5 and Qt6 diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index fa523cc..235ee38 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -440,7 +440,8 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Autogen target parallel processing { - std::string prop = this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); + std::string const& prop = + this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); if (prop.empty() || (prop == "AUTO")) { // Autodetect number of CPUs this->AutogenTarget.Parallel = GetParallelCPUCount(); @@ -471,7 +472,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() this->AutogenTarget.DependOrigin = this->GenTarget->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS"); - std::string const deps = + std::string const& deps = this->GenTarget->GetSafeProperty("AUTOGEN_TARGET_DEPENDS"); if (!deps.empty()) { for (std::string const& depName : cmExpandedList(deps)) { @@ -654,7 +655,7 @@ bool cmQtAutoGenInitializer::InitUic() { // Uic search paths { - std::string const usp = + std::string const& usp = this->GenTarget->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); if (!usp.empty()) { this->Uic.SearchPaths = @@ -1794,7 +1795,7 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, // Custom executable { std::string const prop = cmStrCat(genVars.GenNameUpper, "_EXECUTABLE"); - std::string const val = this->GenTarget->Target->GetSafeProperty(prop); + std::string const& val = this->GenTarget->Target->GetSafeProperty(prop); if (!val.empty()) { // Evaluate generator expression { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 955a5cc..a776398 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1789,13 +1789,15 @@ cmProp cmTarget::GetProperty(const std::string& prop) const return retVal; } -const char* cmTarget::GetSafeProperty(const std::string& prop) const +std::string const& cmTarget::GetSafeProperty(std::string const& prop) const { cmProp ret = this->GetProperty(prop); - if (!ret) { - return ""; + if (ret) { + return *ret; } - return ret->c_str(); + + static std::string const s_empty; + return s_empty; } bool cmTarget::GetPropertyAsBool(const std::string& prop) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ddc3b9b..8fecd41 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -174,7 +174,7 @@ public: //! Might return a nullptr if the property is not set or invalid cmProp GetProperty(const std::string& prop) const; //! Always returns a valid pointer - const char* GetSafeProperty(const std::string& prop) const; + std::string const& GetSafeProperty(std::string const& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void CheckProperty(const std::string& prop, cmMakefile* context) const; cmProp GetComputedProperty(const std::string& prop, cmMessenger* messenger, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9c2b302..2b20a00 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -909,7 +909,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( void cmVisualStudio10TargetGenerator::WriteDotNetDocumentationFile(Elem& e0) { - std::string const documentationFile = + std::string const& documentationFile = this->GeneratorTarget->GetSafeProperty("VS_DOTNET_DOCUMENTATION_FILE"); if (this->ProjectType == csproj && !documentationFile.empty()) { diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index aab367a..9ac1457 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -405,8 +405,9 @@ void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout, void cmXCodeScheme::WriteCustomWorkingDirectory( cmXMLWriter& xout, const std::string& configuration) { - std::string propertyValue = this->Target->GetTarget()->GetSafeProperty( - "XCODE_SCHEME_WORKING_DIRECTORY"); + std::string const& propertyValue = + this->Target->GetTarget()->GetSafeProperty( + "XCODE_SCHEME_WORKING_DIRECTORY"); if (propertyValue.empty()) { xout.Attribute("useCustomWorkingDirectory", "NO"); } else { |