RunCMake.Ninja: add a test for assumed sources

This is a dark corner of the Ninja generator. It should be fixed in the
future, but add a test which shows its behaviors.
This commit is contained in:
Ben Boeckel
2017-04-18 15:05:35 -04:00
parent adf60b2838
commit 664591ce59
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.8)
project(AssumedSources)
set_source_files_properties(
"${CMAKE_CURRENT_BINARY_DIR}/target.c"
"${CMAKE_CURRENT_BINARY_DIR}/target-no-depends.c"
PROPERTIES GENERATED 1)
add_executable(working
"${CMAKE_CURRENT_BINARY_DIR}/target.c"
"${CMAKE_CURRENT_BINARY_DIR}/target-no-depends.c")
add_custom_target(
gen-target.c ALL
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/dep.c" "${CMAKE_CURRENT_BINARY_DIR}/target.c")
add_custom_target(
gen-target-no-depends.c ALL
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/dep.c" "${CMAKE_CURRENT_BINARY_DIR}/target-no-depends.c")
add_dependencies(working gen-target.c)

View File

@@ -112,6 +112,22 @@ function (run_LooseObjectDepends)
endfunction ()
run_LooseObjectDepends()
function (run_AssumedSources)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AssumedSources-build)
run_cmake(AssumedSources)
run_ninja("${RunCMake_TEST_BINARY_DIR}" "target.c")
if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/target.c")
message(FATAL_ERROR
"Dependencies for an assumed source did not hook up properly for 'target.c'.")
endif ()
run_ninja("${RunCMake_TEST_BINARY_DIR}" "target-no-depends.c")
if (EXISTS "${RunCMake_TEST_BINARY_DIR}/target-no-depends.c")
message(FATAL_ERROR
"Dependencies for an assumed source were magically hooked up for 'target-no-depends.c'.")
endif ()
endfunction ()
run_AssumedSources()
function(sleep delay)
execute_process(
COMMAND ${CMAKE_COMMAND} -E sleep ${delay}