summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CPack/CPackTestHelpers.cmake
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2016-09-19 21:44:06 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-20 12:24:28 (GMT)
commitd9cec8adca37965ee7c0742688b0f1de7edd9173 (patch)
tree6c820175ab2d241fa88d40583a0b48d5956c9fd8 /Tests/RunCMake/CPack/CPackTestHelpers.cmake
parent5c87b92b1b7888ee032e3c2a75f35f1f94f4dfa5 (diff)
downloadCMake-d9cec8adca37965ee7c0742688b0f1de7edd9173.zip
CMake-d9cec8adca37965ee7c0742688b0f1de7edd9173.tar.gz
CMake-d9cec8adca37965ee7c0742688b0f1de7edd9173.tar.bz2
CPack/RPM: Generate source rpm (SRPM) packages on demand
Closes: #15839
Diffstat (limited to 'Tests/RunCMake/CPack/CPackTestHelpers.cmake')
-rw-r--r--Tests/RunCMake/CPack/CPackTestHelpers.cmake66
1 files changed, 66 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
index 7bf42f9..d09fafe 100644
--- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -1,4 +1,70 @@
cmake_policy(SET CMP0057 NEW)
+function(run_cpack_test_common_for_merge_ TEST_NAME types build source)
+ if(TEST_TYPE IN_LIST types)
+ set(RunCMake_TEST_NO_CLEAN TRUE)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
+
+ # TODO this should be executed only once per ctest run (not per generator)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
+ include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
+
+ set(FOUND_PREREQUIREMENTS false)
+ get_test_prerequirements("FOUND_PREREQUIREMENTS"
+ "${TEST_CONFIG_DIR}/${type}_config.cmake")
+
+ # skip the test if prerequirements are not met
+ if(NOT FOUND_PREREQUIREMENTS)
+ message(STATUS "${TEST_NAME} - SKIPPED")
+ return()
+ endif()
+ endif()
+
+ # execute cmake
+ set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}")
+ run_cmake(${TEST_NAME})
+
+ # execute optional build step
+ if(build)
+ run_cmake_command(${TEST_NAME}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}")
+ endif()
+
+ if(source)
+ set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake)
+ FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake
+ "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${TEST_NAME}\")")
+ else()
+ unset(pack_params_)
+ endif()
+
+ # execute cpack
+ execute_process(
+ COMMAND ${CMAKE_CPACK_COMMAND} ${pack_params_}
+ WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
+ RESULT_VARIABLE "result_"
+ OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt"
+ ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt"
+ )
+
+ # verify result
+ run_cmake_command(
+ ${TEST_TYPE}/${TEST_NAME}
+ "${CMAKE_COMMAND}"
+ -DRunCMake_TEST=${TEST_NAME}
+ -DGENERATOR_TYPE=${TEST_TYPE}
+ -DPACKAGING_RESULT=${result_}
+ "-Dsrc_dir=${RunCMake_SOURCE_DIR}"
+ "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}"
+ "-Dconfig_file=${config_file}"
+ -P "${RunCMake_SOURCE_DIR}/VerifyResult.cmake"
+ )
+ endif()
+endfunction()
+function(run_cpack_source_test TEST_NAME types)
+ run_cpack_test_common_for_merge_("${TEST_NAME}" "${types}" false true)
+endfunction()
function(run_cpack_test TEST_NAME types build)
if(TEST_TYPE IN_LIST types)