diff options
author | Brad King <brad.king@kitware.com> | 2017-03-13 15:54:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-03-21 14:02:34 (GMT) |
commit | 075f6454092ae058add228eda8220a3680b2f9e4 (patch) | |
tree | c0bff4ce5eaf25b8e38d904f3cfb64ebfc13265b /Source/cmMakefileTargetGenerator.cxx | |
parent | 21c4ec4ffe1c40382f6b435ff49eade31e1137f2 (diff) | |
download | CMake-075f6454092ae058add228eda8220a3680b2f9e4.zip CMake-075f6454092ae058add228eda8220a3680b2f9e4.tar.gz CMake-075f6454092ae058add228eda8220a3680b2f9e4.tar.bz2 |
Support WINDOWS_EXPORT_ALL_SYMBOLS with `.def` files
The `WINDOWS_EXPORT_ALL_SYMBOLS` target property exports all symbols
found in object files explicitly given to the linker. However, the
linker may also find additional symbols in dependencies and copy them
into the linked binary (e.g. from `msvcrt.lib`). Provide a way to
export an explicit list of such symbols by adding a `.def` file as a
source file.
Fixes: #16473
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1fa8702..ed38024 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1414,10 +1414,14 @@ void cmMakefileTargetGenerator::AppendLinkDepends( this->AppendTargetDepends(depends); // Add a dependency on the link definitions file, if any. - cmGeneratorTarget::ModuleDefinitionInfo const* mdi = - this->GeneratorTarget->GetModuleDefinitionInfo(this->GetConfigName()); - if (mdi && !mdi->WindowsExportAllSymbols && !mdi->DefFile.empty()) { - depends.push_back(mdi->DefFile); + if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo( + this->GetConfigName())) { + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + depends.push_back((*i)->GetFullPath()); + } } // Add a dependency on user-specified manifest files, if any. @@ -1724,7 +1728,7 @@ void cmMakefileTargetGenerator::GenDefFile( { cmGeneratorTarget::ModuleDefinitionInfo const* mdi = this->GeneratorTarget->GetModuleDefinitionInfo(this->GetConfigName()); - if (!mdi || !mdi->WindowsExportAllSymbols) { + if (!mdi || !mdi->DefFileGenerated) { return; } std::string cmd = cmSystemTools::GetCMakeCommand(); @@ -1744,15 +1748,24 @@ void cmMakefileTargetGenerator::GenDefFile( real_link_commands.insert(real_link_commands.begin(), cmd); // create a list of obj files for the -E __create_def to read cmGeneratedFileStream fout(objlist_file.c_str()); - for (std::vector<std::string>::const_iterator i = this->Objects.begin(); - i != this->Objects.end(); ++i) { - if (cmHasLiteralSuffix(*i, ".obj")) { + + if (mdi->WindowsExportAllSymbols) { + for (std::vector<std::string>::const_iterator i = this->Objects.begin(); + i != this->Objects.end(); ++i) { + if (cmHasLiteralSuffix(*i, ".obj")) { + fout << *i << "\n"; + } + } + for (std::vector<std::string>::const_iterator i = + this->ExternalObjects.begin(); + i != this->ExternalObjects.end(); ++i) { fout << *i << "\n"; } } - for (std::vector<std::string>::const_iterator i = - this->ExternalObjects.begin(); - i != this->ExternalObjects.end(); ++i) { - fout << *i << "\n"; + + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + fout << (*i)->GetFullPath() << "\n"; } } |