Merge topic 'stdstring-target'

c34b4497f8 cmTarget: add std::string overloads

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4137
This commit is contained in:
Brad King
2019-12-17 16:08:06 +00:00
committed by Kitware Robot
19 changed files with 51 additions and 52 deletions

View File

@@ -49,7 +49,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
if (te->ArchiveGenerator) {
dest = te->ArchiveGenerator->GetDestination("");
}
te->Target->Target->SetProperty("__dest", dest.c_str());
te->Target->Target->SetProperty("__dest", dest);
}
}

View File

@@ -113,7 +113,7 @@ void cmGhsMultiTargetGenerator::Generate()
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
this->Name.c_str());
this->Name);
this->GeneratorTarget->Target->SetProperty(
"GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));

View File

@@ -2668,7 +2668,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
cc.SetUsesTerminal(gti.UsesTerminal);
target.AddPostBuildCommand(std::move(cc));
if (!gti.Message.empty()) {
target.SetProperty("EchoString", gti.Message.c_str());
target.SetProperty("EchoString", gti.Message);
}
for (std::string const& d : gti.Depends) {
target.AddUtility(d);

View File

@@ -83,22 +83,21 @@ bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
}
// Create a target instance for this utility.
cmTarget* target =
mf.AddNewTarget(cmStateEnums::UTILITY, utility_name.c_str());
cmTarget* target = mf.AddNewTarget(cmStateEnums::UTILITY, utility_name);
if (mf.GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
target->SetProperty("GENERATOR_FILE_NAME", utility_name);
target->SetProperty("EXTERNAL_MSPROJECT", path);
if (!customType.empty())
target->SetProperty("VS_PROJECT_TYPE", customType.c_str());
target->SetProperty("VS_PROJECT_TYPE", customType);
if (!platformMapping.empty())
target->SetProperty("VS_PLATFORM_MAPPING", platformMapping.c_str());
target->SetProperty("VS_PLATFORM_MAPPING", platformMapping);
for (std::string const& d : depends) {
target->AddUtility(d.c_str());
target->AddUtility(d);
}
}
#endif

View File

@@ -2551,7 +2551,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
}
target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
target_compile_pdb_dir.c_str());
target_compile_pdb_dir);
}
std::string pchSourceObj =
@@ -2560,8 +2560,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
// Link to the pch object file
target->Target->AppendProperty(
"LINK_FLAGS",
cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL))
.c_str(),
cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL)),
true);
}
} else {

View File

@@ -194,7 +194,7 @@ void cmLocalVisualStudio7Generator::CreateSingleVCProj(
}
// add to the list of projects
target->Target->SetProperty("GENERATOR_FILE_NAME", lname.c_str());
target->Target->SetProperty("GENERATOR_FILE_NAME", lname);
// create the dsp.cmake file
std::string fname;
fname = cmStrCat(this->GetCurrentBinaryDirectory(), '/', lname);

View File

@@ -1939,7 +1939,7 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
target.AddLinkLibrary(*this, libraryName, libType);
target.AppendProperty(
"INTERFACE_LINK_LIBRARIES",
target.GetDebugGeneratorExpressions(libraryName, libType).c_str());
target.GetDebugGeneratorExpressions(libraryName, libType));
}
}
}
@@ -2399,7 +2399,7 @@ void cmMakefile::ExpandVariablesCMP0019()
<< " " << dirs << "\n";
/* clang-format on */
}
t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
t.SetProperty("INCLUDE_DIRECTORIES", dirs);
}
}
@@ -4550,7 +4550,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
std::string* error) const
{
if (cmGeneratorExpression::Find(feature) != std::string::npos) {
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
target->AppendProperty("COMPILE_FEATURES", feature);
return true;
}
@@ -4581,7 +4581,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
return false;
}
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
target->AppendProperty("COMPILE_FEATURES", feature);
if (lang == "C" || lang == "OBJC") {
return this->AddRequiredTargetCFeature(target, feature, lang, error);

View File

@@ -1147,7 +1147,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// Set FOLDER property in autogen target
if (!this->TargetsFolder.empty()) {
autogenTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
autogenTarget->SetProperty("FOLDER", this->TargetsFolder);
}
// Add autogen target to the origin target dependencies
@@ -1216,7 +1216,7 @@ bool cmQtAutoGenInitializer::InitRccTargets()
// Set FOLDER property in autogen target
if (!this->TargetsFolder.empty()) {
autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
autoRccTarget->SetProperty("FOLDER", this->TargetsFolder);
}
if (!this->Rcc.ExecutableTargetName.empty()) {
autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName,
@@ -1528,8 +1528,8 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)
{
this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES",
fileName.c_str(), false);
this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", fileName,
false);
}
void cmQtAutoGenInitializer::ConfigFileNames(ConfigString& configString,

View File

@@ -70,7 +70,7 @@ static bool SetOneTarget(const std::string& tname,
// now loop through all the props and set them
unsigned int k;
for (k = 0; k < propertyPairs.size(); k = k + 2) {
target->SetProperty(propertyPairs[k], propertyPairs[k + 1].c_str());
target->SetProperty(propertyPairs[k], propertyPairs[k + 1]);
target->CheckProperty(propertyPairs[k], mf);
}
}

View File

@@ -951,9 +951,8 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib,
(isNonImportedTarget && llt != GENERAL_LibraryType)
? targetNameGenex(libRef)
: libRef;
this->AppendProperty(
"LINK_LIBRARIES",
this->GetDebugGeneratorExpressions(libName, llt).c_str());
this->AppendProperty("LINK_LIBRARIES",
this->GetDebugGeneratorExpressions(libName, llt));
}
if (cmGeneratorExpression::Find(lib) != std::string::npos || lib != libRef ||
@@ -1287,9 +1286,9 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
impl->Properties.SetProperty(prop, reusedFrom.c_str());
reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom.c_str());
reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom);
reusedTarget->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
cmStrCat(reusedFrom, ".dir/").c_str());
cmStrCat(reusedFrom, ".dir/"));
this->SetProperty("COMPILE_PDB_NAME",
reusedTarget->GetProperty("COMPILE_PDB_NAME"));
@@ -1424,7 +1423,7 @@ void cmTarget::AppendBuildInterfaceIncludes()
dirs += impl->Makefile->GetCurrentSourceDirectory();
if (!dirs.empty()) {
this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES",
("$<BUILD_INTERFACE:" + dirs + ">").c_str());
("$<BUILD_INTERFACE:" + dirs + ">"));
}
}
}

