summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-04-10 20:41:03 (GMT)
committerBrad King <brad.king@kitware.com>2017-04-13 20:10:31 (GMT)
commit40aa6c059c3beebabf8fa433b768192300331e50 (patch)
treedc11ffd7d34ec380c1f3d7cd19349fa1b4300bd6
parente155fba644d4686ac8b4f43dfe31c749bba30c67 (diff)
downloadCMake-40aa6c059c3beebabf8fa433b768192300331e50.zip
CMake-40aa6c059c3beebabf8fa433b768192300331e50.tar.gz
CMake-40aa6c059c3beebabf8fa433b768192300331e50.tar.bz2
cmGeneratorTarget: Add method to collect all sources for all configs
Multi-config generators like VS and Xcode need to loop over all the source files first and then handle per-config information within each one. Teach cmGeneratorTarget to provide such a view.
-rw-r--r--Source/cmGeneratorTarget.cxx37
-rw-r--r--Source/cmGeneratorTarget.h15
2 files changed, 52 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 5e4259d..4c8a2c6 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1069,6 +1069,43 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
}
}
+std::vector<cmGeneratorTarget::AllConfigSource> const&
+cmGeneratorTarget::GetAllConfigSources() const
+{
+ if (this->AllConfigSources.empty()) {
+ this->ComputeAllConfigSources();
+ }
+ return this->AllConfigSources;
+}
+
+void cmGeneratorTarget::ComputeAllConfigSources() const
+{
+ std::vector<std::string> configs;
+ this->Makefile->GetConfigurations(configs);
+
+ std::map<cmSourceFile const*, size_t> index;
+
+ for (size_t ci = 0; ci < configs.size(); ++ci) {
+ KindedSources const& sources = this->GetKindedSources(configs[ci]);
+ for (std::vector<cmGeneratorTarget::SourceAndKind>::const_iterator si =
+ sources.Sources.begin();
+ si != sources.Sources.end(); ++si) {
+ std::map<cmSourceFile const*, size_t>::iterator mi =
+ index.find(si->Source);
+ if (mi == index.end()) {
+ AllConfigSource acs;
+ acs.Source = si->Source;
+ acs.Kind = si->Kind;
+ this->AllConfigSources.push_back(acs);
+ std::map<cmSourceFile const*, size_t>::value_type entry(
+ si->Source, this->AllConfigSources.size() - 1);
+ mi = index.insert(entry).first;
+ }
+ this->AllConfigSources[mi->second].Configs.push_back(ci);
+ }
+ }
+}
+
std::string cmGeneratorTarget::GetCompilePDBName(
const std::string& config) const
{
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 7c86d30..dd25cad 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -12,6 +12,7 @@
#include <map>
#include <set>
+#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
@@ -107,6 +108,17 @@ public:
/** Get all sources needed for a configuration with kinds assigned. */
KindedSources const& GetKindedSources(std::string const& config) const;
+ struct AllConfigSource
+ {
+ cmSourceFile const* Source;
+ cmGeneratorTarget::SourceKind Kind;
+ std::vector<size_t> Configs;
+ };
+
+ /** Get all sources needed for all configurations with kinds and
+ per-source configurations assigned. */
+ std::vector<AllConfigSource> const& GetAllConfigSources() const;
+
void GetObjectSources(std::vector<cmSourceFile const*>&,
const std::string& config) const;
const std::string& GetObjectName(cmSourceFile const* file);
@@ -731,6 +743,9 @@ private:
void ComputeKindedSources(KindedSources& files,
std::string const& config) const;
+ mutable std::vector<AllConfigSource> AllConfigSources;
+ void ComputeAllConfigSources() const;
+
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
std::vector<TargetPropertyEntry*> CompileFeaturesEntries;