diff options
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 13 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 18 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 17 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 27 | ||||
-rw-r--r-- | Source/cmTarget.h | 5 |
6 files changed, 46 insertions, 50 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 53c39dd..630fda3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1067,21 +1067,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { std::string flags; std::string defFlags; - bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || - (target.GetType() == cmTarget::MODULE_LIBRARY)); - if(shared) + // Add the export symbol definition for shared library objects. + if(const char* exportMacro = target.GetExportMacro()) { defFlags += "-D"; - if(const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL")) - { - defFlags += custom_export_name; - } - else - { - std::string in = target.GetName(); - in += "_EXPORTS"; - defFlags += cmSystemTools::MakeCindentifier(in.c_str()); - } + defFlags += exportMacro; } const char* lang = target.GetLinkerLanguage(this); std::string cflags; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 40ba473..24a381a 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1289,18 +1289,13 @@ void cmLocalVisualStudio6Generator staticLibOptions = libflags; } } + + // Add the export symbol definition for shared library objects. std::string exportSymbol; - if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL")) + if(const char* exportMacro = target.GetExportMacro()) { - exportSymbol = custom_export_name; + exportSymbol = exportMacro; } - else - { - std::string in = libName; - in += "_EXPORTS"; - exportSymbol = cmSystemTools::MakeCindentifier(in.c_str()); - } - std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 71a1e0d..97bd3b4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -520,22 +520,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, configDefine += "\\\""; targetOptions.AddDefine(configDefine); - // Add a definition for the export macro. - if(target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + // Add the export symbol definition for shared library objects. + if(const char* exportMacro = target.GetExportMacro()) { - std::string exportSymbol; - if(const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL")) - { - exportSymbol = custom_export_name; - } - else - { - std::string id = libName; - id += "_EXPORTS"; - exportSymbol = cmSystemTools::MakeCindentifier(id.c_str()); - } - targetOptions.AddDefine(exportSymbol); + targetOptions.AddDefine(exportMacro); } // The intermediate directory name consists of a directory for the diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1f6fe63..0a1b9c8 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -243,23 +243,14 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { const char *lang = l->first.c_str(); std::string flags; - // Add the export symbol definition for shared library objects. bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); - if(shared) + + // Add the export symbol definition for shared library objects. + if(const char* exportMacro = this->Target->GetExportMacro()) { flags += "-D"; - if(const char* custom_export_name = - this->Target->GetProperty("DEFINE_SYMBOL")) - { - flags += custom_export_name; - } - else - { - std::string in = this->Target->GetName(); - in += "_EXPORTS"; - flags += cmSystemTools::MakeCindentifier(in.c_str()); - } + flags += exportMacro; } // Add language-specific flags. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 441269c..c4dc29e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2157,3 +2157,30 @@ const char* cmTarget::GetOutputDir(bool implib) return out.c_str(); } + +//---------------------------------------------------------------------------- +const char* cmTarget::GetExportMacro() +{ + // Define the symbol for targets that export symbols. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE && + this->GetPropertyAsBool("ENABLE_EXPORTS")) + { + if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) + { + this->ExportMacro = custom_export_name; + } + else + { + std::string in = this->GetName(); + in += "_EXPORTS"; + this->ExportMacro = cmSystemTools::MakeCindentifier(in.c_str()); + } + return this->ExportMacro.c_str(); + } + else + { + return 0; + } +} diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 028231a..5cda102 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -259,6 +259,10 @@ public: // Compute the OBJECT_FILES property only when requested void ComputeObjectFiles(); + /** Get the macro to define when building sources in this target. + If no macro should be defined null is returned. */ + const char* GetExportMacro(); + private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. @@ -359,6 +363,7 @@ private: std::string OutputDirImplib; std::string Directory; std::string Location; + std::string ExportMacro; std::set<cmStdString> Utilities; bool RecordDependencies; cmPropertyMap Properties; |