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")
7 endif(NOT CPackComponentsForAll_BINARY_DIR)
10 message(FATAL_ERROR "CPackGen not set")
12 get_filename_component(CPACK_LOCATION ${CMAKE_COMMAND} PATH)
13 set(CPackCommand "${CPACK_LOCATION}/cpack")
14 message("cpack = ${CPackCommand}")
16 message(FATAL_ERROR "CPackCommand not set")
17 endif(NOT CPackCommand)
19 if(NOT CPackComponentWay)
20 message(FATAL_ERROR "CPackComponentWay not set")
21 endif(NOT CPackComponentWay)
23 set(expected_file_mask "")
24 # The usual default behavior is to expect a single file
25 # Then some specific generators (Archive, RPM, ...)
26 # May produce several numbers of files depending on
27 # CPACK_COMPONENT_xxx values
29 set(config_type $ENV{CMAKE_CONFIG_TYPE})
32 set(config_args -C ${config_type})
36 if(CPackGen MATCHES "ZIP")
37 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
38 if (${CPackComponentWay} STREQUAL "default")
40 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
42 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
44 elseif (${CPackComponentWay} STREQUAL "AllInOne")
47 elseif (CPackGen MATCHES "RPM")
48 set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1")
49 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm")
50 if (${CPackComponentWay} STREQUAL "default")
52 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
54 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
56 elseif (${CPackComponentWay} STREQUAL "AllInOne")
59 elseif (CPackGen MATCHES "DEB")
60 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb")
61 if (${CPackComponentWay} STREQUAL "default")
63 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
65 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
67 elseif (${CPackComponentWay} STREQUAL "AllInOne")
72 if(CPackGen MATCHES "DragNDrop")
73 set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg")
74 if (${CPackComponentWay} STREQUAL "default")
76 elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
78 elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
80 elseif (${CPackComponentWay} STREQUAL "AllInOne")
83 endif(CPackGen MATCHES "DragNDrop")
85 # clean-up previously CPack generated files
86 if(expected_file_mask)
87 file(GLOB expected_file "${expected_file_mask}")
89 file(REMOVE ${expected_file})
91 endif(expected_file_mask)
93 message("config_args = ${config_args}")
94 message("config_verbose = ${config_verbose}")
95 execute_process(COMMAND ${CPackCommand} ${config_verbose} -G ${CPackGen} ${config_args}
96 RESULT_VARIABLE CPack_result
97 OUTPUT_VARIABLE CPack_output
98 ERROR_VARIABLE CPack_error
99 WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
102 message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
104 message(STATUS "CPack_output=${CPack_output}")
107 # Now verify if the number of expected file is OK
108 # - using expected_file_mask and
110 if(expected_file_mask)
111 file(GLOB expected_file "${expected_file_mask}")
113 message(STATUS "expected_count='${expected_count}'")
114 message(STATUS "expected_file='${expected_file}'")
115 message(STATUS "expected_file_mask='${expected_file_mask}'")
117 if(NOT expected_file)
118 message(FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
119 endif(NOT expected_file)
121 list(LENGTH expected_file actual_count)
122 message(STATUS "actual_count='${actual_count}'")
123 if(NOT actual_count EQUAL expected_count)
124 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})")
125 endif(NOT actual_count EQUAL expected_count)
126 endif(expected_file_mask)