diff options
Diffstat (limited to 'Tests/RunCMake/Ninja')
-rw-r--r-- | Tests/RunCMake/Ninja/LooseObjectDepends.cmake | 26 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/RunCMakeTest.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/dep.c | 4 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/top.c | 7 |
4 files changed, 54 insertions, 0 deletions
diff --git a/Tests/RunCMake/Ninja/LooseObjectDepends.cmake b/Tests/RunCMake/Ninja/LooseObjectDepends.cmake new file mode 100644 index 0000000..360c7ba --- /dev/null +++ b/Tests/RunCMake/Ninja/LooseObjectDepends.cmake @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.8) +project(LooseObjectDepends 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") +add_custom_target(create-command.h + DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/command.h") + +add_custom_target(create-target.h + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/target.h" + COMMAND "${CMAKE_COMMAND}" -E touch + "${CMAKE_CURRENT_BINARY_DIR}/target.h" + COMMENT "Creating target.h") + +add_library(dep SHARED dep.c) +add_dependencies(dep create-command.h create-target.h) +target_include_directories(dep + PUBLIC + "${CMAKE_CURRENT_BINARY_DIR}") + +add_library(top top.c) +target_link_libraries(top PRIVATE dep) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 063a6d1..fb7798d 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -95,6 +95,23 @@ ${ninja_stderr} endif() endfunction(run_ninja) +function (run_LooseObjectDepends) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/LooseObjectDepends-build) + run_cmake(LooseObjectDepends) + run_ninja("${RunCMake_TEST_BINARY_DIR}" "CMakeFiles/top.dir/top.c${CMAKE_C_OUTPUT_EXTENSION}") + if (EXISTS "${RunCMake_TEST_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}dep${CMAKE_SHARED_LIBRARY_SUFFIX}") + message(FATAL_ERROR + "The `dep` library was created when requesting an object file to be " + "built; this should no longer be necessary.") + endif () + if (EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/dep.dir/dep.c${CMAKE_C_OUTPUT_EXTENSION}") + message(FATAL_ERROR + "The `dep.c` object file was created when requesting an object file to " + "be built; this should no longer be necessary.") + endif () +endfunction () +run_LooseObjectDepends() + function(sleep delay) execute_process( COMMAND ${CMAKE_COMMAND} -E sleep ${delay} diff --git a/Tests/RunCMake/Ninja/dep.c b/Tests/RunCMake/Ninja/dep.c new file mode 100644 index 0000000..728f031 --- /dev/null +++ b/Tests/RunCMake/Ninja/dep.c @@ -0,0 +1,4 @@ +int dep() +{ + return 0; +} diff --git a/Tests/RunCMake/Ninja/top.c b/Tests/RunCMake/Ninja/top.c new file mode 100644 index 0000000..4a88eb2 --- /dev/null +++ b/Tests/RunCMake/Ninja/top.c @@ -0,0 +1,7 @@ +#include "command.h" +#include "target.h" + +int top() +{ + return 0; +} |