mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
ENH: Added -D(library_name)_EXPORTS to build rules for sources that are going to be linked into a shared library. This allows dllexport setup for DLL building on cygwin. It may also come in handy in unix in the future. This corresponds to the same definition added by the dll dsp template in windows.
This commit is contained in:
@@ -1173,6 +1173,11 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
|
||||
target != targets.end(); ++target)
|
||||
{
|
||||
bool shared = (target->second.GetType() == cmTarget::SHARED_LIBRARY);
|
||||
std::string exportsDef = "";
|
||||
if(shared)
|
||||
{
|
||||
exportsDef = "-D"+target->first+"_EXPORTS ";
|
||||
}
|
||||
// Iterate over every source for this target.
|
||||
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles();
|
||||
for(std::vector<cmSourceFile>::const_iterator source = sources.begin();
|
||||
@@ -1217,12 +1222,12 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
|
||||
std::string ext = source->GetSourceExtension();
|
||||
if ( ext == "cxx" || ext == "cc" || ext == "cpp" || ext == "C" )
|
||||
{
|
||||
fout << "\t${CMAKE_CXX_COMPILER} ${CMAKE_CXXFLAGS} "
|
||||
fout << "\t${CMAKE_CXX_COMPILER} ${CMAKE_CXXFLAGS} " << exportsDef.c_str()
|
||||
<< (shared? "${CMAKE_SHLIB_CFLAGS} ":"") << "${INCLUDE_FLAGS} -c $< -o $@\n\n";
|
||||
}
|
||||
else if ( ext == "c" )
|
||||
{
|
||||
fout << "\t${CMAKE_C_COMPILER} ${CMAKE_CFLAGS} "
|
||||
fout << "\t${CMAKE_C_COMPILER} ${CMAKE_CFLAGS} " << exportsDef.c_str()
|
||||
<< (shared? "${CMAKE_SHLIB_CFLAGS} ":"") << "${INCLUDE_FLAGS} -c $< -o $@\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user