2022-06-30 21:35:44 +00:00
macro ( clickhouse_split_debug_symbols )
2022-03-10 21:23:28 +00:00
set ( oneValueArgs TARGET DESTINATION_DIR BINARY_PATH )
cmake_parse_arguments ( STRIP "" "${oneValueArgs}" "" ${ ARGN } )
if ( NOT DEFINED STRIP_TARGET )
message ( FATAL_ERROR "A target name must be provided for stripping binary" )
endif ( )
if ( NOT DEFINED STRIP_BINARY_PATH )
message ( FATAL_ERROR "A binary path name must be provided for stripping binary" )
endif ( )
if ( NOT DEFINED STRIP_DESTINATION_DIR )
message ( FATAL_ERROR "Destination directory for stripped binary must be provided" )
endif ( )
add_custom_command ( TARGET ${ STRIP_TARGET } POST_BUILD
2022-03-23 22:15:08 +00:00
C O M M A N D m k d i r - p " $ { S T R I P _ D E S T I N A T I O N _ D I R } / l i b / d e b u g / b i n "
2022-03-23 14:14:30 +00:00
C O M M A N D m k d i r - p " $ { S T R I P _ D E S T I N A T I O N _ D I R } / b i n "
C O M M A N D c p " $ { S T R I P _ B I N A R Y _ P A T H } " " $ { S T R I P _ D E S T I N A T I O N _ D I R } / b i n / $ { S T R I P _ T A R G E T } "
2022-06-14 18:12:07 +00:00
# Splits debug symbols into separate file, leaves the binary untouched:
2022-03-23 22:15:08 +00:00
C O M M A N D " $ { O B J C O P Y _ P A T H } " - - o n l y - k e e p - d e b u g - - c o m p r e s s - d e b u g - s e c t i o n s " $ { S T R I P _ D E S T I N A T I O N _ D I R } / b i n / $ { S T R I P _ T A R G E T } " " $ { S T R I P _ D E S T I N A T I O N _ D I R } / l i b / d e b u g / b i n / $ { S T R I P _ T A R G E T } . d e b u g "
C O M M A N D c h m o d 0 6 4 4 " $ { S T R I P _ D E S T I N A T I O N _ D I R } / l i b / d e b u g / b i n / $ { S T R I P _ T A R G E T } . d e b u g "
2022-06-14 18:12:07 +00:00
# Strips binary, sections '.note' & '.comment' are removed in line with Debian's stripping policy: www.debian.org/doc/debian-policy/ch-files.html, section '.clickhouse.hash' is needed for integrity check:
C O M M A N D " $ { S T R I P _ P A T H } " - - r e m o v e - s e c t i o n = . c o m m e n t - - r e m o v e - s e c t i o n = . n o t e - - k e e p - s e c t i o n = . c l i c k h o u s e . h a s h " $ { S T R I P _ D E S T I N A T I O N _ D I R } / b i n / $ { S T R I P _ T A R G E T } "
# Associate stripped binary with debug symbols:
2022-03-24 13:32:43 +00:00
C O M M A N D " $ { O B J C O P Y _ P A T H } " - - a d d - g n u - d e b u g l i n k " $ { S T R I P _ D E S T I N A T I O N _ D I R } / l i b / d e b u g / b i n / $ { S T R I P _ T A R G E T } . d e b u g " " $ { S T R I P _ D E S T I N A T I O N _ D I R } / b i n / $ { S T R I P _ T A R G E T } "
2022-03-23 14:14:30 +00:00
C O M M E N T " S t r i p p i n g c l i c k h o u s e b i n a r y " V E R B A T I M
2022-03-10 21:23:28 +00:00
)
install ( PROGRAMS ${ STRIP_DESTINATION_DIR } /bin/ ${ STRIP_TARGET } DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT clickhouse )
2022-05-20 04:14:52 +00:00
install ( FILES ${ STRIP_DESTINATION_DIR } /lib/debug/bin/ ${ STRIP_TARGET } .debug DESTINATION ${ CMAKE_INSTALL_LIBDIR } /debug/ ${ CMAKE_INSTALL_FULL_BINDIR } COMPONENT clickhouse )
2022-03-10 21:23:28 +00:00
endmacro ( )
2022-03-23 14:14:30 +00:00
macro ( clickhouse_make_empty_debug_info_for_nfpm )
set ( oneValueArgs TARGET DESTINATION_DIR )
cmake_parse_arguments ( EMPTY_DEBUG "" "${oneValueArgs}" "" ${ ARGN } )
if ( NOT DEFINED EMPTY_DEBUG_TARGET )
message ( FATAL_ERROR "A target name must be provided for stripping binary" )
endif ( )
if ( NOT DEFINED EMPTY_DEBUG_DESTINATION_DIR )
message ( FATAL_ERROR "Destination directory for empty debug must be provided" )
endif ( )
add_custom_command ( TARGET ${ EMPTY_DEBUG_TARGET } POST_BUILD
C O M M A N D m k d i r - p " $ { E M P T Y _ D E B U G _ D E S T I N A T I O N _ D I R } / l i b / d e b u g "
C O M M A N D t o u c h " $ { E M P T Y _ D E B U G _ D E S T I N A T I O N _ D I R } / l i b / d e b u g / $ { E M P T Y _ D E B U G _ T A R G E T } . d e b u g "
2022-04-12 05:38:23 +00:00
C O M M E N T " A d d i n g e m p t y d e b u g i n f o f o r N F P M " V E R B A T I M
2022-03-23 14:14:30 +00:00
)
2022-03-24 13:32:43 +00:00
install ( FILES "${EMPTY_DEBUG_DESTINATION_DIR}/lib/debug/${EMPTY_DEBUG_TARGET}.debug" DESTINATION "${CMAKE_INSTALL_LIBDIR}/debug/${CMAKE_INSTALL_FULL_BINDIR}" COMPONENT clickhouse )
2022-03-23 14:14:30 +00:00
endmacro ( )