mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 23:30:35 -06:00
Tests: Add case covering a unity build with a generated source
Exclude the case on generators where it does not yet work. Issue: #21865
This commit is contained in:
19
Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.cmake
Normal file
19
Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
enable_language(C)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT main.c
|
||||
COMMAND ${CMAKE_COMMAND} -E copy main.c.in main.c
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/main.c.in
|
||||
)
|
||||
add_executable(main main.c)
|
||||
set_property(TARGET main PROPERTY UNITY_BUILD ON)
|
||||
|
||||
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
|
||||
set(check_pairs
|
||||
\"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c.in\"
|
||||
\"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\"
|
||||
)
|
||||
set(check_exes
|
||||
\"$<TARGET_FILE:main>\"
|
||||
)
|
||||
")
|
||||
@@ -0,0 +1,3 @@
|
||||
file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.c.in" [[
|
||||
int main(void) { return 1; }
|
||||
]])
|
||||
@@ -0,0 +1,3 @@
|
||||
file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.c.in" [[
|
||||
int main(void) { return 2; }
|
||||
]])
|
||||
@@ -1,5 +1,22 @@
|
||||
include(RunCMake)
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "Ninja")
|
||||
# Detect ninja version so we know what tests can be supported.
|
||||
execute_process(
|
||||
COMMAND "${RunCMake_MAKE_PROGRAM}" --version
|
||||
OUTPUT_VARIABLE ninja_out
|
||||
ERROR_VARIABLE ninja_out
|
||||
RESULT_VARIABLE ninja_res
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+")
|
||||
set(ninja_version "${ninja_out}")
|
||||
message(STATUS "ninja version: ${ninja_version}")
|
||||
else()
|
||||
message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR
|
||||
RunCMake_GENERATOR STREQUAL "Watcom WMake")
|
||||
set(fs_delay 3)
|
||||
@@ -164,3 +181,11 @@ endif()
|
||||
if(RunCMake_GENERATOR MATCHES "Make")
|
||||
run_BuildDepends(MakeDependencies)
|
||||
endif()
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 " OR
|
||||
RunCMake_GENERATOR MATCHES "Ninja")
|
||||
# This build tool misses the dependency.
|
||||
set(run_BuildDepends_skip_step_2 1)
|
||||
endif()
|
||||
run_BuildDepends(CustomCommandUnityBuild)
|
||||
unset(run_BuildDepends_skip_step_2)
|
||||
|
||||
Reference in New Issue
Block a user