View File

@@ -164,8 +164,17 @@ public:
//! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char* value);
void SetProperty(const std::string& prop, const std::string& value)
{
SetProperty(prop, value.c_str());
}
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false)
{
AppendProperty(prop, value.c_str(), asString);
}
//! 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

View File

@@ -28,7 +28,7 @@ private:
const std::vector<std::string>& content,
bool /*prepend*/, bool /*system*/) override
{
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content));
return true; // Successfully handled.
}

View File

@@ -88,8 +88,7 @@ void TargetIncludeDirectoriesImpl::HandleInterfaceContent(
system);
if (system) {
std::string joined = this->Join(content);
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
joined.c_str());
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", joined);
}
}

View File

@@ -480,7 +480,7 @@ static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
cmGeneratorExpression::Find(lib) != std::string::npos) {
configLib = "$<LINK_ONLY:" + configLib + ">";
}
target->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib.c_str());
target->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib);
}
return true;
}
@@ -488,9 +488,8 @@ static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
// Handle general case where the command was called with another keyword than
// PRIVATE / LINK_PRIVATE or none at all. (The "INTERFACE_LINK_LIBRARIES"
// property of the target on the LHS shall be populated.)
target->AppendProperty(
"INTERFACE_LINK_LIBRARIES",
target->GetDebugGeneratorExpressions(libRef, llt).c_str());
target->AppendProperty("INTERFACE_LINK_LIBRARIES",
target->GetDebugGeneratorExpressions(libRef, llt));
// Stop processing if called without any keyword.
if (currentProcessingState == ProcessingLinkLibraries) {
@@ -522,12 +521,12 @@ static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
// Put in the DEBUG configuration interfaces.
for (std::string const& dc : debugConfigs) {
prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
target->AppendProperty(prop, libRef.c_str());
target->AppendProperty(prop, libRef);
}
}
if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
// Put in the non-DEBUG configuration interfaces.
target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef.c_str());
target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef);
// Make sure the DEBUG configuration interfaces exist so that the
// general one will not be used as a fall-back.

View File

@@ -47,9 +47,8 @@ private:
bool /*prepend*/, bool /*system*/) override
{
std::string const& base = this->Makefile->GetCurrentSourceDirectory();
tgt->AppendProperty(
"PRECOMPILE_HEADERS",
this->Join(ConvertToAbsoluteContent(content, base)).c_str());
tgt->AppendProperty("PRECOMPILE_HEADERS",
this->Join(ConvertToAbsoluteContent(content, base)));
return true;
}

View File

@@ -84,9 +84,7 @@ bool cmTargetPropCommandBase::HandleArguments(
}
++argIndex;
this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM",
args[argIndex].c_str());
this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM", args[argIndex]);
++argIndex;
}
@@ -162,9 +160,8 @@ void cmTargetPropCommandBase::HandleInterfaceContent(
const char* propValue = tgt->GetProperty(propName);
const std::string totalContent = this->Join(content) +
(propValue ? std::string(";") + propValue : std::string());
tgt->SetProperty(propName, totalContent.c_str());
tgt->SetProperty(propName, totalContent);
} else {
tgt->AppendProperty("INTERFACE_" + this->Property,
this->Join(content).c_str());
tgt->AppendProperty("INTERFACE_" + this->Property, this->Join(content));
}
}

View File

@@ -43,8 +43,7 @@ private:
bool /*prepend*/, bool /*system*/) override
{
tgt->AppendProperty(
"SOURCES",
this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str());
"SOURCES", this->Join(ConvertToAbsoluteContent(tgt, content, false)));
return true; // Successfully handled.
}

View File

@@ -334,9 +334,9 @@ void cmVisualStudio10TargetGenerator::Generate()
}
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
this->Name.c_str());
this->Name);
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
ProjectFileExtension.c_str());
ProjectFileExtension);
this->DotNetHintReferences.clear();
this->AdditionalUsingDirectories.clear();
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {

View File

@@ -548,7 +548,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
const char* targetName = "dummy";
std::vector<std::string> srcs;
cmTarget* tgt = mf->AddExecutable(targetName, srcs, true);
tgt->SetProperty("LINKER_LANGUAGE", language.c_str());
tgt->SetProperty("LINKER_LANGUAGE", language);
std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES");
std::vector<std::string> libList = cmExpandedList(libs);