[cmake-commits] king committed cmLocalVisualStudio6Generator.cxx
1.119 1.120 cmLocalVisualStudio7Generator.cxx 1.184 1.185
cmMakefileTargetGenerator.cxx 1.59 1.60 cmTarget.cxx 1.132
1.133 cmTarget.h 1.79 1.80 cmGlobalXCodeGenerator.cxx 1.139 1.140
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Mar 27 22:13:28 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv30186
Modified Files:
cmLocalVisualStudio6Generator.cxx
cmLocalVisualStudio7Generator.cxx
cmMakefileTargetGenerator.cxx cmTarget.cxx cmTarget.h
cmGlobalXCodeGenerator.cxx
Log Message:
ENH: Created method cmTarget::GetExportMacro to centralize computation of the export symbol name. This removes duplicate code from all the generators. Also enabled the export definition for executable targets with the ENABLE_EXPORTS property set.
Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- cmLocalVisualStudio7Generator.cxx 19 Mar 2007 14:00:35 -0000 1.184
+++ cmLocalVisualStudio7Generator.cxx 28 Mar 2007 03:13:25 -0000 1.185
@@ -520,22 +520,10 @@
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
Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- cmGlobalXCodeGenerator.cxx 13 Mar 2007 19:18:27 -0000 1.139
+++ cmGlobalXCodeGenerator.cxx 28 Mar 2007 03:13:25 -0000 1.140
@@ -1067,21 +1067,11 @@
{
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;
Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- cmLocalVisualStudio6Generator.cxx 19 Mar 2007 14:00:35 -0000 1.119
+++ cmLocalVisualStudio6Generator.cxx 28 Mar 2007 03:13:25 -0000 1.120
@@ -1289,19 +1289,14 @@
staticLibOptions = libflags;
}
}
+
+ // Add the export symbol definition for shared library objects.
std::string exportSymbol;
- if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL"))
- {
- exportSymbol = custom_export_name;
- }
- else
+ if(const char* exportMacro = target.GetExportMacro())
{
- std::string in = libName;
- in += "_EXPORTS";
- exportSymbol = cmSystemTools::MakeCindentifier(in.c_str());
+ exportSymbol = exportMacro;
}
-
std::string line;
while(cmSystemTools::GetLineFromStream(fin, line))
{
Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- cmTarget.h 19 Mar 2007 14:00:35 -0000 1.79
+++ cmTarget.h 28 Mar 2007 03:13:25 -0000 1.80
@@ -259,6 +259,10 @@
// 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 @@
std::string OutputDirImplib;
std::string Directory;
std::string Location;
+ std::string ExportMacro;
std::set<cmStdString> Utilities;
bool RecordDependencies;
cmPropertyMap Properties;
Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- cmMakefileTargetGenerator.cxx 9 Mar 2007 16:29:15 -0000 1.59
+++ cmMakefileTargetGenerator.cxx 28 Mar 2007 03:13:25 -0000 1.60
@@ -243,23 +243,14 @@
{
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.
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- cmTarget.cxx 22 Mar 2007 13:45:24 -0000 1.132
+++ cmTarget.cxx 28 Mar 2007 03:13:25 -0000 1.133
@@ -2157,3 +2157,30 @@
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;
+ }
+}
More information about the Cmake-commits
mailing list