summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-01-19 17:50:43 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-01-19 17:50:43 +0100
commitd9d9396324d27f70532ab4e9c878cb3c9e329385 (patch)
treefb8595b5f722bcf1acee398580dae0b2bc78ed88
parentea81c7295c71a2280922034e0929c95496833459 (diff)
downloadtde-cmake-d9d93963.tar.gz
tde-cmake-d9d93963.zip
Update tde_create_tarball macro
+ Use external tar for ensure files owner in tarball. + Add an option to specify compression program. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--modules/TDEMacros.cmake44
1 files changed, 43 insertions, 1 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index d48033c..baa51d1 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -1593,6 +1593,7 @@ macro( tde_create_tarball )
unset( _files )
unset( _destination )
set( _sourcedir "${CMAKE_CURRENT_SOURCE_DIR}" )
+ set( _compression "gzip" )
set( _var _target )
foreach( _arg ${ARGN} )
@@ -1625,6 +1626,13 @@ macro( tde_create_tarball )
set( _directive 1 )
endif( )
+ # found directive "COMPRESSION"
+ if( "+${_arg}" STREQUAL "+COMPRESSION" )
+ unset( _compression )
+ set( _var _compression )
+ set( _directive 1 )
+ endif( )
+
# collect data
if( _directive )
unset( _directive )
@@ -1647,6 +1655,39 @@ macro( tde_create_tarball )
list( APPEND _files_deps "${_sourcedir}/${_file}" )
endforeach( )
+ if( NOT DEFINED TAR_EXECUTABLE )
+ find_program( TAR_EXECUTABLE NAMES tar )
+ if( "${TAR_EXECUTABLE}" STREQUAL "TAR_EXECUTABLE-NOTFOUND" )
+ tde_message_fatal( "tar executable is required but not found on your system" )
+ endif( )
+ endif( )
+
+ if( NOT DEFINED TAR_SETOWNER )
+ execute_process(
+ COMMAND ${TAR_EXECUTABLE} --version
+ OUTPUT_VARIABLE TAR_VERSION
+ )
+ string( REGEX REPLACE "^([^\n]*)\n.*" "\\1" TAR_VERSION "${TAR_VERSION}" )
+ if( "${TAR_VERSION}" MATCHES "GNU *tar" )
+ set( TAR_SETOWNER "--owner=root;--group=root" )
+ elseif( "${TAR_VERSION}" MATCHES "bsd *tar" )
+ set( TAR_SETOWNER "--uname=root;--gname=root" )
+ else( )
+ set( TAR_SETOWNER "" )
+ endif( )
+ endif( )
+
+ if( "${_compression}" STREQUAL "-" )
+ unset( _compression )
+ endif( )
+ if( _compression )
+ if( "${_compression}" STREQUAL "gzip" )
+ set( _compression "-z" )
+ else( )
+ set( _compression "--use-compress-program=\"${_compression}\"" )
+ endif( )
+ 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}" )
@@ -1654,7 +1695,8 @@ macro( tde_create_tarball )
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_target}" )
add_custom_command(
- COMMAND ${CMAKE_COMMAND} -E tar "cfz" "${CMAKE_CURRENT_BINARY_DIR}/${_target}" -- ${_files}
+ COMMAND ${TAR_EXECUTABLE} cf ${CMAKE_CURRENT_BINARY_DIR}/${_target}
+ ${_compression} ${TAR_SETOWNER} -- ${_files}
WORKING_DIRECTORY "${_sourcedir}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_target}"
DEPENDS ${_files_deps}