mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 10:47:59 +08:00
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.
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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(),
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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());
|
||||
|
@@ -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)) {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 =
|
||||
|
@@ -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");
|
||||
|
@@ -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
|
||||
|
@@ -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 &&
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -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.
|
||||
|
@@ -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());
|
||||
|
@@ -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(
|
||||
|
@@ -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.
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user