summaryrefslogtreecommitdiff
path: root/Tests/RunCMake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake30
-rw-r--r--Tests/RunCMake/Ninja/RunCMakeTest.cmake28
2 files changed, 48 insertions, 10 deletions
diff --git a/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake b/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake
index e0c2434dbe..fefd86a1e3 100644
--- a/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake
+++ b/Tests/RunCMake/Ninja/CustomCommandExplicitDepends.cmake
@@ -2,17 +2,35 @@ cmake_minimum_required(VERSION 3.26)
project(CustomCommandExplicitDepends C)
add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command-option.h"
COMMAND "${CMAKE_COMMAND}" -E touch
- "${CMAKE_CURRENT_BINARY_DIR}/command.h"
- COMMENT "Creating command.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/command-option.h"
+ COMMENT "Creating command-option.h"
DEPENDS_EXPLICIT_ONLY
)
-add_library(dep STATIC dep.c)
+set(CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY ON)
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command-variable-on.h"
+ COMMAND "${CMAKE_COMMAND}" -E touch
+ "${CMAKE_CURRENT_BINARY_DIR}/command-variable-on.h"
+ COMMENT "Creating command-variable-on.h"
+)
+
+set(CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY OFF)
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command-variable-off.h"
+ COMMAND "${CMAKE_COMMAND}" -E touch
+ "${CMAKE_CURRENT_BINARY_DIR}/command-variable-off.h"
+ COMMENT "Creating command-variable-off.h"
+)
+
+add_library(dep SHARED dep.c)
-add_library(top STATIC
+add_library(top SHARED
top.c
- "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/command-option.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/command-variable-on.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/command-variable-off.h"
)
target_link_libraries(top PRIVATE dep)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 17ad035a52..91c48c6b47 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -193,11 +193,31 @@ 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}")
+
+ set(DEP_LIB "${RunCMake_TEST_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}dep${CMAKE_SHARED_LIBRARY_SUFFIX}")
+
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" "command-option.h")
+ if (EXISTS "${DEP_LIB}")
+ message(FATAL_ERROR
+ "The `dep` library was created when requesting a custom command to be "
+ "generated; this should no longer be necessary when passing "
+ "DEPENDS_EXPLICIT_ONLY option.")
+ endif ()
+
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" "command-variable-on.h")
+ if (EXISTS "${DEP_LIB}")
+ message(FATAL_ERROR
+ "The `dep` library was created when requesting a custom command to be "
+ "generated; this should no longer be necessary when setting "
+ "CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY variable to ON.")
+ endif ()
+
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" "command-variable-off.h")
+ if (NOT EXISTS "${DEP_LIB}")
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.")
+ "The `dep` library was not created when requesting a custom command to be "
+ "generated; this should be necessary when setting "
+ "CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY variable to OFF.")
endif ()
endfunction ()
run_CustomCommandExplictDepends()