2010-12-03 00:56:26 +03:00
message ( STATUS "=============================================================================" )
message ( STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" )
message ( STATUS "" )
if ( NOT CPackComponentsForAll_BINARY_DIR )
message ( FATAL_ERROR "CPackComponentsForAll_BINARY_DIR not set" )
endif ( NOT CPackComponentsForAll_BINARY_DIR )
if ( NOT CPackGen )
message ( FATAL_ERROR "CPackGen not set" )
endif ( NOT CPackGen )
2010-12-14 21:42:21 +03:00
get_filename_component ( CPACK_LOCATION ${ CMAKE_COMMAND } PATH )
set ( CPackCommand "${CPACK_LOCATION}/cpack" )
message ( "cpack = ${CPackCommand}" )
2010-12-03 00:56:26 +03:00
if ( NOT CPackCommand )
message ( FATAL_ERROR "CPackCommand not set" )
endif ( NOT CPackCommand )
2010-12-11 13:59:02 +03:00
if ( NOT CPackComponentWay )
message ( FATAL_ERROR "CPackComponentWay not set" )
endif ( NOT CPackComponentWay )
2010-12-03 00:56:26 +03:00
set ( expected_file_mask "" )
2010-12-11 13:59:02 +03:00
# The usual default behavior is to expect a single file
2010-12-12 14:19:50 +03:00
# Then some specific generators (Archive, RPM, ...)
# May produce several numbers of files depending on
# CPACK_COMPONENT_xxx values
2010-12-11 13:59:02 +03:00
set ( expected_count 1 )
2010-12-14 21:42:21 +03:00
set ( config_type $ENV{ CMAKE_CONFIG_TYPE } )
set ( config_args )
if ( config_type )
set ( config_args -C ${ config_type } )
2011-03-10 11:48:46 +03:00
endif ( config_type )
set ( config_verbose )
2010-12-12 14:19:50 +03:00
2010-12-03 00:56:26 +03:00
if ( CPackGen MATCHES "ZIP" )
set ( expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip" )
2010-12-11 13:59:02 +03:00
if ( ${ CPackComponentWay } STREQUAL "default" )
set ( expected_count 1 )
endif ( ${ CPackComponentWay } STREQUAL "default" )
2011-01-30 15:11:25 +03:00
if ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
2011-03-03 23:19:13 +03:00
set ( expected_count 3 )
2011-01-30 15:11:25 +03:00
endif ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
if ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
set ( expected_count 4 )
2011-03-03 22:45:43 +03:00
endif ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
if ( ${ CPackComponentWay } STREQUAL "AllInOne" )
set ( expected_count 1 )
endif ( ${ CPackComponentWay } STREQUAL "AllInOne" )
if ( ${ CPackComponentWay } STREQUAL "AllGroupsInOne" )
set ( expected_count 1 )
endif ( ${ CPackComponentWay } STREQUAL "AllGroupsInOne" )
elseif ( CPackGen MATCHES "RPM" )
2011-03-10 11:48:46 +03:00
set ( config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1" )
2011-03-03 22:45:43 +03:00
set ( expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm" )
if ( ${ CPackComponentWay } STREQUAL "default" )
set ( expected_count 1 )
2011-03-10 11:48:46 +03:00
endif ( ${ CPackComponentWay } STREQUAL "default" )
2011-03-03 22:45:43 +03:00
if ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
set ( expected_count 2 )
endif ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
if ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
set ( expected_count 4 )
2011-01-30 15:11:25 +03:00
endif ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
if ( ${ CPackComponentWay } STREQUAL "AllInOne" )
set ( expected_count 1 )
endif ( ${ CPackComponentWay } STREQUAL "AllInOne" )
if ( ${ CPackComponentWay } STREQUAL "AllGroupsInOne" )
set ( expected_count 1 )
endif ( ${ CPackComponentWay } STREQUAL "AllGroupsInOne" )
2010-12-03 00:56:26 +03:00
endif ( CPackGen MATCHES "ZIP" )
2011-02-24 02:43:29 +03:00
# clean-up previously CPack generated files
if ( expected_file_mask )
file ( GLOB expected_file "${expected_file_mask}" )
if ( expected_file )
file ( REMOVE ${ expected_file } )
endif ( expected_file )
endif ( expected_file_mask )
2011-03-10 11:48:46 +03:00
message ( "config_args = ${config_args}" )
message ( "config_verbose = ${config_verbose}" )
execute_process ( COMMAND ${ CPackCommand } ${ config_verbose } -G ${ CPackGen } ${ config_args }
2011-02-24 02:43:29 +03:00
R E S U L T _ V A R I A B L E C P a c k _ r e s u l t
O U T P U T _ V A R I A B L E C P a c k _ o u t p u t
E R R O R _ V A R I A B L E C P a c k _ e r r o r
W O R K I N G _ D I R E C T O R Y $ { C P a c k C o m p o n e n t s F o r A l l _ B I N A R Y _ D I R } )
if ( CPack_result )
message ( FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}" )
else ( CPack_result )
message ( STATUS "CPack_output=${CPack_output}" )
endif ( CPack_result )
2010-12-11 13:59:02 +03:00
# Now verify if the number of expected file is OK
# - using expected_file_mask and
# - expected_count
2010-12-03 00:56:26 +03:00
if ( expected_file_mask )
file ( GLOB expected_file "${expected_file_mask}" )
message ( STATUS "expected_count='${expected_count}'" )
message ( STATUS "expected_file='${expected_file}'" )
message ( STATUS "expected_file_mask='${expected_file_mask}'" )
if ( NOT expected_file )
2010-12-13 00:35:18 +03:00
message ( FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}" )
2010-12-03 00:56:26 +03:00
endif ( NOT expected_file )
list ( LENGTH expected_file actual_count )
message ( STATUS "actual_count='${actual_count}'" )
if ( NOT actual_count EQUAL expected_count )
2010-12-13 00:35:18 +03:00
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})" )
2010-12-03 00:56:26 +03:00
endif ( NOT actual_count EQUAL expected_count )
endif ( expected_file_mask )