mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 20:00:38 -06:00
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:
20
Tests/RunCMake/Ninja/AssumedSources.cmake
Normal file
20
Tests/RunCMake/Ninja/AssumedSources.cmake
Normal 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)
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user