summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-01-11 03:00:07 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-01-11 03:00:07 +0100
commit6f9d42cd992ded747ffdc1cf407460e5136491fc (patch)
treef2ae42958fb32ea89cf43a7151741727bc2e5626
parent6246f2b46a28c97b6e1946aead7faa48fb7ef3fc (diff)
downloadtde-cmake-6f9d42cd.tar.gz
tde-cmake-6f9d42cd.zip
Add tde_create_tarball macro.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--modules/TDEMacros.cmake83
1 files changed, 83 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 2fa53ec..be4b762 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -1582,6 +1582,89 @@ 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
macro( tde_include_tqt )