CMake/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
Brad King add7abc835 Ninja: Restat custom command byproducts even with a SYMBOLIC output (#16049)
The change in commit v3.5.0-rc1~198^2 (Ninja: Always re-run custom
commands that have symbolic dependencies, 2015-11-19) broke the
byproducts feature added by commit v3.2.0-rc1~340^2~2 (Add an option for
explicit BYPRODUCTS of custom commands, 2014-11-13) when SYMBOLIC
outputs also appear.  This case occurs with AUTORCC-generated custom
targets because the output is SYMBOLIC (to always run) and the generated
file is a byproduct (for restat so dependents do not run unnecessarily).

The two use cases conflict because Ninja does not support per-output
restat.  Favor restat whenever byproducts are present because it is
required for byproducts to work correctly.  In use cases where we want
an always-run chain we simply will not be able to also use byproducts.
2016-04-05 16:20:28 -04:00

44 lines
1.5 KiB
CMake

include(RunCMake)
if(RunCMake_GENERATOR STREQUAL "Borland Makefiles")
set(fs_delay 3)
else()
set(fs_delay 1.125)
endif()
function(run_BuildDepends CASE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
include(${RunCMake_SOURCE_DIR}/${CASE}.step1.cmake OPTIONAL)
run_cmake(${CASE})
set(RunCMake-check-file check.cmake)
set(check_step 1)
run_cmake_command(${CASE}-build1 ${CMAKE_COMMAND} --build . --config Debug)
if(run_BuildDepends_skip_step_2)
return()
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) # handle 1s resolution
include(${RunCMake_SOURCE_DIR}/${CASE}.step2.cmake OPTIONAL)
set(check_step 2)
run_cmake_command(${CASE}-build2 ${CMAKE_COMMAND} --build . --config Debug)
endfunction()
run_BuildDepends(C-Exe)
if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode")
if(RunCMake_GENERATOR MATCHES "Visual Studio 10")
# VS 10 forgets to re-link when a manifest changes
set(run_BuildDepends_skip_step_2 1)
endif()
run_BuildDepends(C-Exe-Manifest)
unset(run_BuildDepends_skip_step_2)
endif()
run_BuildDepends(Custom-Symbolic-and-Byproduct)
run_BuildDepends(Custom-Always)