Commit 0733a94f authored by Brad King's avatar Brad King

Ninja,Makefile: Fix subdir "all" with nested EXCLUDE_FROM_ALL subdir

The "all" target defined for a subdirectory (e.g. `cd sub; make` or
`ninja sub/all`) should not include the "all" targets from nested
subdirectories (e.g. `sub/sub`) that are marked as `EXCLUDE_FROM_ALL`.
Fix this and add a test case.

Issue: #19753
Co-Author: Sebastian Holtermann <sebholt@xwmw.org>
parent 11fb377e
......@@ -1123,6 +1123,9 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
// The directory-level rule should depend on the directory-level
// rules of the subdirectories.
for (cmStateSnapshot const& state : lg->GetStateSnapshot().GetChildren()) {
if (state.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
continue;
}
std::string const& currentBinaryDir =
state.GetDirectory().GetCurrentBinary();
folderTargets.push_back(
......
......@@ -429,6 +429,9 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
// The directory-level rule should depend on the directory-level
// rules of the subdirectories.
for (cmStateSnapshot const& c : lg->GetStateSnapshot().GetChildren()) {
if (check_all && c.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
continue;
}
std::string subdir =
cmStrCat(c.GetDirectory().GetCurrentBinary(), '/', pass);
depends.push_back(std::move(subdir));
......
......@@ -11,4 +11,5 @@ set(foo_lib \"$<TARGET_FILE:foo>\")
set(bar_lib \"$<TARGET_FILE:bar>\")
set(zot_lib \"$<TARGET_FILE:zot>\")
set(subinc_lib \"$<TARGET_FILE:subinc>\")
set(subsub_lib \"$<TARGET_FILE:subsub>\")
")
project(ExcludeFromAllSub NONE)
add_subdirectory(SubSub EXCLUDE_FROM_ALL)
add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp)
add_library(zot STATIC zot.cpp)
......
......@@ -18,6 +18,7 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake)
foreach(file
"${main_exe}"
"${bar_lib}"
"${subsub_lib}"
)
if(EXISTS "${file}")
set(RunCMake_TEST_FAILED
......
......@@ -21,6 +21,7 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake)
foreach(file
"${zot_lib}"
"${bar_lib}"
"${subsub_lib}"
)
if(EXISTS "${file}")
set(RunCMake_TEST_FAILED
......
Markdown is supported
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