summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-20 13:26:40 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-05-20 13:26:46 (GMT)
commitd98a7cdb25611ed6f1e856fd4c4ff980225b89cd (patch)
treeb7e5b22546b03b481854485f3fd8f77294c6bde8 /Tests
parent6f656d6b58886a07c773fb83ec6f1a9633204af5 (diff)
parent2725ecff38ccd25905a9bc968bfb1b2f0d09b34a (diff)
downloadCMake-d98a7cdb25611ed6f1e856fd4c4ff980225b89cd.zip
CMake-d98a7cdb25611ed6f1e856fd4c4ff980225b89cd.tar.gz
CMake-d98a7cdb25611ed6f1e856fd4c4ff980225b89cd.tar.bz2
Merge topic 'cmake-ninja-workdir'
2725ecff38 Ninja: Handle depfiles with absolute paths to generated files bc40cd7a4e Tests: Add case covering a unity build with a generated source ae927f936d cmGlobalNinjaGenerator: Improve allocation pattern in WriteBuild 68e5f92cad cmGlobalNinjaGenerator: Factor out custom command output collection c5195193d3 cmGlobalNinjaGenerator: Reduce string copies in WriteCustomCommandBuild 8bac527b0c cmGlobalNinjaGenerator: Re-order logic in WriteCustomCommandBuild ddc030f5ca cmGlobalNinjaGenerator: Record implicit outputs as known too ceb82752ef cmLocalNinjaGenerator: Use variable for main custom command output path Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6143
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.cmake19
-rw-r--r--Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step1.cmake3
-rw-r--r--Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step2.cmake3
-rw-r--r--Tests/RunCMake/BuildDepends/RunCMakeTest.cmake25
4 files changed, 50 insertions, 0 deletions
diff --git a/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.cmake b/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.cmake
new file mode 100644
index 0000000..22e7f27
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.cmake
@@ -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>\"
+ )
+")
diff --git a/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step1.cmake b/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step1.cmake
new file mode 100644
index 0000000..87576eb
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step1.cmake
@@ -0,0 +1,3 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.c.in" [[
+int main(void) { return 1; }
+]])
diff --git a/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step2.cmake b/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step2.cmake
new file mode 100644
index 0000000..69b21b8
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/CustomCommandUnityBuild.step2.cmake
@@ -0,0 +1,3 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.c.in" [[
+int main(void) { return 2; }
+]])
diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
index 72faddb..0a80580 100644
--- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
+++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
@@ -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" AND ninja_version VERSION_LESS 1.7))
+ # This build tool misses the dependency.
+ set(run_BuildDepends_skip_step_2 1)
+endif()
+run_BuildDepends(CustomCommandUnityBuild)
+unset(run_BuildDepends_skip_step_2)