cmGeneratorTarget::GetExportMacro: return const std::string*

This commit is contained in:
Vitaly Stakhovsky
2018-10-14 19:00:34 -04:00
committed by Brad King
parent f77a9576e5
commit b8bb6ba653
6 changed files with 15 additions and 13 deletions

View File

@@ -1730,7 +1730,7 @@ bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
this->GetType() == cmStateEnums::EXECUTABLE; this->GetType() == cmStateEnums::EXECUTABLE;
} }
const char* cmGeneratorTarget::GetExportMacro() const const std::string* cmGeneratorTarget::GetExportMacro() const
{ {
// Define the symbol for targets that export symbols. // Define the symbol for targets that export symbols.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY || if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
@@ -1743,7 +1743,7 @@ const char* cmGeneratorTarget::GetExportMacro() const
in += "_EXPORTS"; in += "_EXPORTS";
this->ExportMacro = cmSystemTools::MakeCidentifier(in); this->ExportMacro = cmSystemTools::MakeCidentifier(in);
} }
return this->ExportMacro.c_str(); return &this->ExportMacro;
} }
return nullptr; return nullptr;
} }

View File

@@ -283,7 +283,7 @@ public:
/** Get the macro to define when building sources in this target. /** Get the macro to define when building sources in this target.
If no macro should be defined null is returned. */ If no macro should be defined null is returned. */
const char* GetExportMacro() const; const std::string* GetExportMacro() const;
/** Get the soname of the target. Allowed only for a shared library. */ /** Get the soname of the target. Allowed only for a shared library. */
std::string GetSOName(const std::string& config) const; std::string GetSOName(const std::string& config) const;

View File

@@ -1814,9 +1814,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
BuildObjectListOrString ppDefs(this, true); BuildObjectListOrString ppDefs(this, true);
this->AppendDefines( this->AppendDefines(
ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
if (const char* exportMacro = gtgt->GetExportMacro()) { if (const std::string* exportMacro = gtgt->GetExportMacro()) {
// Add the export symbol definition for shared library objects. // Add the export symbol definition for shared library objects.
this->AppendDefines(ppDefs, exportMacro); this->AppendDefines(ppDefs, exportMacro->c_str());
} }
std::vector<std::string> targetDefines; std::vector<std::string> targetDefines;
if (!langForPreprocessor.empty()) { if (!langForPreprocessor.empty()) {

View File

@@ -1253,8 +1253,8 @@ void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target,
std::set<std::string>& defines) const std::set<std::string>& defines) const
{ {
// Add the export symbol definition for shared library objects. // Add the export symbol definition for shared library objects.
if (const char* exportMacro = target->GetExportMacro()) { if (const std::string* exportMacro = target->GetExportMacro()) {
this->AppendDefines(defines, exportMacro); this->AppendDefines(defines, *exportMacro);
} }
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.

View File

@@ -735,8 +735,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
targetOptions.AddDefine(configDefine); targetOptions.AddDefine(configDefine);
// Add the export symbol definition for shared library objects. // Add the export symbol definition for shared library objects.
if (const char* exportMacro = target->GetExportMacro()) { if (const std::string* exportMacro = target->GetExportMacro()) {
targetOptions.AddDefine(exportMacro); targetOptions.AddDefine(*exportMacro);
} }
// The intermediate directory name consists of a directory for the // The intermediate directory name consists of a directory for the

View File

@@ -2580,8 +2580,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
configDefine += configName; configDefine += configName;
configDefine += "\""; configDefine += "\"";
clOptions.AddDefine(configDefine); clOptions.AddDefine(configDefine);
if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) { if (const std::string* exportMacro =
clOptions.AddDefine(exportMacro); this->GeneratorTarget->GetExportMacro()) {
clOptions.AddDefine(*exportMacro);
} }
if (this->MSTools) { if (this->MSTools) {
@@ -2877,8 +2878,9 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
configDefine += configName; configDefine += configName;
configDefine += "\""; configDefine += "\"";
cudaOptions.AddDefine(configDefine); cudaOptions.AddDefine(configDefine);
if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) { if (const std::string* exportMacro =
cudaOptions.AddDefine(exportMacro); this->GeneratorTarget->GetExportMacro()) {
cudaOptions.AddDefine(*exportMacro);
} }
// Get includes for this target // Get includes for this target