summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-12-10 15:09:14 (GMT)
committerBrad King <brad.king@kitware.com>2024-12-10 16:46:31 (GMT)
commit5ce1ca607f8c99a81b7155940ff3ce7afa13140b (patch)
tree3c22e8893544f0866978bc21defce951708e11ca /Tests
parent5d0f2aba7e231efefa28f54f9c1a5e36b4f374ea (diff)
downloadCMake-5ce1ca607f8c99a81b7155940ff3ce7afa13140b.zip
CMake-5ce1ca607f8c99a81b7155940ff3ce7afa13140b.tar.gz
CMake-5ce1ca607f8c99a81b7155940ff3ce7afa13140b.tar.bz2
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
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/Codegen/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/Codegen/SubDir-build-check.cmake9
-rw-r--r--Tests/RunCMake/Codegen/SubDir-common.cmake15
-rw-r--r--Tests/RunCMake/Codegen/SubDir.cmake2
-rw-r--r--Tests/RunCMake/Codegen/SubDir/CMakeLists.txt15
-rw-r--r--Tests/RunCMake/Codegen/SubDirExcludeFromAll-build-check.cmake9
-rw-r--r--Tests/RunCMake/Codegen/SubDirExcludeFromAll.cmake2
7 files changed, 56 insertions, 0 deletions
diff --git a/Tests/RunCMake/Codegen/RunCMakeTest.cmake b/Tests/RunCMake/Codegen/RunCMakeTest.cmake
index bbd70b0..7b072ba 100644
--- a/Tests/RunCMake/Codegen/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Codegen/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/Codegen/SubDir-build-check.cmake b/Tests/RunCMake/Codegen/SubDir-build-check.cmake
new file mode 100644
index 0000000..d81aa40
--- /dev/null
+++ b/Tests/RunCMake/Codegen/SubDir-build-check.cmake
@@ -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()
diff --git a/Tests/RunCMake/Codegen/SubDir-common.cmake b/Tests/RunCMake/Codegen/SubDir-common.cmake
new file mode 100644
index 0000000..b4013d9
--- /dev/null
+++ b/Tests/RunCMake/Codegen/SubDir-common.cmake
@@ -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
+)
diff --git a/Tests/RunCMake/Codegen/SubDir.cmake b/Tests/RunCMake/Codegen/SubDir.cmake
new file mode 100644
index 0000000..5e5ff7b
--- /dev/null
+++ b/Tests/RunCMake/Codegen/SubDir.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(SubDir)
+include(SubDir-common.cmake)
diff --git a/Tests/RunCMake/Codegen/SubDir/CMakeLists.txt b/Tests/RunCMake/Codegen/SubDir/CMakeLists.txt
new file mode 100644
index 0000000..58f2f6e
--- /dev/null
+++ b/Tests/RunCMake/Codegen/SubDir/CMakeLists.txt
@@ -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
+)
diff --git a/Tests/RunCMake/Codegen/SubDirExcludeFromAll-build-check.cmake b/Tests/RunCMake/Codegen/SubDirExcludeFromAll-build-check.cmake
new file mode 100644
index 0000000..9357747
--- /dev/null
+++ b/Tests/RunCMake/Codegen/SubDirExcludeFromAll-build-check.cmake
@@ -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()
diff --git a/Tests/RunCMake/Codegen/SubDirExcludeFromAll.cmake b/Tests/RunCMake/Codegen/SubDirExcludeFromAll.cmake
new file mode 100644
index 0000000..707da29
--- /dev/null
+++ b/Tests/RunCMake/Codegen/SubDirExcludeFromAll.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(SubDir EXCLUDE_FROM_ALL)
+include(SubDir-common.cmake)