Windows: Optionally generate DLL module definition files automatically

Create target property WINDOWS_EXPORT_ALL_SYMBOLS to automatically
generate a module definition file from MS-compatible .obj files and give
it to the linker in order to export all symbols from the .dll part of a
SHARED library.
This commit is contained in:
Bill Hoffman
2015-06-19 16:12:43 -04:00
committed by Brad King
parent 069aa93b55
commit 8f86407cfd
26 changed files with 455 additions and 3 deletions
+28 -2
View File
@@ -2466,6 +2466,15 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
"%(IgnoreSpecificDefaultLibraries)");
}
if (this->Target->GetType() == cmTarget::SHARED_LIBRARY &&
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
{
if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
{
linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)exportall.def");
}
}
this->LinkOptions[config] = pOptions.release();
return true;
}
@@ -2613,8 +2622,25 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
void
cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
{
this->WriteEvent("PreLinkEvent",
this->Target->GetPreLinkCommands(), configName);
bool addedPrelink = false;
if (this->Target->GetType() == cmTarget::SHARED_LIBRARY &&
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
{
if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
{
addedPrelink = true;
std::vector<cmCustomCommand> commands =
this->Target->GetPreLinkCommands();
this->GlobalGenerator->AddSymbolExportCommand(
this->GeneratorTarget, commands, configName);
this->WriteEvent("PreLinkEvent", commands, configName);
}
}
if (!addedPrelink)
{
this->WriteEvent("PreLinkEvent",
this->Target->GetPreLinkCommands(), configName);
}
this->WriteEvent("PreBuildEvent",
this->Target->GetPreBuildCommands(), configName);
this->WriteEvent("PostBuildEvent",