summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-07-20 11:30:38 -0400
committerBrad King <brad.king@kitware.com>2020-07-23 13:31:44 -0400
commit422d9a0ab21ff430e5fd012cf965dd92068d185f (patch)
tree9aeabc71a17acf32289eb19890d7d58b8aa58c21
parentbce82df0aaa4046b31fcf0608f0ce1249bdfc9bd (diff)
downloadcmake-422d9a0ab21ff430e5fd012cf965dd92068d185f.tar.gz
Factor out generator checks for filtering out interface libraries
Add a `cmGeneratorTarget::IsInBuildSystem` helper method to tell generators whether a target should participate in the generated build system.
-rw-r--r--Source/cmComputeTargetDepends.cxx9
-rw-r--r--Source/cmGeneratorTarget.cxx23
-rw-r--r--Source/cmGeneratorTarget.h1
-rw-r--r--Source/cmGlobalCommonGenerator.cxx7
-rw-r--r--Source/cmGlobalGenerator.cxx4
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx7
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx6
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx18
-rw-r--r--Source/cmLocalGenerator.cxx4
-rw-r--r--Source/cmLocalGhsMultiGenerator.cxx3
-rw-r--r--Source/cmLocalNinjaGenerator.cxx2
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx2
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx2
19 files changed, 58 insertions, 48 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 6b4d110f91..6846f57e64 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -184,7 +184,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{
// Get the depender.
cmGeneratorTarget const* depender = this->Targets[depender_index];
- if (depender->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!depender->IsInBuildSystem()) {
return;
}
@@ -356,10 +356,9 @@ void cmComputeTargetDepends::AddTargetDepend(
int depender_index, cmGeneratorTarget const* dependee,
cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross)
{
- if (dependee->IsImported() ||
- dependee->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- // Skip IMPORTED and INTERFACE targets but follow their utility
- // dependencies.
+ if (!dependee->IsInBuildSystem()) {
+ // Skip targets that are not in the buildsystem but follow their
+ // utility dependencies.
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
for (cmLinkItem const& i : utils) {
if (cmGeneratorTarget const* transitive_dependee = i.Target) {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index bfefbe6682..9978320ad7 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1089,6 +1089,27 @@ std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPostBuildCommands()
return this->Target->GetPostBuildCommands();
}
+bool cmGeneratorTarget::IsInBuildSystem() const
+{
+ if (this->IsImported()) {
+ return false;
+ }
+ switch (this->Target->GetType()) {
+ case cmStateEnums::EXECUTABLE:
+ case cmStateEnums::STATIC_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ case cmStateEnums::UTILITY:
+ case cmStateEnums::GLOBAL_TARGET:
+ return true;
+ case cmStateEnums::INTERFACE_LIBRARY:
+ case cmStateEnums::UNKNOWN_LIBRARY:
+ break;
+ }
+ return false;
+}
+
bool cmGeneratorTarget::IsImported() const
{
return this->Target->IsImported();
@@ -1365,7 +1386,7 @@ void AddSwiftImplicitIncludeDirectories(
for (const cmLinkImplItem& library : libraries->Libraries) {
if (const cmGeneratorTarget* dependency = library.Target) {
- if (dependency->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!dependency->IsInBuildSystem()) {
continue;
}
if (cm::contains(dependency->GetAllConfigCompileLanguages(),
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 08aa015923..65683e6efe 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -45,6 +45,7 @@ public:
cmGlobalGenerator* GetGlobalGenerator() const;
+ bool IsInBuildSystem() const;
bool IsImported() const;
bool IsImportedGloballyVisible() const;
const std::string& GetLocation(const std::string& config) const;
diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx
index 5eff3b894d..9e5bbca003 100644
--- a/Source/cmGlobalCommonGenerator.cxx
+++ b/Source/cmGlobalCommonGenerator.cxx
@@ -42,12 +42,7 @@ cmGlobalCommonGenerator::ComputeDirectoryTargets() const
// for all targets in the directory.
for (const auto& gt : lg->GetGeneratorTargets()) {
cmStateEnums::TargetType const type = gt->GetType();
- if (type != cmStateEnums::EXECUTABLE &&
- type != cmStateEnums::STATIC_LIBRARY &&
- type != cmStateEnums::SHARED_LIBRARY &&
- type != cmStateEnums::MODULE_LIBRARY &&
- type != cmStateEnums::OBJECT_LIBRARY &&
- type != cmStateEnums::UTILITY) {
+ if (type == cmStateEnums::GLOBAL_TARGET || !gt->IsInBuildSystem()) {
continue;
}
DirectoryTarget::Target t;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5c07e31b91..b79dfdea2f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2165,7 +2165,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
const cmGeneratorTarget* target) const
{
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
return true;
}
cmMakefile* mf = root->GetMakefile();
@@ -3054,7 +3054,7 @@ void cmGlobalGenerator::WriteSummary()
for (const auto& lg : this->LocalGenerators) {
for (const auto& tgt : lg->GetGeneratorTargets()) {
- if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!tgt->IsInBuildSystem()) {
continue;
}
this->WriteSummary(tgt.get());
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 1664dd0861..996946551d 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -467,7 +467,7 @@ void cmGlobalGhsMultiGenerator::WriteAllTarget(
this->ProjectTargets.push_back(t);
}
for (cmGeneratorTarget const* t : sortedProjectTargets) {
- if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!t->IsInBuildSystem()) {
continue;
}
if (!IsExcluded(t->GetLocalGenerator(), t)) {
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 80eae8284e..86ed1e96ac 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1129,7 +1129,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
cmNinjaDeps outs;
for (cmTargetDepend const& targetDep :
this->GetTargetDirectDepends(target)) {
- if (targetDep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!targetDep->IsInBuildSystem()) {
continue;
}
if (targetDep.IsCross()) {
@@ -1171,7 +1171,7 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
cmNinjaOuts this_outs; // this will be the new cache entry
for (auto const& dep_target : this->GetTargetDirectDepends(target)) {
- if (dep_target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ if (!dep_target->IsInBuildSystem() ||
(this->EnableCrossConfigBuild() && !dep_target.IsCross())) {
continue;
}
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 1764429960..ebc90b61e1 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -845,8 +845,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
for (const auto& gt : lg->GetGeneratorTargets()) {
cmLocalGenerator* tlg = gt->GetLocalGenerator();
- if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
- IsExcluded(lg.get(), gt.get())) {
+ if (!gt->IsInBuildSystem() || IsExcluded(lg.get(), gt.get())) {
continue;
}
@@ -881,7 +880,7 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget(
if (emitted.insert(target).second) {
count = this->ProgressMap[target].Marks.size();
for (cmTargetDepend const& depend : this->GetTargetDirectDepends(target)) {
- if (depend->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!depend->IsInBuildSystem()) {
continue;
}
count += this->CountProgressMarksInTarget(depend, emitted);
@@ -938,7 +937,7 @@ void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends(
for (cmTargetDepend const& i : this->GetTargetDirectDepends(target)) {
// Create the target-level dependency.
cmGeneratorTarget const* dep = i;
- if (dep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!dep->IsInBuildSystem()) {
continue;
}
cmLocalUnixMakefileGenerator3* lg3 =
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index c851eea323..f8b438a63e 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -339,7 +339,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
// loop over again and write out configurations for each target
// in the solution
for (cmGeneratorTarget const* target : projectTargets) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
cmProp expath = target->GetProperty("EXTERNAL_MSPROJECT");
@@ -369,7 +369,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
for (cmGeneratorTarget const* target : projectTargets) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
bool written = false;
@@ -436,7 +436,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
std::ostream& fout, OrderedTargetDependSet const& projectTargets)
{
for (cmGeneratorTarget const* target : projectTargets) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
cmProp vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 29ca1549c5..fcdfc5064e 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -325,7 +325,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
OrderedTargetDependSet depends(unordered, std::string());
for (cmTargetDepend const& i : depends) {
- if (i->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!i->IsInBuildSystem()) {
continue;
}
std::string guid = this->GetGUID(i->GetName());
@@ -341,7 +341,7 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
if (cmGeneratorTarget* depTarget =
target->GetLocalGenerator()->FindGeneratorTargetToUse(
ui.Value.first)) {
- if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
+ if (depTarget->IsInBuildSystem() &&
depTarget->GetProperty("EXTERNAL_MSPROJECT")) {
// This utility dependency names an external .vcproj target.
// We use LinkLibraryDependencies="true" to link to it without
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index b31d069b13..001d876650 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -368,7 +368,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target)
void cmGlobalVisualStudioGenerator::FollowLinkDepends(
const cmGeneratorTarget* target, std::set<const cmGeneratorTarget*>& linked)
{
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
return;
}
if (linked.insert(target).second &&
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index e54de5d14d..26760ead98 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1199,7 +1199,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
return true;
}
- if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!gtgt->IsInBuildSystem()) {
return true;
}
@@ -1845,7 +1845,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
cmXCodeObject* buildSettings,
const std::string& configName)
{
- if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!gtgt->IsInBuildSystem()) {
return;
}
@@ -2678,7 +2678,7 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases)
{
- if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!gtgt->IsInBuildSystem()) {
return nullptr;
}
cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
@@ -2821,7 +2821,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
cmSystemTools::Error("Error no target on xobject\n");
return;
}
- if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!gt->IsInBuildSystem()) {
return;
}
@@ -3113,13 +3113,9 @@ bool cmGlobalXCodeGenerator::CreateGroups(
// end up with (empty anyhow) ZERO_CHECK, install, or test source
// groups:
//
- if (gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
- continue;
- }
- if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- continue;
- }
- if (gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ if (!gtgt->IsInBuildSystem() ||
+ gtgt->GetType() == cmStateEnums::GLOBAL_TARGET ||
+ gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
continue;
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 028053d8eb..a39ed68ea0 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -284,7 +284,7 @@ void cmLocalGenerator::TraceDependencies()
// Generate the rule files for each target.
const auto& targets = this->GetGeneratorTargets();
for (const auto& target : targets) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
target->TraceDependencies();
@@ -760,7 +760,7 @@ void cmLocalGenerator::ComputeTargetManifest()
// Add our targets to the manifest for each configuration.
const auto& targets = this->GetGeneratorTargets();
for (const auto& target : targets) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
for (std::string const& c : configNames) {
diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx
index 098fa5a577..a23ad574dc 100644
--- a/Source/cmLocalGhsMultiGenerator.cxx
+++ b/Source/cmLocalGhsMultiGenerator.cxx
@@ -11,7 +11,6 @@
#include "cmGhsMultiTargetGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmSourceFile.h"
-#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -33,7 +32,7 @@ std::string cmLocalGhsMultiGenerator::GetTargetDirectory(
void cmLocalGhsMultiGenerator::GenerateTargetsDepthFirst(
cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining)
{
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
return;
}
// Find this target in the list of remaining targets.
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index aee7f4519d..50aa9557bc 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate()
}
for (const auto& target : this->GetGeneratorTargets()) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
auto tg = cmNinjaTargetGenerator::New(target.get());
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 88754a8eb8..08f0a5fb60 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -101,7 +101,7 @@ void cmLocalUnixMakefileGenerator3::Generate()
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
for (const auto& target : this->GetGeneratorTargets()) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
continue;
}
std::unique_ptr<cmMakefileTargetGenerator> tg(
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 9076e26d12..6c7d6c6c45 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -69,7 +69,7 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst(
cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining)
{
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!target->IsInBuildSystem()) {
return;
}
// Find this target in the list of remaining targets.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index ad61ad3b2b..fec6a9d500 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -66,7 +66,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
// Now create GUIDs for targets
const auto& tgts = this->GetGeneratorTargets();
for (const auto& l : tgts) {
- if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!l->IsInBuildSystem()) {
continue;
}
cmProp path = l->GetProperty("EXTERNAL_MSPROJECT");
@@ -129,7 +129,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles()
// Create the project file for each target.
for (const auto& l : tgts) {
- if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!l->IsInBuildSystem()) {
continue;
}
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index f291cbd55a..f0d520afc4 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -4138,7 +4138,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
Elem e1(e0, "ItemGroup");
e1.SetHasElements();
for (cmGeneratorTarget const* dt : depends) {
- if (dt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (!dt->IsInBuildSystem()) {
continue;
}
// skip fortran targets as they can not be processed by MSBuild