summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2020-04-29 15:00:00 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2020-04-29 14:59:39 (GMT)
commit36aba01223cfb28ee574386cd91dbfccc4dc9359 (patch)
tree7acf2fc54b9ddf7a5372cb088eb80cde6764408d /Source/cmGeneratorTarget.cxx
parentd63c442a6bcec287afb32a88c80b68cb141f49f4 (diff)
downloadCMake-36aba01223cfb28ee574386cd91dbfccc4dc9359.zip
CMake-36aba01223cfb28ee574386cd91dbfccc4dc9359.tar.gz
CMake-36aba01223cfb28ee574386cd91dbfccc4dc9359.tar.bz2
cmGeneratorTarget::GetProperty: return cmProp
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx387
1 files changed, 193 insertions, 194 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index fd863a3..509df93 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -356,22 +356,22 @@ const std::string& cmGeneratorTarget::GetName() const
std::string cmGeneratorTarget::GetExportName() const
{
- const char* exportName = this->GetProperty("EXPORT_NAME");
+ cmProp exportName = this->GetProperty("EXPORT_NAME");
- if (exportName && *exportName) {
- if (!cmGeneratorExpression::IsValidTargetName(exportName)) {
+ if (exportName && !exportName->empty()) {
+ if (!cmGeneratorExpression::IsValidTargetName(*exportName)) {
std::ostringstream e;
- e << "EXPORT_NAME property \"" << exportName << "\" for \""
+ e << "EXPORT_NAME property \"" << *exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
cmSystemTools::Error(e.str());
return "";
}
- return exportName;
+ return *exportName;
}
return this->GetName();
}
-const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
+cmProp cmGeneratorTarget::GetProperty(const std::string& prop) const
{
if (!cmTargetPropertyComputer::PassesWhitelist(
this->GetType(), prop, this->Makefile->GetMessenger(),
@@ -380,22 +380,22 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
}
if (cmProp result = cmTargetPropertyComputer::GetProperty(
this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {
- return result->c_str();
+ return result;
}
if (cmSystemTools::GetFatalErrorOccured()) {
return nullptr;
}
- cmProp retval = this->Target->GetProperty(prop);
- return retval ? retval->c_str() : nullptr;
+ return this->Target->GetProperty(prop);
}
const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const
{
- const char* ret = this->GetProperty(prop);
+ cmProp ret = this->GetProperty(prop);
if (!ret) {
return "";
}
- return ret;
+
+ return ret->c_str();
}
const char* cmGeneratorTarget::GetOutputTargetType(
@@ -484,8 +484,8 @@ std::string cmGeneratorTarget::GetOutputName(
std::string outName;
for (std::string const& p : props) {
- if (const char* outNameProp = this->GetProperty(p)) {
- outName = outNameProp;
+ if (cmProp outNameProp = this->GetProperty(p)) {
+ outName = *outNameProp;
break;
}
}
@@ -541,7 +541,7 @@ std::string cmGeneratorTarget::GetFileSuffix(
std::string cmGeneratorTarget::GetFilePostfix(const std::string& config) const
{
- const char* postfix = nullptr;
+ cmProp postfix = nullptr;
std::string frameworkPostfix;
if (!config.empty()) {
std::string configProp =
@@ -559,16 +559,16 @@ std::string cmGeneratorTarget::GetFilePostfix(const std::string& config) const
// framework postfix.
frameworkPostfix = GetFrameworkMultiConfigPostfix(config);
if (!frameworkPostfix.empty()) {
- postfix = frameworkPostfix.c_str();
+ postfix = &frameworkPostfix;
}
}
- return postfix ? postfix : std::string();
+ return postfix ? *postfix : std::string();
}
std::string cmGeneratorTarget::GetFrameworkMultiConfigPostfix(
const std::string& config) const
{
- const char* postfix = nullptr;
+ cmProp postfix = nullptr;
if (!config.empty()) {
std::string configProp = cmStrCat("FRAMEWORK_MULTI_CONFIG_POSTFIX_",
cmSystemTools::UpperCase(config));
@@ -580,7 +580,7 @@ std::string cmGeneratorTarget::GetFrameworkMultiConfigPostfix(
postfix = nullptr;
}
}
- return postfix ? postfix : std::string();
+ return postfix ? *postfix : std::string();
}
const char* cmGeneratorTarget::GetFilePrefixInternal(
@@ -613,7 +613,7 @@ const char* cmGeneratorTarget::GetFilePrefixInternal(
}
// Compute prefix value.
- const char* targetPrefix =
+ cmProp targetPrefix =
(isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX")
: this->GetProperty("PREFIX"));
@@ -621,17 +621,17 @@ const char* cmGeneratorTarget::GetFilePrefixInternal(
const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact);
if (!language.empty() && prefixVar && *prefixVar) {
std::string langPrefix = prefixVar + std::string("_") + language;
- targetPrefix = this->Makefile->GetDefinition(langPrefix);
+ targetPrefix = this->Makefile->GetDef(langPrefix);
}
// if there is no prefix on the target nor specific language
// use the cmake definition.
if (!targetPrefix && prefixVar) {
- targetPrefix = this->Makefile->GetDefinition(prefixVar);
+ targetPrefix = this->Makefile->GetDef(prefixVar);
}
}
- return targetPrefix;
+ return targetPrefix ? targetPrefix->c_str() : nullptr;
}
const char* cmGeneratorTarget::GetFileSuffixInternal(
std::string const& config, cmStateEnums::ArtifactType artifact,
@@ -663,7 +663,7 @@ const char* cmGeneratorTarget::GetFileSuffixInternal(
}
// Compute suffix value.
- const char* targetSuffix =
+ cmProp targetSuffix =
(isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX")
: this->GetProperty("SUFFIX"));
@@ -671,17 +671,17 @@ const char* cmGeneratorTarget::GetFileSuffixInternal(
const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact);
if (!language.empty() && suffixVar && *suffixVar) {
std::string langSuffix = suffixVar + std::string("_") + language;
- targetSuffix = this->Makefile->GetDefinition(langSuffix);
+ targetSuffix = this->Makefile->GetDef(langSuffix);
}
// if there is no suffix on the target nor specific language
// use the cmake definition.
if (!targetSuffix && suffixVar) {
- targetSuffix = this->Makefile->GetDefinition(suffixVar);
+ targetSuffix = this->Makefile->GetDef(suffixVar);
}
}
- return targetSuffix;
+ return targetSuffix ? targetSuffix->c_str() : nullptr;
}
void cmGeneratorTarget::ClearSourcesCache()
@@ -743,9 +743,9 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
std::vector<std::string>& result,
bool excludeImported, std::string const& language)
{
- if (const char* dirs =
+ if (cmProp dirs =
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
- cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget,
+ cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget,
dagChecker, depTgt, language),
result);
}
@@ -753,9 +753,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
return;
}
- if (const char* dirs =
- depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
- cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget,
+ if (cmProp dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
+ cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget,
dagChecker, depTgt, language),
result);
}
@@ -811,12 +810,12 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature,
if (!config.empty()) {
std::string featureConfig =
cmStrCat(feature, '_', cmSystemTools::UpperCase(config));
- if (const char* value = this->GetProperty(featureConfig)) {
- return value;
+ if (cmProp value = this->GetProperty(featureConfig)) {
+ return value->c_str();
}
}
- if (const char* value = this->GetProperty(feature)) {
- return value;
+ if (cmProp value = this->GetProperty(feature)) {
+ return value->c_str();
}
return this->LocalGenerator->GetFeature(feature, config);
}
@@ -1172,8 +1171,8 @@ bool cmGeneratorTarget::MaybeHaveInterfaceProperty(
bool& maybeInterfaceProp = i->second;
// If this target itself has a non-empty property value, we are done.
- const char* p = this->GetProperty(prop);
- maybeInterfaceProp = p && *p;
+ cmProp p = this->GetProperty(prop);
+ maybeInterfaceProp = p && !p->empty();
// Otherwise, recurse to interface dependencies.
if (!maybeInterfaceProp) {
@@ -1239,9 +1238,9 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
cmGeneratorTarget const* headTarget =
context->HeadTarget ? context->HeadTarget : this;
- if (const char* p = this->GetProperty(prop)) {
+ if (cmProp p = this->GetProperty(prop)) {
result = cmGeneratorExpressionNode::EvaluateDependentExpression(
- p, context->LG, context, headTarget, &dagChecker, this);
+ *p, context->LG, context, headTarget, &dagChecker, this);
}
if (cmLinkInterfaceLibraries const* iface = this->GetLinkInterfaceLibraries(
@@ -1346,9 +1345,8 @@ void AddSwiftImplicitIncludeDirectories(
"Swift")) {
EvaluatedTargetPropertyEntry entry{ library, library.Backtrace };
- if (const char* val =
- dependency->GetProperty("Swift_MODULE_DIRECTORY")) {
- entry.Values.emplace_back(val);
+ if (cmProp val = dependency->GetProperty("Swift_MODULE_DIRECTORY")) {
+ entry.Values.emplace_back(*val);
} else {
entry.Values.emplace_back(
dependency->GetLocalGenerator()->GetCurrentBinaryDirectory());
@@ -1825,14 +1823,14 @@ std::string cmGeneratorTarget::GetCompilePDBName(
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(config);
std::string configProp = cmStrCat("COMPILE_PDB_NAME_", configUpper);
- const char* config_name = this->GetProperty(configProp);
- if (config_name && *config_name) {
- return prefix + config_name + ".pdb";
+ cmProp config_name = this->GetProperty(configProp);
+ if (config_name && !config_name->empty()) {
+ return prefix + *config_name + ".pdb";
}
- const char* name = this->GetProperty("COMPILE_PDB_NAME");
- if (name && *name) {
- return prefix + name + ".pdb";
+ cmProp name = this->GetProperty("COMPILE_PDB_NAME");
+ if (name && !name->empty()) {
+ return prefix + *name + ".pdb";
}
return "";
@@ -2014,10 +2012,9 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
if (this->GetType() != cmStateEnums::SHARED_LIBRARY) {
return false;
}
- const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
+ cmProp install_name = this->GetProperty("INSTALL_NAME_DIR");
bool use_install_name = this->MacOSXUseInstallNameDir();
- if (install_name && use_install_name &&
- std::string(install_name) == "@rpath") {
+ if (install_name && use_install_name && *install_name == "@rpath") {
install_name_is_rpath = true;
} else if (install_name && use_install_name) {
return false;
@@ -2073,7 +2070,7 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
return false;
}
- const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
+ cmProp macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
if (macosx_rpath_str) {
return this->GetPropertyAsBool("MACOSX_RPATH");
}
@@ -2090,10 +2087,10 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
{
- const char* build_with_install_name =
+ cmProp build_with_install_name =
this->GetProperty("BUILD_WITH_INSTALL_NAME_DIR");
if (build_with_install_name) {
- return cmIsOn(build_with_install_name);
+ return cmIsOn(*build_with_install_name);
}
cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068();
@@ -2175,11 +2172,8 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(
{
std::string fpath = cmStrCat(
this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
- const char* ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
- ext = "app";
- }
- fpath += ext;
+ cmProp ext = this->GetProperty("BUNDLE_EXTENSION");
+ fpath += (ext ? *ext : "app");
if (shouldAddContentLevel(level) &&
!this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Contents";
@@ -2201,8 +2195,10 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(
{
std::string fpath = cmStrCat(
this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
- const char* ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
+ std::string ext;
+ if (cmProp p = this->GetProperty("BUNDLE_EXTENSION")) {
+ ext = *p;
+ } else {
if (this->IsXCTestOnApple()) {
ext = "xctest";
} else {
@@ -2225,11 +2221,8 @@ std::string cmGeneratorTarget::GetFrameworkDirectory(
{
std::string fpath = cmStrCat(
this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
- const char* ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
- ext = "framework";
- }
- fpath += ext;
+ cmProp ext = this->GetProperty("BUNDLE_EXTENSION");
+ fpath += (ext ? *ext : "framework");
if (shouldAddFullLevel(level) &&
!this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Versions/";
@@ -2280,11 +2273,11 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree(
{
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
std::string dir;
- const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
+ cmProp install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
- if (install_name_dir && *install_name_dir) {
- dir = install_name_dir;
+ if (install_name_dir && !install_name_dir->empty()) {
+ dir = *install_name_dir;
cmGeneratorExpression::ReplaceInstallPrefix(dir, installPrefix);
dir =
cmGeneratorExpression::Evaluate(dir, this->LocalGenerator, config);
@@ -2329,8 +2322,8 @@ const std::string* cmGeneratorTarget::GetExportMacro() const
if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::MODULE_LIBRARY ||
this->IsExecutableWithExports()) {
- if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
- this->ExportMacro = custom_export_name;
+ if (cmProp custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
+ this->ExportMacro = *custom_export_name;
} else {
std::string in = cmStrCat(this->GetName(), "_EXPORTS");
this->ExportMacro = cmSystemTools::MakeCidentifier(in);
@@ -2617,9 +2610,9 @@ std::string cmGeneratorTarget::GetEffectiveFolderName() const
return effectiveFolder;
}
- const char* targetFolder = this->GetProperty("FOLDER");
+ cmProp targetFolder = this->GetProperty("FOLDER");
if (targetFolder) {
- effectiveFolder += targetFolder;
+ effectiveFolder += *targetFolder;
}
return effectiveFolder;
@@ -3075,7 +3068,7 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory(
void cmGeneratorTarget::GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const
{
- const char* archs = nullptr;
+ cmProp archs = nullptr;
if (!config.empty()) {
std::string defVarName =
cmStrCat("OSX_ARCHITECTURES_", cmSystemTools::UpperCase(config));
@@ -3085,7 +3078,7 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config,
archs = this->GetProperty("OSX_ARCHITECTURES");
}
if (archs) {
- cmExpandList(std::string(archs), archVec);
+ cmExpandList(*archs, archVec);
}
}
@@ -3641,7 +3634,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
if (!config.empty()) {
std::string configPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
- const char* configProp = this->GetProperty(configPropName);
+ cmProp configProp = this->GetProperty(configPropName);
if (configProp) {
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) {
case cmPolicies::WARN: {
@@ -3652,7 +3645,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
}
case cmPolicies::OLD: {
std::unique_ptr<TargetPropertyEntry> entry =
- CreateTargetPropertyEntry(configProp);
+ CreateTargetPropertyEntry(*configProp);
entries.emplace_back(EvaluateTargetPropertyEntry(
this, config, language, &dagChecker, *entry));
} break;
@@ -3720,7 +3713,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
return std::string();
}
const cmGeneratorTarget* generatorTarget = this;
- const char* pchReuseFrom =
+ cmProp pchReuseFrom =
generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
const auto inserted =
@@ -3735,7 +3728,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
if (pchReuseFrom) {
generatorTarget =
- this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom);
}
filename = cmStrCat(
@@ -3833,11 +3826,11 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config,
std::string& filename = inserted.first->second;
const cmGeneratorTarget* generatorTarget = this;
- const char* pchReuseFrom =
+ cmProp pchReuseFrom =
generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
if (pchReuseFrom) {
generatorTarget =
- this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom);
}
filename =
@@ -3929,11 +3922,11 @@ std::string cmGeneratorTarget::GetPchFile(const std::string& config,
};
cmGeneratorTarget* generatorTarget = this;
- const char* pchReuseFrom =
+ cmProp pchReuseFrom =
generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
if (pchReuseFrom) {
generatorTarget =
- this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom);
}
const std::string pchFileObject =
@@ -4211,8 +4204,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
nullptr, nullptr);
std::vector<EvaluatedTargetPropertyEntry> entries;
- if (const char* linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
- std::vector<std::string> options = cmExpandedList(linkOptions);
+ if (cmProp linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
+ std::vector<std::string> options = cmExpandedList(*linkOptions);
for (const auto& option : options) {
std::unique_ptr<TargetPropertyEntry> entry =
CreateTargetPropertyEntry(option);
@@ -4366,8 +4359,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
nullptr);
std::vector<EvaluatedTargetPropertyEntry> entries;
- if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) {
- std::vector<std::string> depends = cmExpandedList(linkDepends);
+ if (cmProp linkDepends = this->GetProperty("LINK_DEPENDS")) {
+ std::vector<std::string> depends = cmExpandedList(*linkDepends);
for (const auto& depend : depends) {
std::unique_ptr<TargetPropertyEntry> entry =
CreateTargetPropertyEntry(depend);
@@ -4527,8 +4520,8 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
}
// Check for library version properties.
- const char* version = this->GetProperty("VERSION");
- const char* soversion = this->GetProperty("SOVERSION");
+ cmProp version = this->GetProperty("VERSION");
+ cmProp soversion = this->GetProperty("SOVERSION");
if (!this->HasSOName(config) ||
this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
this->IsFrameworkOnApple()) {
@@ -4569,11 +4562,12 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
// The library's soname.
this->ComputeVersionedName(targetNames.SharedObject, prefix,
targetNames.Base, suffix, targetNames.Output,
- soversion);
+ (soversion ? soversion->c_str() : nullptr));
// The library's real name on disk.
this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base,
- suffix, targetNames.Output, version);
+ suffix, targetNames.Output,
+ (version ? version->c_str() : nullptr));
}
// The import library name.
@@ -4606,10 +4600,13 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames(
// This versioning is supported only for executables and then only
// when the platform supports symbolic links.
#if defined(_WIN32) && !defined(__CYGWIN__)
- const char* version = 0;
+ const char* version = nullptr;
#else
// Check for executable version properties.
- const char* version = this->GetProperty("VERSION");
+ const char* version = nullptr;
+ if (cmProp p = this->GetProperty("VERSION")) {
+ version = p->c_str();
+ }
if (this->GetType() != cmStateEnums::EXECUTABLE ||
this->Makefile->IsOn("XCODE")) {
version = nullptr;
@@ -4750,12 +4747,12 @@ void cmGeneratorTarget::GetFullNameInternal(
}
// Name shared libraries with their version number on some platforms.
- if (const char* soversion = this->GetProperty("SOVERSION")) {
+ if (cmProp soversion = this->GetProperty("SOVERSION")) {
if (this->GetType() == cmStateEnums::SHARED_LIBRARY &&
!isImportedLibraryArtifact &&
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
outBase += "-";
- outBase += soversion;
+ outBase += *soversion;
}
}
@@ -4786,8 +4783,8 @@ std::string cmGeneratorTarget::GetPDBOutputName(
props.emplace_back("PDB_NAME");
for (std::string const& p : props) {
- if (const char* outName = this->GetProperty(p)) {
- base = outName;
+ if (cmProp outName = this->GetProperty(p)) {
+ base = *outName;
break;
}
}
@@ -4813,8 +4810,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
props.emplace_back("PDB_NAME");
for (std::string const& p : props) {
- if (const char* outName = this->GetProperty(p)) {
- base = outName;
+ if (cmProp outName = this->GetProperty(p)) {
+ base = *outName;
break;
}
}
@@ -4916,8 +4913,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
this->SourceFileFlagsConstructed = true;
// Process public headers to mark the source files.
- if (const char* files = this->GetProperty("PUBLIC_HEADER")) {
- std::vector<std::string> relFiles = cmExpandedList(files);
+ if (cmProp files = this->GetProperty("PUBLIC_HEADER")) {
+ std::vector<std::string> relFiles = cmExpandedList(*files);
for (std::string const& relFile : relFiles) {
if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
@@ -4929,8 +4926,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
// Process private headers after public headers so that they take
// precedence if a file is listed in both.
- if (const char* files = this->GetProperty("PRIVATE_HEADER")) {
- std::vector<std::string> relFiles = cmExpandedList(files);
+ if (cmProp files = this->GetProperty("PRIVATE_HEADER")) {
+ std::vector<std::string> relFiles = cmExpandedList(*files);
for (std::string const& relFile : relFiles) {
if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
@@ -4941,8 +4938,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
}
// Mark sources listed as resources.
- if (const char* files = this->GetProperty("RESOURCE")) {
- std::vector<std::string> relFiles = cmExpandedList(files);
+ if (cmProp files = this->GetProperty("RESOURCE")) {
+ std::vector<std::string> relFiles = cmExpandedList(*files);
for (std::string const& relFile : relFiles) {
if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
@@ -4969,9 +4966,9 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
this->GetLinkImplementationClosure(config);
for (cmGeneratorTarget const* li : deps) {
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
- if (const char* prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
+ if (cmProp prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
std::vector<std::string> props; \
- cmExpandList(prop, props); \
+ cmExpandList(*prop, props); \
compat.Props##x.insert(props.begin(), props.end()); \
}
CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
@@ -5079,12 +5076,12 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
const std::string& config, CompatibleType t,
PropertyType* /*unused*/)
{
- const char* prop = dependee->GetProperty(propName);
+ cmProp prop = dependee->GetProperty(propName);
if (!prop) {
return;
}
- std::vector<std::string> props = cmExpandedList(prop);
+ std::vector<std::string> props = cmExpandedList(*prop);
std::string pdir =
cmStrCat(cmSystemTools::GetCMakeRoot(), "/Help/prop_tgt/");
@@ -5314,8 +5311,9 @@ bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
return tgt->GetPropertyAsBool(prop);
}
- const char* value = tgt->GetProperty(prop);
- return cmIsOn(genexInterpreter->Evaluate(value, prop));
+ cmProp value = tgt->GetProperty(prop);
+ return cmIsOn(
+ genexInterpreter->Evaluate(value ? value->c_str() : nullptr, prop));
}
template <>
@@ -5323,13 +5321,14 @@ const char* getTypedProperty<const char*>(
cmGeneratorTarget const* tgt, const std::string& prop,
cmGeneratorExpressionInterpreter* genexInterpreter)
{
- const char* value = tgt->GetProperty(prop);
+ cmProp value = tgt->GetProperty(prop);
if (genexInterpreter == nullptr) {
- return value;
+ return value ? value->c_str() : nullptr;
}
- return genexInterpreter->Evaluate(value, prop).c_str();
+ return genexInterpreter->Evaluate(value ? value->c_str() : nullptr, prop)
+ .c_str();
}
template <>
@@ -5337,13 +5336,13 @@ std::string getTypedProperty<std::string>(
cmGeneratorTarget const* tgt, const std::string& prop,
cmGeneratorExpressionInterpreter* genexInterpreter)
{
- const char* value = tgt->GetProperty(prop);
+ cmProp value = tgt->GetProperty(prop);
if (genexInterpreter == nullptr) {
- return valueAsString(value);
+ return valueAsString(value ? value->c_str() : nullptr);
}
- return genexInterpreter->Evaluate(value, prop);
+ return genexInterpreter->Evaluate(value ? value->c_str() : nullptr, prop);
}
template <typename PropertyType>
@@ -5714,13 +5713,13 @@ void cmGeneratorTarget::GetTargetVersion(const std::string& property,
assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
- if (const char* version = this->GetProperty(property)) {
+ if (cmProp version = this->GetProperty(property)) {
// Try to parse the version number and store the results that were
// successfully parsed.
int parsed_major;
int parsed_minor;
int parsed_patch;
- switch (sscanf(version, "%d.%d.%d", &parsed_major, &parsed_minor,
+ switch (sscanf(version->c_str(), "%d.%d.%d", &parsed_major, &parsed_minor,
&parsed_patch)) {
case 3:
patch = parsed_patch;
@@ -5754,8 +5753,8 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory(
{
std::string mod_dir;
std::string target_mod_dir;
- if (const char* prop = this->GetProperty("Fortran_MODULE_DIRECTORY")) {
- target_mod_dir = prop;
+ if (cmProp prop = this->GetProperty("Fortran_MODULE_DIRECTORY")) {
+ target_mod_dir = *prop;
} else {
std::string const& default_mod_dir =
this->LocalGenerator->GetCurrentBinaryDirectory();
@@ -5786,11 +5785,11 @@ std::string cmGeneratorTarget::GetFrameworkVersion() const
{
assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
- if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
- return fversion;
+ if (cmProp fversion = this->GetProperty("FRAMEWORK_VERSION")) {
+ return *fversion;
}
- if (const char* tversion = this->GetProperty("VERSION")) {
- return tversion;
+ if (cmProp tversion = this->GetProperty("VERSION")) {
+ return *tversion;
}
return "A";
}
@@ -6026,11 +6025,11 @@ void cmGeneratorTarget::ComputeLinkInterface(
// How many repetitions are needed if this library has cyclic
// dependencies?
std::string propName = cmStrCat("LINK_INTERFACE_MULTIPLICITY", suffix);
- if (const char* config_reps = this->GetProperty(propName)) {
- sscanf(config_reps, "%u", &iface.Multiplicity);
- } else if (const char* reps =
+ if (cmProp config_reps = this->GetProperty(propName)) {
+ sscanf(config_reps->c_str(), "%u", &iface.Multiplicity);
+ } else if (cmProp reps =
this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) {
- sscanf(reps, "%u", &iface.Multiplicity);
+ sscanf(reps->c_str(), "%u", &iface.Multiplicity);
}
}
}
@@ -6180,21 +6179,21 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
}
// Select an output directory.
- if (const char* config_outdir = this->GetProperty(configProp)) {
+ if (cmProp config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
- out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator,
+ out = cmGeneratorExpression::Evaluate(*config_outdir, this->LocalGenerator,
config);
// Skip per-configuration subdirectory.
conf.clear();
- } else if (const char* outdir = this->GetProperty(propertyName)) {
+ } else if (cmProp outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
out =
- cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config);
+ cmGeneratorExpression::Evaluate(*outdir, this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a
// generator expression.
- if (out != outdir) {
+ if (out != *outdir) {
conf.clear();
}
} else if (this->GetType() == cmStateEnums::EXECUTABLE) {
@@ -6256,21 +6255,21 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
}
// Select an output directory.
- if (const char* config_outdir = this->GetProperty(configProp)) {
+ if (cmProp config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
- out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator,
+ out = cmGeneratorExpression::Evaluate(*config_outdir, this->LocalGenerator,
config);
// Skip per-configuration subdirectory.
conf.clear();
- } else if (const char* outdir = this->GetProperty(propertyName)) {
+ } else if (cmProp outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
out =
- cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config);
+ cmGeneratorExpression::Evaluate(*outdir, this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a
// generator expression.
- if (out != outdir) {
+ if (out != *outdir) {
conf.clear();
}
}
@@ -6316,12 +6315,13 @@ bool cmGeneratorTarget::GetRPATH(const std::string& config,
const std::string& prop,
std::string& rpath) const
{
- const char* value = this->GetProperty(prop);
+ cmProp value = this->GetProperty(prop);
if (!value) {
return false;
}
- rpath = cmGeneratorExpression::Evaluate(value, this->LocalGenerator, config);
+ rpath =
+ cmGeneratorExpression::Evaluate(*value, this->LocalGenerator, config);
return true;
}
@@ -6340,7 +6340,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// An explicit list of interface libraries may be set for shared
// libraries and executables that export symbols.
- const char* explicitLibraries = nullptr;
+ cmProp explicitLibraries = nullptr;
std::string linkIfaceProp;
bool const cmp0022NEW = (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
this->GetPolicyStatusCMP0022() != cmPolicies::WARN);
@@ -6369,10 +6369,10 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
!this->PolicyWarnedCMP0022) {
// Compare the explicitly set old link interface properties to the
// preferred new link interface property one and warn if different.
- const char* newExplicitLibraries =
+ cmProp newExplicitLibraries =
this->GetProperty("INTERFACE_LINK_LIBRARIES");
if (newExplicitLibraries &&
- strcmp(newExplicitLibraries, explicitLibraries) != 0) {
+ (*newExplicitLibraries != *explicitLibraries)) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
@@ -6381,9 +6381,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
linkIfaceProp << " properties."
"\n"
"INTERFACE_LINK_LIBRARIES:\n"
- " " << newExplicitLibraries << "\n" <<
+ " " << *newExplicitLibraries << "\n" <<
linkIfaceProp << ":\n"
- " " << explicitLibraries << "\n";
+ " " << *explicitLibraries << "\n";
/* clang-format on */
this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
this->PolicyWarnedCMP0022 = true;
@@ -6402,8 +6402,8 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
if (explicitLibraries) {
// The interface libraries have been explicitly set.
- this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget,
- usage_requirements_only, iface.Libraries,
+ this->ExpandLinkItems(linkIfaceProp, *explicitLibraries, config,
+ headTarget, usage_requirements_only, iface.Libraries,
iface.HadHeadSensitiveCondition,
iface.HadLinkLanguageSensitiveCondition);
} else if (!cmp0022NEW)
@@ -6423,10 +6423,10 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// preferred new link interface property and warn if different.
std::vector<cmLinkItem> ifaceLibs;
static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
- if (const char* newExplicitLibraries = this->GetProperty(newProp)) {
+ if (cmProp newExplicitLibraries = this->GetProperty(newProp)) {
bool hadHeadSensitiveConditionDummy = false;
bool hadLinkLanguageSensitiveConditionDummy = false;
- this->ExpandLinkItems(newProp, newExplicitLibraries, config,
+ this->ExpandLinkItems(newProp, *newExplicitLibraries, config,
headTarget, usage_requirements_only, ifaceLibs,
hadHeadSensitiveConditionDummy,
hadLinkLanguageSensitiveConditionDummy);
@@ -6562,7 +6562,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the link interface.
{
std::string linkProp = "INTERFACE_LINK_LIBRARIES";
- const char* propertyLibs = this->GetProperty(linkProp);
+ cmProp propertyLibs = this->GetProperty(linkProp);
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
if (!propertyLibs) {
@@ -6577,7 +6577,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
if (propertyLibs) {
info.LibrariesProp = linkProp;
- info.Libraries = propertyLibs;
+ info.Libraries = *propertyLibs;
}
}
if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
@@ -6595,31 +6595,30 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
info.Location = *loc;
} else {
std::string impProp = cmStrCat("IMPORTED_LOCATION", suffix);
- if (const char* config_location = this->GetProperty(impProp)) {
- info.Location = config_location;
- } else if (const char* location = this->GetProperty("IMPORTED_LOCATION")) {
- info.Location = location;
+ if (cmProp config_location = this->GetProperty(impProp)) {
+ info.Location = *config_location;
+ } else if (cmProp location = this->GetProperty("IMPORTED_LOCATION")) {
+ info.Location = *location;
}
}
// Get the soname.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
std::string soProp = cmStrCat("IMPORTED_SONAME", suffix);
- if (const char* config_soname = this->GetProperty(soProp)) {
- info.SOName = config_soname;
- } else if (const char* soname = this->GetProperty("IMPORTED_SONAME")) {
- info.SOName = soname;
+ if (cmProp config_soname = this->GetProperty(soProp)) {
+ info.SOName = *config_soname;
+ } else if (cmProp soname = this->GetProperty("IMPORTED_SONAME")) {
+ info.SOName = *soname;
}
}
// Get the "no-soname" mark.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
std::string soProp = cmStrCat("IMPORTED_NO_SONAME", suffix);
- if (const char* config_no_soname = this->GetProperty(soProp)) {
- info.NoSOName = cmIsOn(config_no_soname);
- } else if (const char* no_soname =
- this->GetProperty("IMPORTED_NO_SONAME")) {
- info.NoSOName = cmIsOn(no_soname);
+ if (cmProp config_no_soname = this->GetProperty(soProp)) {
+ info.NoSOName = cmIsOn(*config_no_soname);
+ } else if (cmProp no_soname = this->GetProperty("IMPORTED_NO_SONAME")) {
+ info.NoSOName = cmIsOn(*no_soname);
}
}
@@ -6629,10 +6628,10 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
} else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
- if (const char* config_implib = this->GetProperty(impProp)) {
- info.ImportLibrary = config_implib;
- } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
- info.ImportLibrary = implib;
+ if (cmProp config_implib = this->GetProperty(impProp)) {
+ info.ImportLibrary = *config_implib;
+ } else if (cmProp implib = this->GetProperty("IMPORTED_IMPLIB")) {
+ info.ImportLibrary = *implib;
}
}
@@ -6640,11 +6639,11 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string linkProp =
cmStrCat("IMPORTED_LINK_DEPENDENT_LIBRARIES", suffix);
- if (const char* config_libs = this->GetProperty(linkProp)) {
- info.SharedDeps = config_libs;
- } else if (const char* libs =
+ if (cmProp config_libs = this->GetProperty(linkProp)) {
+ info.SharedDeps = *config_libs;
+ } else if (cmProp libs =
this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) {
- info.SharedDeps = libs;
+ info.SharedDeps = *libs;
}
}
@@ -6652,21 +6651,21 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
if (this->LinkLanguagePropagatesToDependents()) {
std::string linkProp =
cmStrCat("IMPORTED_LINK_INTERFACE_LANGUAGES", suffix);
- if (const char* config_libs = this->GetProperty(linkProp)) {
- info.Languages = config_libs;
- } else if (const char* libs =
+ if (cmProp config_libs = this->GetProperty(linkProp)) {
+ info.Languages = *config_libs;
+ } else if (cmProp libs =
this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) {
- info.Languages = libs;
+ info.Languages = *libs;
}
}
// Get information if target is managed assembly.
{
std::string linkProp = "IMPORTED_COMMON_LANGUAGE_RUNTIME";
- if (auto pc = this->GetProperty(linkProp + suffix)) {
- info.Managed = this->CheckManagedType(pc);
- } else if (auto p = this->GetProperty(linkProp)) {
- info.Managed = this->CheckManagedType(p);
+ if (cmProp pc = this->GetProperty(linkProp + suffix)) {
+ info.Managed = this->CheckManagedType(*pc);
+ } else if (cmProp p = this->GetProperty(linkProp)) {
+ info.Managed = this->CheckManagedType(*p);
}
}
@@ -6674,11 +6673,11 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
std::string linkProp =
cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix);
- if (const char* config_reps = this->GetProperty(linkProp)) {
- sscanf(config_reps, "%u", &info.Multiplicity);
- } else if (const char* reps =
+ if (cmProp config_reps = this->GetProperty(linkProp)) {
+ sscanf(config_reps->c_str(), "%u", &info.Multiplicity);
+ } else if (cmProp reps =
this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) {
- sscanf(reps, "%u", &info.Multiplicity);
+ sscanf(reps->c_str(), "%u", &info.Multiplicity);
}
}
}
@@ -6854,15 +6853,15 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
bool cmGeneratorTarget::IsDeprecated() const
{
- const char* deprecation = this->GetProperty("DEPRECATION");
- return deprecation && *deprecation;
+ cmProp deprecation = this->GetProperty("DEPRECATION");
+ return deprecation && !deprecation->empty();
}
std::string cmGeneratorTarget::GetDeprecation() const
{
// find DEPRECATION property
- if (const char* deprecation = this->GetProperty("DEPRECATION")) {
- return deprecation;
+ if (cmProp deprecation = this->GetProperty("DEPRECATION")) {
+ return *deprecation;
}
return std::string();
}
@@ -6919,9 +6918,9 @@ bool cmGeneratorTarget::IsCSharpOnly() const
std::set<std::string> languages = this->GetAllConfigCompileLanguages();
// Consider an explicit linker language property, but *not* the
// computed linker language that may depend on linked targets.
- const char* linkLang = this->GetProperty("LINKER_LANGUAGE");
- if (linkLang && *linkLang) {
- languages.insert(linkLang);
+ cmProp linkLang = this->GetProperty("LINKER_LANGUAGE");
+ if (linkLang && !linkLang->empty()) {
+ languages.insert(*linkLang);
}
return languages.size() == 1 && languages.count("CSharp") > 0;
}
@@ -7299,8 +7298,8 @@ cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType(
}
// Check for explicitly set clr target property.
- if (auto* clr = this->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
- return this->CheckManagedType(clr);
+ if (cmProp clr = this->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
+ return this->CheckManagedType(*clr);
}
// C# targets are always managed. This language specific check