summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CMP0116
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-10-02 17:35:40 -0400
committerKyle Edwards <kyle.edwards@kitware.com>2020-10-13 10:19:46 -0400
commit146e1e6ba14d964bf120635aca953cc76e5b2282 (patch)
treee8fd8309f7288a275322dcbc14a8ee99370aba4b /Tests/RunCMake/CMP0116
parent596439b1bbac44b4218f65615d93e9fe9bd43922 (diff)
downloadcmake-146e1e6ba14d964bf120635aca953cc76e5b2282.tar.gz
Ninja: Transform DEPFILEs with policy CMP0116
Fixes: #21267
Diffstat (limited to 'Tests/RunCMake/CMP0116')
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-NEW-NOWARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-NEW-WARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-OLD-WARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN-stderr.txt7
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-WARN-WARN-stderr.txt16
-rw-r--r--Tests/RunCMake/CMP0116/CMP0116-WARN-WARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0116/Common.cmake8
-rw-r--r--Tests/RunCMake/CMP0116/RunCMakeTest.cmake49
-rw-r--r--Tests/RunCMake/CMP0116/Subdirectory/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CMP0116/WriteDepfile.cmake3
-rw-r--r--Tests/RunCMake/CMP0116/check.cmake18
14 files changed, 128 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0116/CMP0116-NEW-NOWARN.cmake b/Tests/RunCMake/CMP0116/CMP0116-NEW-NOWARN.cmake
new file mode 100644
index 0000000000..f92fac68a8
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-NEW-NOWARN.cmake
@@ -0,0 +1,3 @@
+set(depdir)
+
+include(Common.cmake)
diff --git a/Tests/RunCMake/CMP0116/CMP0116-NEW-WARN.cmake b/Tests/RunCMake/CMP0116/CMP0116-NEW-WARN.cmake
new file mode 100644
index 0000000000..f92fac68a8
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-NEW-WARN.cmake
@@ -0,0 +1,3 @@
+set(depdir)
+
+include(Common.cmake)
diff --git a/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN.cmake b/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN.cmake
new file mode 100644
index 0000000000..665f485314
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN.cmake
@@ -0,0 +1,3 @@
+set(depdir Subdirectory/)
+
+include(Common.cmake)
diff --git a/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN.cmake b/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN.cmake
new file mode 100644
index 0000000000..665f485314
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN.cmake
@@ -0,0 +1,3 @@
+set(depdir Subdirectory/)
+
+include(Common.cmake)
diff --git a/Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN-stderr.txt
new file mode 100644
index 0000000000..843ff1c7af
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning \(dev\) at Subdirectory/CMakeLists\.txt:[0-9]+ \(add_custom_command\):
+ Policy CMP0116 is not set: Ninja generators transform DEPFILEs from
+ add_custom_command\(\)\. Run "cmake --help-policy CMP0116" for policy
+ details\. Use the cmake_policy command to set the policy and suppress this
+ warning\.
+This warning is for project developers\. Use -Wno-dev to suppress it\.
+*)+$
diff --git a/Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN.cmake b/Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN.cmake
new file mode 100644
index 0000000000..665f485314
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-WARN-NOWARN.cmake
@@ -0,0 +1,3 @@
+set(depdir Subdirectory/)
+
+include(Common.cmake)
diff --git a/Tests/RunCMake/CMP0116/CMP0116-WARN-WARN-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-WARN-WARN-stderr.txt
new file mode 100644
index 0000000000..e29af91a06
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-WARN-WARN-stderr.txt
@@ -0,0 +1,16 @@
+^(CMake Warning \(dev\) at Common\.cmake:[0-9]+ \(add_custom_command\):
+ Policy CMP0116 is not set: Ninja generators transform DEPFILEs from
+ add_custom_command\(\)\. Run "cmake --help-policy CMP0116" for policy
+ details\. Use the cmake_policy command to set the policy and suppress this
+ warning\.
+Call Stack \(most recent call first\):
+ CMP0116-WARN-WARN\.cmake:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++)+(CMake Warning \(dev\) at Subdirectory/CMakeLists\.txt:[0-9]+ \(add_custom_command\):
+ Policy CMP0116 is not set: Ninja generators transform DEPFILEs from
+ add_custom_command\(\)\. Run "cmake --help-policy CMP0116" for policy
+ details\. Use the cmake_policy command to set the policy and suppress this
+ warning\.
+This warning is for project developers\. Use -Wno-dev to suppress it\.
+*)+$
diff --git a/Tests/RunCMake/CMP0116/CMP0116-WARN-WARN.cmake b/Tests/RunCMake/CMP0116/CMP0116-WARN-WARN.cmake
new file mode 100644
index 0000000000..665f485314
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMP0116-WARN-WARN.cmake
@@ -0,0 +1,3 @@
+set(depdir Subdirectory/)
+
+include(Common.cmake)
diff --git a/Tests/RunCMake/CMP0116/CMakeLists.txt b/Tests/RunCMake/CMP0116/CMakeLists.txt
new file mode 100644
index 0000000000..b646c4ac67
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.18)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0116/Common.cmake b/Tests/RunCMake/CMP0116/Common.cmake
new file mode 100644
index 0000000000..472b1625b3
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/Common.cmake
@@ -0,0 +1,8 @@
+add_custom_command(
+ OUTPUT top.txt
+ COMMAND ${CMAKE_COMMAND} -DOUTFILE=top.txt -DINFILE=topdep.txt -DDEPFILE=top.txt.d -DSTAMPFILE=topstamp.txt -DDEPDIR= -P ${CMAKE_SOURCE_DIR}/WriteDepfile.cmake
+ DEPFILE top.txt.d
+ )
+add_custom_target(top ALL DEPENDS top.txt)
+
+add_subdirectory(Subdirectory)
diff --git a/Tests/RunCMake/CMP0116/RunCMakeTest.cmake b/Tests/RunCMake/CMP0116/RunCMakeTest.cmake
new file mode 100644
index 0000000000..8a83cc1d3f
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/RunCMakeTest.cmake
@@ -0,0 +1,49 @@
+include(RunCMake)
+
+function(run_cmp0116 status warn)
+ if(warn)
+ set(name CMP0116-${status}-WARN)
+ else()
+ set(name CMP0116-${status}-NOWARN)
+ endif()
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_POLICY_WARNING_CMP0116:BOOL=${warn}
+ )
+ if(NOT status STREQUAL "WARN")
+ list(APPEND RunCMake_TEST_OPTIONS
+ -DCMAKE_POLICY_DEFAULT_CMP0116:STRING=${status}
+ )
+ endif()
+
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
+ run_cmake(${name})
+ unset(RunCMake_TEST_OPTIONS)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake-check-file check.cmake)
+
+ file(TOUCH "${RunCMake_TEST_BINARY_DIR}/topdep.txt")
+ file(TOUCH "${RunCMake_TEST_BINARY_DIR}/Subdirectory/subdep.txt")
+ set(cmp0116_step 1)
+ run_cmake_command(${name}-build1 ${CMAKE_COMMAND} --build . --config Debug)
+ file(REMOVE "${RunCMake_TEST_BINARY_DIR}/topstamp.txt")
+ file(REMOVE "${RunCMake_TEST_BINARY_DIR}/Subdirectory/substamp.txt")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.25)
+
+ file(TOUCH "${RunCMake_TEST_BINARY_DIR}/topdep.txt")
+ file(TOUCH "${RunCMake_TEST_BINARY_DIR}/Subdirectory/subdep.txt")
+ set(cmp0116_step 2)
+ run_cmake_command(${name}-build2 ${CMAKE_COMMAND} --build . --config Debug)
+ file(REMOVE "${RunCMake_TEST_BINARY_DIR}/topstamp.txt")
+ file(REMOVE "${RunCMake_TEST_BINARY_DIR}/Subdirectory/substamp.txt")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.25)
+
+ set(cmp0116_step 3)
+ run_cmake_command(${name}-build3 ${CMAKE_COMMAND} --build . --config Debug)
+endfunction()
+
+run_cmp0116(WARN OFF)
+run_cmp0116(OLD OFF)
+run_cmp0116(NEW OFF)
+run_cmp0116(WARN ON)
+run_cmp0116(OLD ON)
+run_cmp0116(NEW ON)
diff --git a/Tests/RunCMake/CMP0116/Subdirectory/CMakeLists.txt b/Tests/RunCMake/CMP0116/Subdirectory/CMakeLists.txt
new file mode 100644
index 0000000000..f0f60b2a2d
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/Subdirectory/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_custom_command(
+ OUTPUT sub.txt
+ COMMAND ${CMAKE_COMMAND} -DOUTFILE=sub.txt -DINFILE=subdep.txt -DDEPFILE=sub.txt.d -DSTAMPFILE=substamp.txt -DDEPDIR=${depdir} -P ${CMAKE_SOURCE_DIR}/WriteDepfile.cmake
+ DEPFILE ${depdir}sub.txt.d
+ )
+add_custom_target(sub ALL DEPENDS sub.txt)
diff --git a/Tests/RunCMake/CMP0116/WriteDepfile.cmake b/Tests/RunCMake/CMP0116/WriteDepfile.cmake
new file mode 100644
index 0000000000..1a74d2a8cc
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/WriteDepfile.cmake
@@ -0,0 +1,3 @@
+file(TOUCH "${OUTFILE}")
+file(TOUCH "${STAMPFILE}")
+file(WRITE "${DEPFILE}" "${DEPDIR}${OUTFILE}: ${DEPDIR}${INFILE}\n")
diff --git a/Tests/RunCMake/CMP0116/check.cmake b/Tests/RunCMake/CMP0116/check.cmake
new file mode 100644
index 0000000000..1b16748da1
--- /dev/null
+++ b/Tests/RunCMake/CMP0116/check.cmake
@@ -0,0 +1,18 @@
+function(check_exists file)
+ if(NOT EXISTS "${file}")
+ string(APPEND RunCMake_TEST_FAILED "${file} does not exist\n")
+ endif()
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+endfunction()
+
+function(check_not_exists file)
+ if(EXISTS "${file}")
+ string(APPEND RunCMake_TEST_FAILED "${file} exists\n")
+ endif()
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+endfunction()
+
+if(cmp0116_step EQUAL 3)
+ check_not_exists("${RunCMake_TEST_BINARY_DIR}/topstamp.txt")
+ check_not_exists("${RunCMake_TEST_BINARY_DIR}/Subdirectory/substamp.txt")
+endif()