summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
blob: 53f4e4f930e5c08ba73edc69dc858f38e83ddf56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
include(RunCMake)
set(RunCMake_TEST_TIMEOUT 60)

file(WRITE "${RunCMake_BINARY_DIR}/NotAGenerator-build/CPackConfig.cmake" [[
set(CPACK_PACKAGE_NAME "Test")
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()