diff options
author | Abdelmaged Khalifa <abdelmaged.khalifa@gmail.com> | 2023-02-11 23:00:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-02-14 13:56:59 (GMT) |
commit | 082ccd75301cd02efd09bb9882bb9d2a8957193b (patch) | |
tree | 92611f898b4b3253c12687faa610f0bc8a0d0de8 /Tests/RunCMake/Ninja | |
parent | 48c69eeafe5e480b5baa0c6766d4d2e3c7f5a4ad (diff) | |
download | CMake-082ccd75301cd02efd09bb9882bb9d2a8957193b.zip CMake-082ccd75301cd02efd09bb9882bb9d2a8957193b.tar.gz CMake-082ccd75301cd02efd09bb9882bb9d2a8957193b.tar.bz2 |
add_custom_command: Add DEPENDS_EXPLICIT_ONLY option for Ninja
Add option `DEPENDS_EXPLICIT_ONLY` to `add_custom_command` to indicate
that implicit dependencies coming from users of the output are not
needed, and only consider dependencies explicitly specified in the
custom command.
Fixes: #17097
Diffstat (limited to 'Tests/RunCMake/Ninja')
-rw-r--r-- | Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake | 18 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/RunCMakeTest.cmake | 12 |
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) |