Ninja: Add missing top-level codegen dependencies on per-directory codegen
In commit 197cb419d1
(add_custom_command: Add CODEGEN support,
2024-05-27, v3.31.0-rc1~394^2) we accidentally left out the global
`codegen` target's dependencies on the per-directory `codegen` targets.
Add them for parity with the `all` target.
Fixes: #26517
This commit is contained in:
parent
5d0f2aba7e
commit
5ce1ca607f
@ -1661,6 +1661,13 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
|
||||
}
|
||||
}
|
||||
|
||||
for (DirectoryTarget::Dir const& d : dt.Children) {
|
||||
if (!d.ExcludeFromAll) {
|
||||
build.ExplicitDeps.emplace_back(this->BuildAlias(
|
||||
this->ConvertToNinjaPath(cmStrCat(d.Path, "/codegen")), config));
|
||||
}
|
||||
}
|
||||
|
||||
// Write target
|
||||
this->WriteBuild(this->EnableCrossConfigBuild() &&
|
||||
this->CrossConfigs.count(config)
|
||||
|
@ -31,3 +31,7 @@ run_cmake("implicit-depends")
|
||||
run_cmake("implicit-depends-append-codegen")
|
||||
run_cmake("append-implicit-depends")
|
||||
run_cmake("no-output")
|
||||
|
||||
# Top-level codegen depends on that of subdirectories.
|
||||
run_codegen(SubDir)
|
||||
run_codegen(SubDirExcludeFromAll)
|
||||
|
9
Tests/RunCMake/Codegen/SubDir-build-check.cmake
Normal file
9
Tests/RunCMake/Codegen/SubDir-build-check.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
set(filename "${RunCMake_TEST_BINARY_DIR}/generated.h")
|
||||
if(NOT EXISTS "${filename}")
|
||||
string(APPEND RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}\n")
|
||||
endif()
|
||||
|
||||
set(filename "${RunCMake_TEST_BINARY_DIR}/SubDir/generated.h")
|
||||
if(NOT EXISTS "${filename}")
|
||||
string(APPEND RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}\n")
|
||||
endif()
|
15
Tests/RunCMake/Codegen/SubDir-common.cmake
Normal file
15
Tests/RunCMake/Codegen/SubDir-common.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E
|
||||
copy ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
CODEGEN
|
||||
)
|
||||
|
||||
add_library(errorlib_top
|
||||
# If this library is built error.c will cause the build to fail
|
||||
error.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
)
|
2
Tests/RunCMake/Codegen/SubDir.cmake
Normal file
2
Tests/RunCMake/Codegen/SubDir.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
add_subdirectory(SubDir)
|
||||
include(SubDir-common.cmake)
|
15
Tests/RunCMake/Codegen/SubDir/CMakeLists.txt
Normal file
15
Tests/RunCMake/Codegen/SubDir/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E
|
||||
copy ${CMAKE_CURRENT_SOURCE_DIR}/../generated.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
CODEGEN
|
||||
)
|
||||
|
||||
add_library(errorlib_subdir
|
||||
# If this library is built error.c will cause the build to fail
|
||||
../error.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
set(filename "${RunCMake_TEST_BINARY_DIR}/generated.h")
|
||||
if(NOT EXISTS "${filename}")
|
||||
string(APPEND RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}\n")
|
||||
endif()
|
||||
|
||||
set(filename "${RunCMake_TEST_BINARY_DIR}/SubDir/generated.h")
|
||||
if(EXISTS "${filename}")
|
||||
string(APPEND RunCMake_TEST_FAILED "unexpected file created:\n ${filename}\n")
|
||||
endif()
|
2
Tests/RunCMake/Codegen/SubDirExcludeFromAll.cmake
Normal file
2
Tests/RunCMake/Codegen/SubDirExcludeFromAll.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
add_subdirectory(SubDir EXCLUDE_FROM_ALL)
|
||||
include(SubDir-common.cmake)
|
Loading…
Reference in New Issue
Block a user