Makefile: Fix progress with non-excluded targets in excluded dirs

Fixes: #26871
This commit is contained in:
xndcn
2025-04-15 21:22:31 +08:00
committed by Brad King
parent 89ab14b05b
commit 5781cf406f
4 changed files with 17 additions and 8 deletions

View File

@@ -801,19 +801,15 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
// Loop over all targets in all local generators.
for (auto const& lg : this->LocalGenerators) {
for (auto const& gt : lg->GetGeneratorTargets()) {
cmLocalGenerator* tlg = gt->GetLocalGenerator();
if (!gt->IsInBuildSystem() || this->IsExcluded(lg.get(), gt.get())) {
continue;
}
cmStateSnapshot csnp = lg->GetStateSnapshot();
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()) {
// Consider the directory containing the target and all its parents.
// An excluded directory may contains non-excluded targets.
for (; csnp.IsValid(); csnp = csnp.GetBuildsystemDirectoryParent()) {
// This local generator includes the target.
std::set<cmGeneratorTarget const*>& targetSet =
this->DirectoryTargetsMap[csnp];
@@ -854,7 +850,9 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInAll(
std::set<cmGeneratorTarget const*> emitted;
for (cmGeneratorTarget const* target :
this->DirectoryTargetsMap[lg.GetStateSnapshot()]) {
count += this->CountProgressMarksInTarget(target, emitted);
if (!this->IsExcluded(&lg, target)) {
count += this->CountProgressMarksInTarget(target, emitted);
}
}
return count;
}

View File

@@ -0,0 +1,7 @@
if(EXISTS ${RunCMake_TEST_BINARY_DIR}/CMakeFiles/progress.marks)
file(STRINGS ${RunCMake_TEST_BINARY_DIR}/CMakeFiles/progress.marks progress_marks)
# 8: (zot.cpp.o + libzot.a) + (foo.cpp.o + libfoo.a) + (subinc.cpp.o + libsubinc.a) + (subsub.cpp.o + libsubsubinc.a)
if(NOT progress_marks STREQUAL "8")
set(RunCMake_TEST_FAILED "progress.marks should be 8, but got ${progress_marks}")
endif()
endif()

View File

@@ -53,6 +53,9 @@ elseif(RunCMake_GENERATOR MATCHES "Make")
set(RunCMake-check-file ExcludeFromAll/check-sub.cmake)
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll)
run_cmake_command(ExcludeFromAll-build-sub "${RunCMake_MAKE_PROGRAM}")
set(RunCMake-check-file ExcludeFromAll/check-progress.cmake)
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll)
run_cmake_command(ExcludeFromAll-build-progress "${RunCMake_MAKE_PROGRAM}")
elseif(RunCMake_GENERATOR MATCHES "Visual Studio")
set(RunCMake-check-file ExcludeFromAll/check-sub.cmake)
run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build ExcludeFromAll --config Debug)