summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-04-24 13:31:44 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-04-24 13:31:49 (GMT)
commit305e628284fc647087cc8b1e1d7074f826358de6 (patch)
treecda9bc002f9fd84485940a60f1592422496fde71 /Tests
parentfa338c97d7e1cd320f79a6eed3b7913fd88ee890 (diff)
parentd96e5d9a19d613de108ab399663f76a8dd964172 (diff)
downloadCMake-305e628284fc647087cc8b1e1d7074f826358de6.zip
CMake-305e628284fc647087cc8b1e1d7074f826358de6.tar.gz
CMake-305e628284fc647087cc8b1e1d7074f826358de6.tar.bz2
Merge topic 'loosen-object-deps'
d96e5d9a Tests: use BYPRODUCTS in the CustomCommandWorkingDirectory test 664591ce RunCMake.Ninja: add a test for assumed sources adf60b28 ninja: break unnecessary target dependencies 01c5bb95 RunCMake.Ninja: support passing arguments when running ninja 7f947b60 ninja: remove duplicate order-only dependencies e9827eba ninja: describe the intermediate order depends target better b57b7d8e Ninja: Order Fortran dyndep file generation explicitly Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !430
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CustomCommandWorkingDirectory/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/Ninja/AssumedSources.cmake20
-rw-r--r--Tests/RunCMake/Ninja/LooseObjectDepends.cmake26
-rw-r--r--Tests/RunCMake/Ninja/RunCMakeTest.cmake35
-rw-r--r--Tests/RunCMake/Ninja/dep.c4
-rw-r--r--Tests/RunCMake/Ninja/top.c7
7 files changed, 97 insertions, 1 deletions
diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
index f917cd7..4975feb 100644
--- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
+++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
@@ -19,6 +19,7 @@ add_executable(working "${TestWorkingDir_BINARY_DIR}/working.c"
add_custom_target(
Custom ALL
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget.c"
+ BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget.c"
WORKING_DIRECTORY "${TestWorkingDir_SOURCE_DIR}"
)
@@ -36,6 +37,7 @@ add_executable(working2 working2.c ${TestWorkingDir_BINARY_DIR}/customTarget2.c)
add_custom_target(
Custom2 ALL
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${TestWorkingDir_SOURCE_DIR}/customTarget.c ../customTarget2.c
+ BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget2.c"
WORKING_DIRECTORY work/ # Relative to build tree, trailing slash
)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 32c4be8..21e6259 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -119,6 +119,10 @@ if(CMAKE_GENERATOR MATCHES "Make")
add_RunCMake_test(Make)
endif()
if(CMAKE_GENERATOR STREQUAL "Ninja")
+ set(Ninja_ARGS
+ -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION}
+ -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}
+ -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX})
add_RunCMake_test(Ninja)
endif()
add_RunCMake_test(CTest)
diff --git a/Tests/RunCMake/Ninja/AssumedSources.cmake b/Tests/RunCMake/Ninja/AssumedSources.cmake
new file mode 100644
index 0000000..5fb0219
--- /dev/null
+++ b/Tests/RunCMake/Ninja/AssumedSources.cmake
@@ -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)
diff --git a/Tests/RunCMake/Ninja/LooseObjectDepends.cmake b/Tests/RunCMake/Ninja/LooseObjectDepends.cmake
new file mode 100644
index 0000000..360c7ba
--- /dev/null
+++ b/Tests/RunCMake/Ninja/LooseObjectDepends.cmake
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.8)
+project(LooseObjectDepends C)
+
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+ COMMAND "${CMAKE_COMMAND}" -E touch
+ "${CMAKE_CURRENT_BINARY_DIR}/command.h"
+ COMMENT "Creating command.h")
+add_custom_target(create-command.h
+ DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/command.h")
+
+add_custom_target(create-target.h
+ BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/target.h"
+ COMMAND "${CMAKE_COMMAND}" -E touch
+ "${CMAKE_CURRENT_BINARY_DIR}/target.h"
+ COMMENT "Creating target.h")
+
+add_library(dep SHARED dep.c)
+add_dependencies(dep create-command.h create-target.h)
+target_include_directories(dep
+ PUBLIC
+ "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_library(top top.c)
+target_link_libraries(top PRIVATE dep)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 7b4e51e..8c3bc20 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -73,7 +73,7 @@ run_SubDir()
function(run_ninja dir)
execute_process(
- COMMAND "${RunCMake_MAKE_PROGRAM}"
+ COMMAND "${RunCMake_MAKE_PROGRAM}" ${ARGN}
WORKING_DIRECTORY "${dir}"
OUTPUT_VARIABLE ninja_stdout
ERROR_VARIABLE ninja_stderr
@@ -95,6 +95,39 @@ ${ninja_stderr}
endif()
endfunction(run_ninja)
+function (run_LooseObjectDepends)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/LooseObjectDepends-build)
+ run_cmake(LooseObjectDepends)
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" "CMakeFiles/top.dir/top.c${CMAKE_C_OUTPUT_EXTENSION}")
+ if (EXISTS "${RunCMake_TEST_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}dep${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ message(FATAL_ERROR
+ "The `dep` library was created when requesting an object file to be "
+ "built; this should no longer be necessary.")
+ endif ()
+ if (EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/dep.dir/dep.c${CMAKE_C_OUTPUT_EXTENSION}")
+ message(FATAL_ERROR
+ "The `dep.c` object file was created when requesting an object file to "
+ "be built; this should no longer be necessary.")
+ endif ()
+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}
diff --git a/Tests/RunCMake/Ninja/dep.c b/Tests/RunCMake/Ninja/dep.c
new file mode 100644
index 0000000..728f031
--- /dev/null
+++ b/Tests/RunCMake/Ninja/dep.c
@@ -0,0 +1,4 @@
+int dep()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Ninja/top.c b/Tests/RunCMake/Ninja/top.c
new file mode 100644
index 0000000..4a88eb2
--- /dev/null
+++ b/Tests/RunCMake/Ninja/top.c
@@ -0,0 +1,7 @@
+#include "command.h"
+#include "target.h"
+
+int top()
+{
+ return 0;
+}