mirror of
https://github.com/reactos/CMake.git
synced 2025-02-03 18:42:32 +00:00
Merge topic 'vs-remove-UseObjectLibraries'
f4af14ad VS: Simplify logic collecting object library files as sources 10772c51 VS: Simplify use of object libraries in WINDOWS_EXPORT_ALL_SYMBOLS 22829a13 cmMakefile: Create an explicit "Object Libraries" source group Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !686
This commit is contained in:
commit
ff4fa70c20
@ -14,7 +14,6 @@
|
|||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmOutputConverter.h"
|
#include "cmOutputConverter.h"
|
||||||
#include "cmPolicies.h"
|
#include "cmPolicies.h"
|
||||||
#include "cmSourceFile.h"
|
|
||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
@ -34,6 +33,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
class cmSourceFile;
|
||||||
|
|
||||||
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
||||||
std::string const& prop, cmLocalGenerator* lg,
|
std::string const& prop, cmLocalGenerator* lg,
|
||||||
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
|
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
|
||||||
@ -1265,6 +1266,8 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
|||||||
|
|
||||||
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
||||||
|
|
||||||
|
cmMakefile* mf = context->LG->GetMakefile();
|
||||||
|
|
||||||
std::string obj_dir = gt->ObjectDirectory;
|
std::string obj_dir = gt->ObjectDirectory;
|
||||||
std::string result;
|
std::string result;
|
||||||
const char* sep = "";
|
const char* sep = "";
|
||||||
@ -1278,10 +1281,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
|||||||
assert(!map_it->second.empty());
|
assert(!map_it->second.empty());
|
||||||
result += sep;
|
result += sep;
|
||||||
std::string objFile = obj_dir + map_it->second;
|
std::string objFile = obj_dir + map_it->second;
|
||||||
cmSourceFile* sf =
|
mf->AddTargetObject(tgtName, objFile);
|
||||||
context->LG->GetMakefile()->GetOrCreateSource(objFile, true);
|
|
||||||
sf->SetObjectLibrary(tgtName);
|
|
||||||
sf->SetProperty("EXTERNAL_OBJECT", "1");
|
|
||||||
result += objFile;
|
result += objFile;
|
||||||
sep = ";";
|
sep = ";";
|
||||||
}
|
}
|
||||||
|
@ -887,7 +887,6 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
|
|||||||
objs.push_back((*it)->GetFullPath());
|
objs.push_back((*it)->GetFullPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
gt->UseObjectLibraries(objs, configName);
|
|
||||||
for (std::vector<std::string>::iterator it = objs.begin();
|
for (std::vector<std::string>::iterator it = objs.begin();
|
||||||
it != objs.end(); ++it) {
|
it != objs.end(); ++it) {
|
||||||
std::string objFile = *it;
|
std::string objFile = *it;
|
||||||
|
@ -1306,14 +1306,21 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
|
|||||||
// list object library content on the link line instead.
|
// list object library content on the link line instead.
|
||||||
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
|
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
|
||||||
std::string currentBinDir = lg->GetCurrentBinaryDirectory();
|
std::string currentBinDir = lg->GetCurrentBinaryDirectory();
|
||||||
std::vector<std::string> objs;
|
|
||||||
gt->UseObjectLibraries(objs, "");
|
std::vector<cmSourceFile*> sources;
|
||||||
|
if (!gt->GetConfigCommonSourceFiles(sources)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const char* sep = isep ? isep : "";
|
const char* sep = isep ? isep : "";
|
||||||
for (std::vector<std::string>::const_iterator oi = objs.begin();
|
for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
|
||||||
oi != objs.end(); ++oi) {
|
i != sources.end(); i++) {
|
||||||
std::string rel = lg->ConvertToRelativePath(currentBinDir, oi->c_str());
|
if (!(*i)->GetObjectLibrary().empty()) {
|
||||||
fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
|
std::string const& objFile = (*i)->GetFullPath();
|
||||||
sep = " ";
|
std::string rel = lg->ConvertToRelativePath(currentBinDir, objFile);
|
||||||
|
fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
|
||||||
|
sep = " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1370,7 +1377,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
|||||||
for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
|
for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
|
||||||
i != classes.end(); i++) {
|
i != classes.end(); i++) {
|
||||||
if (!(*i)->GetObjectLibrary().empty()) {
|
if (!(*i)->GetObjectLibrary().empty()) {
|
||||||
continue;
|
if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 ||
|
||||||
|
this->FortranProject) {
|
||||||
|
// VS < 8 does not support per-config source locations so we
|
||||||
|
// list object library content on the link line instead.
|
||||||
|
// See OutputObjects.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add the file to the list of sources.
|
// Add the file to the list of sources.
|
||||||
std::string source = (*i)->GetFullPath();
|
std::string source = (*i)->GetFullPath();
|
||||||
@ -1392,24 +1405,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
|||||||
this->WriteGroup(&sg, target, fout, libName, configs);
|
this->WriteGroup(&sg, target, fout, libName, configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8 &&
|
|
||||||
!this->FortranProject) {
|
|
||||||
// VS >= 8 support per-config source locations so we
|
|
||||||
// list object library content as external objects.
|
|
||||||
std::vector<std::string> objs;
|
|
||||||
target->UseObjectLibraries(objs, "");
|
|
||||||
if (!objs.empty()) {
|
|
||||||
// TODO: Separate sub-filter for each object library used?
|
|
||||||
fout << "\t\t<Filter Name=\"Object Libraries\">\n";
|
|
||||||
for (std::vector<std::string>::const_iterator oi = objs.begin();
|
|
||||||
oi != objs.end(); ++oi) {
|
|
||||||
std::string o = this->ConvertToXMLOutputPathSingle(oi->c_str());
|
|
||||||
fout << "\t\t\t<File RelativePath=\"" << o << "\" />\n";
|
|
||||||
}
|
|
||||||
fout << "\t\t</Filter>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fout << "\t</Files>\n";
|
fout << "\t</Files>\n";
|
||||||
|
|
||||||
// Write the VCProj file's footer.
|
// Write the VCProj file's footer.
|
||||||
|
@ -94,6 +94,10 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
|
|||||||
this->AddSourceGroup("CMake Rules", "\\.rule$");
|
this->AddSourceGroup("CMake Rules", "\\.rule$");
|
||||||
this->AddSourceGroup("Resources", "\\.plist$");
|
this->AddSourceGroup("Resources", "\\.plist$");
|
||||||
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
||||||
|
|
||||||
|
this->ObjectLibrariesSourceGroupIndex = this->SourceGroups.size();
|
||||||
|
this->SourceGroups.push_back(
|
||||||
|
cmSourceGroup("Object Libraries", "^MATCH_NO_SOURCES$"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3124,6 +3128,18 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
|||||||
return this->CreateSource(sourceName, generated);
|
return this->CreateSource(sourceName, generated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmMakefile::AddTargetObject(std::string const& tgtName,
|
||||||
|
std::string const& objFile)
|
||||||
|
{
|
||||||
|
cmSourceFile* sf = this->GetOrCreateSource(objFile, true);
|
||||||
|
sf->SetObjectLibrary(tgtName);
|
||||||
|
sf->SetProperty("EXTERNAL_OBJECT", "1");
|
||||||
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
|
this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile(
|
||||||
|
sf->GetFullPath());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
|
void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
|
||||||
bool optional)
|
bool optional)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
#include <stddef.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -406,6 +407,8 @@ public:
|
|||||||
cmSourceFile* GetOrCreateSource(const std::string& sourceName,
|
cmSourceFile* GetOrCreateSource(const std::string& sourceName,
|
||||||
bool generated = false);
|
bool generated = false);
|
||||||
|
|
||||||
|
void AddTargetObject(std::string const& tgtName, std::string const& objFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a variable name, return its value (as a string).
|
* Given a variable name, return its value (as a string).
|
||||||
* If the variable is not found in this makefile instance, the
|
* If the variable is not found in this makefile instance, the
|
||||||
@ -817,6 +820,7 @@ protected:
|
|||||||
|
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
std::vector<cmSourceGroup> SourceGroups;
|
std::vector<cmSourceGroup> SourceGroups;
|
||||||
|
size_t ObjectLibrariesSourceGroupIndex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<cmCommand*> FinalPassCommands;
|
std::vector<cmCommand*> FinalPassCommands;
|
||||||
|
@ -1337,23 +1337,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
|||||||
this->WriteString("</ItemGroup>\n", 1);
|
this->WriteString("</ItemGroup>\n", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add object library contents as external objects.
|
|
||||||
std::vector<std::string> objs;
|
|
||||||
this->GeneratorTarget->UseObjectLibraries(objs, "");
|
|
||||||
if (!objs.empty()) {
|
|
||||||
this->WriteString("<ItemGroup>\n", 1);
|
|
||||||
for (std::vector<std::string>::const_iterator oi = objs.begin();
|
|
||||||
oi != objs.end(); ++oi) {
|
|
||||||
std::string obj = *oi;
|
|
||||||
this->WriteString("<Object Include=\"", 2);
|
|
||||||
this->ConvertToWindowsSlash(obj);
|
|
||||||
(*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n";
|
|
||||||
this->WriteString("<Filter>Object Libraries</Filter>\n", 3);
|
|
||||||
this->WriteString("</Object>\n", 2);
|
|
||||||
}
|
|
||||||
this->WriteString("</ItemGroup>\n", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->WriteString("<ItemGroup>\n", 1);
|
this->WriteString("<ItemGroup>\n", 1);
|
||||||
for (std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
|
for (std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
|
||||||
g != groupsUsed.end(); ++g) {
|
g != groupsUsed.end(); ++g) {
|
||||||
@ -1371,15 +1354,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
|||||||
this->WriteString("</Filter>\n", 2);
|
this->WriteString("</Filter>\n", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!objs.empty()) {
|
|
||||||
this->WriteString("<Filter Include=\"Object Libraries\">\n", 2);
|
|
||||||
std::string guidName = "SG_Filter_Object Libraries";
|
|
||||||
this->WriteString("<UniqueIdentifier>", 3);
|
|
||||||
std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str());
|
|
||||||
(*this->BuildFileStream) << "{" << guid << "}"
|
|
||||||
<< "</UniqueIdentifier>\n";
|
|
||||||
this->WriteString("</Filter>\n", 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!resxObjs.empty() || !this->AddedFiles.empty()) {
|
if (!resxObjs.empty() || !this->AddedFiles.empty()) {
|
||||||
this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
|
this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
|
||||||
@ -1824,14 +1798,6 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
|
|||||||
|
|
||||||
std::vector<cmSourceFile const*> externalObjects;
|
std::vector<cmSourceFile const*> externalObjects;
|
||||||
this->GeneratorTarget->GetExternalObjects(externalObjects, "");
|
this->GeneratorTarget->GetExternalObjects(externalObjects, "");
|
||||||
for (std::vector<cmSourceFile const*>::iterator si = externalObjects.begin();
|
|
||||||
si != externalObjects.end();) {
|
|
||||||
if (!(*si)->GetObjectLibrary().empty()) {
|
|
||||||
si = externalObjects.erase(si);
|
|
||||||
} else {
|
|
||||||
++si;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this->LocalGenerator->GetVersion() >
|
if (this->LocalGenerator->GetVersion() >
|
||||||
cmGlobalVisualStudioGenerator::VS10) {
|
cmGlobalVisualStudioGenerator::VS10) {
|
||||||
// For VS >= 11 we use LinkObjects to avoid linking custom command
|
// For VS >= 11 we use LinkObjects to avoid linking custom command
|
||||||
@ -1857,17 +1823,6 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
|
|||||||
this->WriteExtraSource(*si);
|
this->WriteExtraSource(*si);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add object library contents as external objects.
|
|
||||||
std::vector<std::string> objs;
|
|
||||||
this->GeneratorTarget->UseObjectLibraries(objs, "");
|
|
||||||
for (std::vector<std::string>::const_iterator oi = objs.begin();
|
|
||||||
oi != objs.end(); ++oi) {
|
|
||||||
std::string obj = *oi;
|
|
||||||
this->WriteString("<Object Include=\"", 2);
|
|
||||||
this->ConvertToWindowsSlash(obj);
|
|
||||||
(*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\" />\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<cmSourceFile const*> defSources;
|
std::vector<cmSourceFile const*> defSources;
|
||||||
this->GeneratorTarget->GetModuleDefinitionSources(defSources, "");
|
this->GeneratorTarget->GetModuleDefinitionSources(defSources, "");
|
||||||
this->WriteSources("None", defSources);
|
this->WriteSources("None", defSources);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user