1 message(STATUS "=============================================================================")
2 message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
5 if(NOT CPackComponentsForAll_BINARY_DIR)
6 message(FATAL_ERROR "CPackComponentsForAll_BINARY_DIR not set")
10 message(FATAL_ERROR "CPackGen not set")
13 message("CMAKE_CPACK_COMMAND = ${CMAKE_CPACK_COMMAND}")
14 if(NOT CMAKE_CPACK_COMMAND)
15 message(FATAL_ERROR "CMAKE_CPACK_COMMAND not set")
18 if(NOT CPackComponentWay)
19 message(FATAL_ERROR "CPackComponentWay not set")
22 set(expected_file_mask "")
23 # The usual default behavior is to expect a single file
24 # Then some specific generators (Archive, RPM, ...)
25 # May produce several numbers of files depending on
26 # CPACK_COMPONENT_xxx values
28 set(config_type $ENV{CMAKE_CONFIG_TYPE})
31 set(config_args -C ${config_type})
35 if(CPackGen MATCHES "ZIP")
36 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
37 if (${CPackComponentWay} STREQUAL "default")
39 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
41 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
43 elseif (${CPackComponentWay} STREQUAL "AllInOne")
46 elseif (CPackGen MATCHES "RPM")
47 set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1")
48 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm")
49 if (${CPackComponentWay} STREQUAL "default")
51 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
53 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
55 elseif (${CPackComponentWay} STREQUAL "AllInOne")
58 elseif (CPackGen MATCHES "DEB")
59 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb")
60 if (${CPackComponentWay} STREQUAL "default")
62 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
64 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
66 elseif (${CPackComponentWay} STREQUAL "AllInOne")
71 if(CPackGen MATCHES "DragNDrop")
72 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg")
73 if (${CPackComponentWay} STREQUAL "default")
75 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
77 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
79 elseif (${CPackComponentWay} STREQUAL "AllInOne")
84 # clean-up previously CPack generated files
85 if(expected_file_mask)
86 file(GLOB expected_file "${expected_file_mask}")
88 file(REMOVE ${expected_file})
92 message("config_args = ${config_args}")
93 message("config_verbose = ${config_verbose}")
94 execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen} ${config_args}
95 RESULT_VARIABLE CPack_result
96 OUTPUT_VARIABLE CPack_output
97 ERROR_VARIABLE CPack_error
98 WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
101 message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
103 message(STATUS "CPack_output=${CPack_output}")
106 # Now verify if the number of expected file is OK
107 # - using expected_file_mask and
109 if(expected_file_mask)
110 file(GLOB expected_file "${expected_file_mask}")
112 message(STATUS "expected_count='${expected_count}'")
113 message(STATUS "expected_file='${expected_file}'")
114 message(STATUS "expected_file_mask='${expected_file_mask}'")
116 if(NOT expected_file)
117 message(FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
120 list(LENGTH expected_file actual_count)
121 message(STATUS "actual_count='${actual_count}'")
122 if(NOT actual_count EQUAL expected_count)
123 message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})")