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:
Brad King 2001-07-10 11:46:20 -04:00
parent e0fa3f281c
commit e5a3ad77e5
1 changed files with 7 additions and 2 deletions

View File

@ -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";
}
}