Factor out generator checks for filtering on non-compiling targets
Add a `cmGeneratorTarget::CanCompileSources` helper method to tell generators whether a target might compile anything.
This commit is contained in:
parent
422d9a0ab2
commit
2f0790df50
@ -1120,6 +1120,11 @@ bool cmGeneratorTarget::IsImportedGloballyVisible() const
|
||||
return this->Target->IsImportedGloballyVisible();
|
||||
}
|
||||
|
||||
bool cmGeneratorTarget::CanCompileSources() const
|
||||
{
|
||||
return this->Target->CanCompileSources();
|
||||
}
|
||||
|
||||
const std::string& cmGeneratorTarget::GetLocationForBuild() const
|
||||
{
|
||||
static std::string location;
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
bool IsInBuildSystem() const;
|
||||
bool IsImported() const;
|
||||
bool IsImportedGloballyVisible() const;
|
||||
bool CanCompileSources() const;
|
||||
const std::string& GetLocation(const std::string& config) const;
|
||||
|
||||
std::vector<cmCustomCommand> const& GetPreBuildCommands() const;
|
||||
|
@ -302,9 +302,7 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
|
||||
bool failed = false;
|
||||
for (const auto& localGen : this->LocalGenerators) {
|
||||
for (const auto& target : localGen->GetGeneratorTargets()) {
|
||||
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
|
||||
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
|
||||
target->GetType() == cmStateEnums::TargetType::UTILITY ||
|
||||
if (!target->CanCompileSources() ||
|
||||
cmIsOn(target->GetProperty("ghs_integrity_app"))) {
|
||||
continue;
|
||||
}
|
||||
@ -358,9 +356,7 @@ bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const
|
||||
bool failed = false;
|
||||
for (const auto& generator : this->LocalGenerators) {
|
||||
for (const auto& target : generator->GetGeneratorTargets()) {
|
||||
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
|
||||
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
|
||||
target->GetType() == cmStateEnums::TargetType::UTILITY ||
|
||||
if (!target->CanCompileSources() ||
|
||||
cmIsOn(target->GetProperty("ghs_integrity_app"))) {
|
||||
continue;
|
||||
}
|
||||
@ -1595,9 +1591,7 @@ bool cmGlobalGenerator::AddAutomaticSources()
|
||||
for (const auto& lg : this->LocalGenerators) {
|
||||
lg->CreateEvaluationFileOutputs();
|
||||
for (const auto& gt : lg->GetGeneratorTargets()) {
|
||||
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
|
||||
gt->GetType() == cmStateEnums::UTILITY ||
|
||||
gt->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||
if (!gt->CanCompileSources()) {
|
||||
continue;
|
||||
}
|
||||
lg->AddUnityBuild(gt.get());
|
||||
@ -1609,9 +1603,7 @@ bool cmGlobalGenerator::AddAutomaticSources()
|
||||
}
|
||||
for (const auto& lg : this->LocalGenerators) {
|
||||
for (const auto& gt : lg->GetGeneratorTargets()) {
|
||||
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
|
||||
gt->GetType() == cmStateEnums::UTILITY ||
|
||||
gt->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||
if (!gt->CanCompileSources()) {
|
||||
continue;
|
||||
}
|
||||
// Handle targets that re-use a PCH from an above-handled target.
|
||||
|
@ -797,7 +797,7 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
|
||||
|
||||
// Now that C/C++ _STANDARD values have been computed
|
||||
// set the values to ObjC/ObjCXX _STANDARD variables
|
||||
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
|
||||
if (target->CanCompileSources()) {
|
||||
for (std::string const& c : configNames) {
|
||||
target->ComputeCompileFeatures(c, inferredEnabledLanguages);
|
||||
}
|
||||
|
@ -137,8 +137,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
|
||||
std::map<std::string, LocalObjectInfo>& localObjectFiles)
|
||||
{
|
||||
for (const auto& gt : this->GetGeneratorTargets()) {
|
||||
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
|
||||
gt->GetType() == cmStateEnums::UTILITY) {
|
||||
if (!gt->CanCompileSources()) {
|
||||
continue;
|
||||
}
|
||||
std::vector<cmSourceFile const*> objectSources;
|
||||
|
@ -272,8 +272,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
||||
};
|
||||
|
||||
// Setup default property values.
|
||||
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
|
||||
this->GetType() != cmStateEnums::UTILITY) {
|
||||
if (this->CanCompileSources()) {
|
||||
initProp("ANDROID_API");
|
||||
initProp("ANDROID_API_MIN");
|
||||
initProp("ANDROID_ARCH");
|
||||
@ -505,6 +504,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
||||
if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
|
||||
impl->TargetType == cmStateEnums::MODULE_LIBRARY) {
|
||||
this->SetProperty("POSITION_INDEPENDENT_CODE", "True");
|
||||
} else if (this->CanCompileSources()) {
|
||||
initProp("POSITION_INDEPENDENT_CODE");
|
||||
}
|
||||
if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
|
||||
impl->TargetType == cmStateEnums::EXECUTABLE) {
|
||||
@ -512,11 +513,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
||||
initProp("WINDOWS_EXPORT_ALL_SYMBOLS");
|
||||
}
|
||||
|
||||
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
|
||||
this->GetType() != cmStateEnums::UTILITY) {
|
||||
initProp("POSITION_INDEPENDENT_CODE");
|
||||
}
|
||||
|
||||
// Record current policies for later use.
|
||||
impl->Makefile->RecordPolicies(impl->PolicyMap);
|
||||
|
||||
@ -1910,6 +1906,27 @@ bool cmTarget::IsPerConfig() const
|
||||
return impl->PerConfig;
|
||||
}
|
||||
|
||||
bool cmTarget::CanCompileSources() const
|
||||
{
|
||||
if (this->IsImported()) {
|
||||
return false;
|
||||
}
|
||||
switch (this->GetType()) {
|
||||
case cmStateEnums::EXECUTABLE:
|
||||
case cmStateEnums::STATIC_LIBRARY:
|
||||
case cmStateEnums::SHARED_LIBRARY:
|
||||
case cmStateEnums::MODULE_LIBRARY:
|
||||
case cmStateEnums::OBJECT_LIBRARY:
|
||||
return true;
|
||||
case cmStateEnums::UTILITY:
|
||||
case cmStateEnums::INTERFACE_LIBRARY:
|
||||
case cmStateEnums::GLOBAL_TARGET:
|
||||
case cmStateEnums::UNKNOWN_LIBRARY:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* cmTarget::GetSuffixVariableInternal(
|
||||
cmStateEnums::ArtifactType artifact) const
|
||||
{
|
||||
|
@ -196,6 +196,7 @@ public:
|
||||
bool IsImported() const;
|
||||
bool IsImportedGloballyVisible() const;
|
||||
bool IsPerConfig() const;
|
||||
bool CanCompileSources() const;
|
||||
|
||||
bool GetMappedConfig(std::string const& desired_config, cmProp& loc,
|
||||
cmProp& imp, std::string& suffix) const;
|
||||
|
Loading…
Reference in New Issue
Block a user