summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-13 13:39:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-13 13:39:28 (GMT)
commit7d43bcb4db2b26d9f9f8d828198252a44b5560a0 (patch)
tree5a80e647a6cc5d59ebe3b34623d7b9c9b5dc6fed /Tests
parent072372aeb80a5de15a4a9c4ecb3bc0981da0bf11 (diff)
parent7a7793e6d7a230b3c208319dce337c6eec54897a (diff)
downloadCMake-7d43bcb4db2b26d9f9f8d828198252a44b5560a0.zip
CMake-7d43bcb4db2b26d9f9f8d828198252a44b5560a0.tar.gz
CMake-7d43bcb4db2b26d9f9f8d828198252a44b5560a0.tar.bz2
Merge topic 'vs-BuildInParallel'
7a7793e6d7 FindCUDA: Disallow with CMP0147 under Visual Studio d6353e74b4 VS: Add policy to build custom commands concurrently Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8314
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake40
-rw-r--r--Tests/RunCMake/VS10Project/CustomCommandParallel.cmake5
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/find_package/CMP0147-NEW-result.txt1
-rw-r--r--Tests/RunCMake/find_package/CMP0147-NEW-stderr.txt7
-rw-r--r--Tests/RunCMake/find_package/CMP0147-NEW.cmake2
-rw-r--r--Tests/RunCMake/find_package/CMP0147-OLD.cmake2
-rw-r--r--Tests/RunCMake/find_package/CMP0147-WARN.cmake2
-rw-r--r--Tests/RunCMake/find_package/CMP0147-common.cmake3
-rw-r--r--Tests/RunCMake/find_package/RunCMakeTest.cmake5
10 files changed, 70 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake b/Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake
new file mode 100644
index 0000000..87e2f70
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake
@@ -0,0 +1,40 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(found_CustomBuild_cmp0147_new 0)
+set(found_CustomBuild_cmp0147_old 0)
+set(found_BuildInParallel_cmp0147_new 0)
+set(found_BuildInParallel_cmp0147_old 0)
+set(in_CustomBuild_cmp0147 "")
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES [[<CustomBuild Include=".*\\cmp0147-old\.txt\.rule">]])
+ set(found_CustomBuild_cmp0147_old 1)
+ set(in_CustomBuild_cmp0147 "old")
+ endif()
+ if(line MATCHES [[<CustomBuild Include=".*\\cmp0147-new\.txt\.rule">]])
+ set(found_CustomBuild_cmp0147_new 1)
+ set(in_CustomBuild_cmp0147 "new")
+ endif()
+ if(line MATCHES [[</CustomBuild>]])
+ set(in_CustomBuild_cmp0147 "")
+ endif()
+ if(line MATCHES [[<BuildInParallel .*>true</BuildInParallel>]] AND in_CustomBuild_cmp0147)
+ set(found_BuildInParallel_cmp0147_${in_CustomBuild_cmp0147} 1)
+ endif()
+endforeach()
+if(NOT found_CustomBuild_cmp0147_new)
+ string(APPEND RunCMake_TEST_FAILED "CustomBuild for cmp0147-new.txt.rule not found in\n ${vcProjectFile}\n")
+endif()
+if(NOT found_CustomBuild_cmp0147_old)
+ string(APPEND RunCMake_TEST_FAILED "CustomBuild for cmp0147-old.txt.rule not found in\n ${vcProjectFile}\n")
+endif()
+if(NOT found_BuildInParallel_cmp0147_new)
+ string(APPEND RunCMake_TEST_FAILED "BuildInParallel for cmp0147-new.txt.rule not found in\n ${vcProjectFile}\n")
+endif()
+if(found_BuildInParallel_cmp0147_old)
+ string(APPEND RunCMake_TEST_FAILED "BuildInParallel for cmp0147-old.txt.rule incorrectly found in\n ${vcProjectFile}\n")
+endif()
diff --git a/Tests/RunCMake/VS10Project/CustomCommandParallel.cmake b/Tests/RunCMake/VS10Project/CustomCommandParallel.cmake
new file mode 100644
index 0000000..784fc68
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/CustomCommandParallel.cmake
@@ -0,0 +1,5 @@
+cmake_policy(VERSION 3.26) # CMP0147 left unset
+add_custom_command(OUTPUT "cmp0147-old.txt" COMMAND echo)
+cmake_policy(SET CMP0147 NEW)
+add_custom_command(OUTPUT "cmp0147-new.txt" COMMAND echo)
+add_custom_target(foo DEPENDS "cmp0147-old.txt" "cmp0147-new.txt")
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index ed74896..669049a 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -8,6 +8,9 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREA
endif()
run_cmake(CustomCommandGenex)
+if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio 1[1-5] ")
+ run_cmake(CustomCommandParallel)
+endif()
run_cmake(VsCsharpSourceGroup)
run_cmake(VsCSharpCompilerOpts)
run_cmake(ExplicitCMakeLists)
diff --git a/Tests/RunCMake/find_package/CMP0147-NEW-result.txt b/Tests/RunCMake/find_package/CMP0147-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0147-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_package/CMP0147-NEW-stderr.txt b/Tests/RunCMake/find_package/CMP0147-NEW-stderr.txt
new file mode 100644
index 0000000..1caf6c5
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0147-NEW-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at [^
+]*/Modules/FindCUDA.cmake:[0-9]+ \(message\):
+ The FindCUDA module does not work in Visual Studio with policy CMP0147\.
+Call Stack \(most recent call first\):
+ CMP0147-common\.cmake:[0-9]+ \(find_package\)
+ CMP0147-NEW\.cmake:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/find_package/CMP0147-NEW.cmake b/Tests/RunCMake/find_package/CMP0147-NEW.cmake
new file mode 100644
index 0000000..0ca5b6c
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0147-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0147 NEW)
+include(CMP0147-common.cmake)
diff --git a/Tests/RunCMake/find_package/CMP0147-OLD.cmake b/Tests/RunCMake/find_package/CMP0147-OLD.cmake
new file mode 100644
index 0000000..61ecee5
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0147-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0147 OLD)
+include(CMP0147-common.cmake)
diff --git a/Tests/RunCMake/find_package/CMP0147-WARN.cmake b/Tests/RunCMake/find_package/CMP0147-WARN.cmake
new file mode 100644
index 0000000..d5f3e91
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0147-WARN.cmake
@@ -0,0 +1,2 @@
+# leave CMP0147 unset
+include(CMP0147-common.cmake)
diff --git a/Tests/RunCMake/find_package/CMP0147-common.cmake b/Tests/RunCMake/find_package/CMP0147-common.cmake
new file mode 100644
index 0000000..68a86ee
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0147-common.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0146 OLD)
+set(_FindCUDA_testing TRUE)
+find_package(CUDA MODULE)
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index 924aa66..26eb908 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -42,6 +42,11 @@ run_cmake(CMP0145-NEW)
run_cmake(CMP0146-OLD)
run_cmake(CMP0146-WARN)
run_cmake(CMP0146-NEW)
+if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ run_cmake(CMP0147-OLD)
+ run_cmake(CMP0147-WARN)
+ run_cmake(CMP0147-NEW)
+endif()
run_cmake(WrongVersionRange)
run_cmake(EmptyVersionRange)
run_cmake(VersionRangeWithEXACT)