summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-02-15 13:57:24 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-02-15 13:57:32 (GMT)
commite2ed34abf899ebe528709c2850503fd7ead544a9 (patch)
tree8ddec9a1d0ba63ef3e3548ed77616ccf8cbd93fb /Tests/RunCMake
parenta550db0d45ed8c56f642b07d05c9b18f7b6ed224 (diff)
parent082ccd75301cd02efd09bb9882bb9d2a8957193b (diff)
downloadCMake-e2ed34abf899ebe528709c2850503fd7ead544a9.zip
CMake-e2ed34abf899ebe528709c2850503fd7ead544a9.tar.gz
CMake-e2ed34abf899ebe528709c2850503fd7ead544a9.tar.bz2
Merge topic 'ninja-custom-command-depends'
082ccd7530 add_custom_command: Add DEPENDS_EXPLICIT_ONLY option for Ninja Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8198
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake18
-rw-r--r--Tests/RunCMake/Ninja/RunCMakeTest.cmake12
2 files changed, 30 insertions, 0 deletions
diff --git a/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake b/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake
new file mode 100644
index 0000000..e0c2434
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.26)
+project(CustomCommandExplicitDepends C)
+
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+ COMMAND "${CMAKE_COMMAND}" -E touch
+ "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+ COMMENT "Creating command.h"
+ DEPENDS_EXPLICIT_ONLY
+)
+
+add_library(dep STATIC dep.c)
+
+add_library(top STATIC
+ top.c
+ "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+)
+target_link_libraries(top PRIVATE dep)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 9214e90..17ad035 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -190,6 +190,18 @@ function (run_LooseObjectDepends)
endfunction ()
run_LooseObjectDepends()
+function (run_CustomCommandExplictDepends)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandExplicitDepends-build)
+ run_cmake(CustomCommandExplicitDepends)
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" "command.h")
+ if (EXISTS "${RunCMake_TEST_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}dep${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ message(FATAL_ERROR
+ "The `dep` library was created when requesting an custom command to be "
+ "generated; this should no longer be necessary when passing DEPENDS_EXPLICIT_ONLY keyword.")
+ endif ()
+endfunction ()
+run_CustomCommandExplictDepends()
+
function (run_AssumedSources)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AssumedSources-build)
run_cmake(AssumedSources)