mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
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:
@@ -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>\")
|
||||
")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
add_library(subsub STATIC subsub.cpp)
|
||||
@@ -0,0 +1,4 @@
|
||||
int subsub()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user