Add tde_create_tarball macro.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 6f9d42cd99)
v3.5.13-sru
Slávek Banko 6 years ago
parent 7d2860cb2e
commit b18d54755e
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1430,6 +1430,89 @@ macro( tde_create_handbook )
endmacro( )
#################################################
#####
##### tde_create_tarball
#####
##### Macro is used to create tarball.
#####
macro( tde_create_tarball )
unset( _target )
unset( _files )
unset( _destination )
set( _sourcedir "${CMAKE_CURRENT_SOURCE_DIR}" )
set( _var _target )
foreach( _arg ${ARGN} )
# found directive "TARGET"
if( "+${_arg}" STREQUAL "+TARGET" )
unset( _target )
set( _var _target )
set( _directive 1 )
endif( )
# found directive "SOURCEDIR"
if( "+${_arg}" STREQUAL "+SOURCEDIR" )
unset( _sourcedir )
set( _var _sourcedir )
set( _directive 1 )
endif( )
# found directive "FILES"
if( "+${_arg}" STREQUAL "+FILES" )
unset( _files )
set( _var _files )
set( _directive 1 )
endif( )
# found directive "DESTINATION"
if( "+${_arg}" STREQUAL "+DESTINATION" )
unset( _dest )
set( _var _dest )
set( _directive 1 )
endif( )
# collect data
if( _directive )
unset( _directive )
elseif( _var )
list( APPEND ${_var} ${_arg} )
endif( )
endforeach( )
if( NOT _target )
tde_message_fatal( "Target tarball name not specified." )
endif( )
if( NOT _files )
file( GLOB_RECURSE _files RELATIVE ${_sourcedir} "${_sourcedir}/*" )
endif( )
get_filename_component( _target_path "${CMAKE_CURRENT_BINARY_DIR}/${_target}" ABSOLUTE )
file( RELATIVE_PATH _target_path "${CMAKE_BINARY_DIR}" "${_target_path}" )
string( REPLACE "/" "+" _target_name "${_target_path}" )
add_custom_target( "${_target_name}-tarball" ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_target}" )
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E tar "cfz" "${CMAKE_CURRENT_BINARY_DIR}/${_target}" -- ${_files}
WORKING_DIRECTORY "${_sourcedir}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_target}"
DEPENDS ${_files}
COMMENT "Create tarball ${_target_path}"
)
if( _destination )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_target} DESTINATION ${_destination} )
endif( )
endmacro()
#################################################
#####
##### tde_include_tqt

Loading…
Cancel
Save