From 9da725cb00d25c7d3f45e8ee8c943ec5241d6227 Mon Sep 17 00:00:00 2001 From: Yury Zhuravlev Date: Sun, 10 Jul 2016 20:24:43 +0300 Subject: Windows: Honor WINDOWS_EXPORT_ALL_SYMBOLS for executables with exports For executables with ENABLE_EXPORTS set, export all symbols when instructed to do so by WINDOWS_EXPORT_ALL_SYMBOLS. --- Source/cmLocalVisualStudio7Generator.cxx | 6 ++++-- Source/cmMakefileExecutableTargetGenerator.cxx | 6 ++++++ Source/cmNinjaNormalTargetGenerator.cxx | 6 ++++-- Source/cmTarget.cxx | 3 ++- Source/cmVisualStudio10TargetGenerator.cxx | 6 ++++-- 5 files changed, 20 insertions(+), 7 deletions(-) (limited to 'Source') diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index c38e99c448..e72abe9572 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1013,7 +1013,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } - if (target->GetType() == cmState::SHARED_LIBRARY && + if ((target->GetType() == cmState::SHARED_LIBRARY || + target->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)/exportall.def"); @@ -1836,7 +1837,8 @@ void cmLocalVisualStudio7Generator::OutputTargetRules( tool = this->FortranProject ? "VFPreLinkEventTool" : "VCPreLinkEventTool"; event.Start(tool); bool addedPrelink = false; - if (target->GetType() == cmState::SHARED_LIBRARY && + if ((target->GetType() == cmState::SHARED_LIBRARY || + target->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { addedPrelink = true; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 9a37a332b7..8730ccd671 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -318,6 +318,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->CreateObjectLists(useLinkScript, false, useResponseFileForObjects, buildObjs, depends, useWatcomQuote); + // maybe create .def file from list of objects + if (this->GeneratorTarget->IsExecutableWithExports() && + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { + this->GenDefFile(real_link_commands, linkFlags); + } + std::string manifests = this->GetManifests(); cmLocalGenerator::RuleVariables vars; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 77d3901dc1..81a1618385 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -472,7 +472,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget, useWatcomQuote); if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && - gt.GetType() == cmState::SHARED_LIBRARY) { + (gt.GetType() == cmState::SHARED_LIBRARY || + gt.IsExecutableWithExports())) { if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { std::string name_of_def_file = gt.GetSupportDirectory(); name_of_def_file += "/" + gt.GetName(); @@ -599,7 +600,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // maybe create .def file from list of objects - if (gt.GetType() == cmState::SHARED_LIBRARY && + if ((gt.GetType() == cmState::SHARED_LIBRARY || + gt.IsExecutableWithExports()) && this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { std::string cmakeCommand = diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ceebf93158..8476538674 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -253,7 +253,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->TargetTypeValue == cmState::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - if (this->TargetTypeValue == cmState::SHARED_LIBRARY) { + if (this->TargetTypeValue == cmState::SHARED_LIBRARY || + this->TargetTypeValue == cmState::EXECUTABLE) { this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", CM_NULLPTR); } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 13e7c89922..50da41b7c7 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2343,7 +2343,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( "%(IgnoreSpecificDefaultLibraries)"); } - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && + if ((this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (this->GeneratorTarget->GetPropertyAsBool( "WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -2506,7 +2507,8 @@ void cmVisualStudio10TargetGenerator::WriteEvents( std::string const& configName) { bool addedPrelink = false; - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && + if ((this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (this->GeneratorTarget->GetPropertyAsBool( "WINDOWS_EXPORT_ALL_SYMBOLS")) { -- cgit v1.2.1