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>
This commit is contained in:
Brad King
2019-09-25 14:09:43 -04:00
parent 11fb377eb9
commit 0733a94f64
8 changed files with 16 additions and 0 deletions

View File

@@ -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(

View File

@@ -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));

View File

@@ -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>\")
")

View File

@@ -1,5 +1,7 @@
project(ExcludeFromAllSub NONE)
add_subdirectory(SubSub EXCLUDE_FROM_ALL)
add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp)
add_library(zot STATIC zot.cpp)

View File

@@ -0,0 +1 @@
add_library(subsub STATIC subsub.cpp)

View File

@@ -0,0 +1,4 @@
int subsub()
{
return 0;
}

View File

@@ -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

View File

@@ -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