Commit 51ff15cb authored by Adriaan de Groot's avatar Adriaan de Groot
Browse files

Makefiles: Count explicitly included targets in progress total

A target that is explicitly included (e.g. has explicitly set
EXCLUDE_FROM_ALL to FALSE) needs to be added in directories that
are above the source directory where the target is defined, so that
it gets counted towards ALL. This affects targets where the **directory**
containing the target is excluded, but the target itself is included;
these are either counted double or not at all in previous CMake versions.

Fixes: #21867
parent acf3fe63
Pipeline #288299 waiting for manual action with stages
in 5 minutes and 9 seconds
......@@ -21,6 +21,7 @@
#include "cmMakefileTargetGenerator.h"
#include "cmOutputConverter.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
......@@ -771,6 +772,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
// generator directory level.
void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
{
const std::string EXCLUDE_FROM_ALL = "EXCLUDE_FROM_ALL";
this->DirectoryTargetsMap.clear();
// Loop over all targets in all local generators.
for (const auto& lg : this->LocalGenerators) {
......@@ -781,13 +784,41 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
continue;
}
const std::string targetExplicitExcludeValue =
gt->GetProperty(EXCLUDE_FROM_ALL);
const bool targetHasExplicitExclusion =
!targetExplicitExcludeValue.empty();
const bool targetIsExplicitlyIncluded = targetHasExplicitExclusion
? !gt->GetPropertyAsBool(EXCLUDE_FROM_ALL)
: false;
// Here, targetIsExplicitlyIncluded is @c true **only** if
// the target has EXCLUDE_FROM_ALL set (explicitly) on it
// and that value is is CMake-falsey (e.g. "FALSE"). If there
// is no value, or the value is truthy, then there is nothing
// explicitly indicating this target must be included.
cmStateSnapshot csnp = lg->GetStateSnapshot();
cmStateSnapshot tsnp = tlg->GetStateSnapshot();
const cmStateSnapshot tsnp = tlg->GetStateSnapshot();
// Consider the directory containing the target and all its
// parents until something excludes the target.
for (; csnp.IsValid() && !this->IsExcluded(csnp, tsnp);
csnp = csnp.GetBuildsystemDirectoryParent()) {
for (; csnp.IsValid(); csnp = csnp.GetBuildsystemDirectoryParent()) {
if (this->IsExcluded(csnp, tsnp)) {
if (targetIsExplicitlyIncluded &&
csnp.GetDirectory().GetPropertyAsBool(EXCLUDE_FROM_ALL)) {
// Might be excluded because the **directory** is excluded,
// while the target is explicitly included. If it is explicitly
// included, try again at a higher level.
continue;
}
if (!targetIsExplicitlyIncluded) {
// Not explicitly included, so it is excluded at this level.
break;
}
// Explicitly included, and this level has no explicit exclusion,
// so it is included at this level (continue as if not excluded).
}
// This local generator includes the target.
std::set<cmGeneratorTarget const*>& targetSet =
this->DirectoryTargetsMap[csnp];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment