summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-11-11 18:58:25 (GMT)
committerBrad King <brad.king@kitware.com>2019-11-11 19:16:48 (GMT)
commit1d1fa5d3e4f3594f1c1db258e526c4b747117aa2 (patch)
tree485ed4fdfa0ef330dec9afe87bf2b4146130464c /Tests/RunCMake
parent108207cc849b3c6f3de57c5ba8676465510d0849 (diff)
downloadCMake-1d1fa5d3e4f3594f1c1db258e526c4b747117aa2.zip
CMake-1d1fa5d3e4f3594f1c1db258e526c4b747117aa2.tar.gz
CMake-1d1fa5d3e4f3594f1c1db258e526c4b747117aa2.tar.bz2
Tests: Add RunCMake.CPackCommandLine case for multi-config package
In commit da5ac4bb60 (cpack: Add `CPACK_INSTALL_CMAKE_CONFIGURATIONS` variable, 2019-07-10, v3.16.0-rc1~165^2) we added support for running the `cpack -C ...` command-line with multiple configurations. Add an explicit test for this. Fixes: #19918
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CPackCommandLine/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt4
-rw-r--r--Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt8
-rw-r--r--Tests/RunCMake/CPackCommandLine/MultiConfig.cmake9
-rw-r--r--Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake23
-rw-r--r--Tests/RunCMake/CPackCommandLine/foo.c4
6 files changed, 51 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPackCommandLine/CMakeLists.txt b/Tests/RunCMake/CPackCommandLine/CMakeLists.txt
new file mode 100644
index 0000000..2632ffa
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.16)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt b/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt
new file mode 100644
index 0000000..f2ae844
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt
@@ -0,0 +1,4 @@
+MultiConfig-0\.1\.1-[^/
+]*/lib/(lib|)foo_dbg\.(a|lib)
+MultiConfig-0\.1\.1-[^/
+]*/lib/(lib|)foo_rel\.(a|lib)
diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt b/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt
new file mode 100644
index 0000000..4fb8181
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt
@@ -0,0 +1,8 @@
+^CPack: Create package using ZIP
+CPack: Install projects
+CPack: - Install project: MultiConfig \[Debug\]
+CPack: - Install project: MultiConfig \[Release\]
+CPack: Create package
+CPack: - package: [^
+]*/Tests/RunCMake/CPackCommandLine/MultiConfig-build/MultiConfig-0.1.1-[^
+]*.zip generated.$
diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake b/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake
new file mode 100644
index 0000000..71fd189
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+include(CPack)
+
+add_library(foo foo.c)
+set_property(TARGET foo PROPERTY DEBUG_POSTFIX _dbg)
+set_property(TARGET foo PROPERTY RELEASE_POSTFIX _rel)
+
+install(TARGETS foo)
diff --git a/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
index 991146c..53f4e4f 100644
--- a/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
@@ -8,3 +8,26 @@ set(CPACK_PACKAGE_VERSION "1")
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(NotAGenerator ${CMAKE_CPACK_COMMAND} -G NotAGenerator)
unset(RunCMake_TEST_NO_CLEAN)
+
+function(run_MultiConfig)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/MultiConfig-build")
+ run_cmake(MultiConfig)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(MultiConfig-build-dbg ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(MultiConfig-build-rel ${CMAKE_COMMAND} --build . --config Release)
+ run_cmake_command(MultiConfig-package ${CMAKE_CPACK_COMMAND} -G ZIP -C "Debug\;Release")
+ set(zip_glob "${RunCMake_TEST_BINARY_DIR}/MultiConfig-0.1.1-*.zip")
+ file(GLOB zips "${zip_glob}")
+ set(zip_found 0)
+ foreach(zip IN LISTS zips)
+ set(zip_found 1)
+ run_cmake_command(MultiConfig-check ${CMAKE_COMMAND} -E tar tf "${zip}")
+ endforeach()
+ if(NOT zip_found)
+ message(SEND_ERROR "No package file found at\n ${zip_glob}")
+ endif()
+endfunction()
+
+if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode")
+ run_MultiConfig()
+endif()
diff --git a/Tests/RunCMake/CPackCommandLine/foo.c b/Tests/RunCMake/CPackCommandLine/foo.c
new file mode 100644
index 0000000..c83d856
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/foo.c
@@ -0,0 +1,4 @@
+int foo(void)
+{
+ return 0;
+}