Makefile: Factor out WINDOWS_EXPORT_ALL_SYMBOLS helper
Factor the implementation out of cmMakefileLibraryTargetGenerator into a helper method in cmMakefileTargetGenerator so it can be re-used elsewhere later.
This commit is contained in:
parent
f2c1900a71
commit
2005b96067
|
@ -521,48 +521,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
|
|||
// maybe create .def file from list of objects
|
||||
if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY &&
|
||||
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
|
||||
if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"WINDOWS_EXPORT_ALL_SYMBOLS")) {
|
||||
std::string name_of_def_file =
|
||||
this->GeneratorTarget->GetSupportDirectory();
|
||||
name_of_def_file +=
|
||||
std::string("/") + this->GeneratorTarget->GetName();
|
||||
name_of_def_file += ".def";
|
||||
std::string cmd = cmSystemTools::GetCMakeCommand();
|
||||
cmd = this->Convert(cmd, cmOutputConverter::NONE,
|
||||
cmOutputConverter::SHELL);
|
||||
cmd += " -E __create_def ";
|
||||
cmd += this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
|
||||
cmOutputConverter::SHELL);
|
||||
cmd += " ";
|
||||
std::string objlist_file = name_of_def_file;
|
||||
objlist_file += ".objs";
|
||||
cmd += this->Convert(objlist_file, cmOutputConverter::START_OUTPUT,
|
||||
cmOutputConverter::SHELL);
|
||||
real_link_commands.push_back(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")) {
|
||||
fout << *i << "\n";
|
||||
}
|
||||
}
|
||||
for (std::vector<std::string>::const_iterator i =
|
||||
this->ExternalObjects.begin();
|
||||
i != this->ExternalObjects.end(); ++i) {
|
||||
fout << *i << "\n";
|
||||
}
|
||||
// now add the def file link flag
|
||||
linkFlags += " ";
|
||||
linkFlags +=
|
||||
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||
linkFlags +=
|
||||
this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
|
||||
cmOutputConverter::SHELL);
|
||||
linkFlags += " ";
|
||||
}
|
||||
this->GenDefFile(real_link_commands, linkFlags);
|
||||
}
|
||||
|
||||
std::string manifests = this->GetManifests();
|
||||
|
|
|
@ -1595,3 +1595,46 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
|
|||
this->LocalGenerator->AppendFlags(flags, includeFlags);
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefileTargetGenerator::GenDefFile(
|
||||
std::vector<std::string>& real_link_commands, std::string& linkFlags)
|
||||
{
|
||||
if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) {
|
||||
std::string name_of_def_file =
|
||||
this->GeneratorTarget->GetSupportDirectory();
|
||||
name_of_def_file += std::string("/") + this->GeneratorTarget->GetName();
|
||||
name_of_def_file += ".def";
|
||||
std::string cmd = cmSystemTools::GetCMakeCommand();
|
||||
cmd =
|
||||
this->Convert(cmd, cmOutputConverter::NONE, cmOutputConverter::SHELL);
|
||||
cmd += " -E __create_def ";
|
||||
cmd += this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
|
||||
cmOutputConverter::SHELL);
|
||||
cmd += " ";
|
||||
std::string objlist_file = name_of_def_file;
|
||||
objlist_file += ".objs";
|
||||
cmd += this->Convert(objlist_file, cmOutputConverter::START_OUTPUT,
|
||||
cmOutputConverter::SHELL);
|
||||
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")) {
|
||||
fout << *i << "\n";
|
||||
}
|
||||
}
|
||||
for (std::vector<std::string>::const_iterator i =
|
||||
this->ExternalObjects.begin();
|
||||
i != this->ExternalObjects.end(); ++i) {
|
||||
fout << *i << "\n";
|
||||
}
|
||||
// now add the def file link flag
|
||||
linkFlags += " ";
|
||||
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||
linkFlags +=
|
||||
this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
|
||||
cmOutputConverter::SHELL);
|
||||
linkFlags += " ";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,6 +162,10 @@ protected:
|
|||
std::vector<std::string>& makefile_depends,
|
||||
bool useWatcomQuote);
|
||||
|
||||
/** Add commands for generate def files */
|
||||
void GenDefFile(std::vector<std::string>& real_link_commands,
|
||||
std::string& linkFlags);
|
||||
|
||||
void AddIncludeFlags(std::string& flags,
|
||||
const std::string& lang) CM_OVERRIDE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue