From 1334ee8b96cb6e5ceb5880b9d2fa9fadf5dc50f9 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 30 Aug 2022 09:08:00 +0900 Subject: [PATCH] CMake: Always strip the Release binary --- CMake/platforms/n3ds.cmake | 3 +++ CMake/platforms/ps4.cmake | 40 ++++++++++++++++++++------------------ CMakeLists.txt | 8 ++++++++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/CMake/platforms/n3ds.cmake b/CMake/platforms/n3ds.cmake index ab8c930e7..2756b7fba 100644 --- a/CMake/platforms/n3ds.cmake +++ b/CMake/platforms/n3ds.cmake @@ -23,6 +23,9 @@ list(APPEND DEVILUTIONX_PLATFORM_SUBDIRECTORIES platform/ctr) list(APPEND DEVILUTIONX_PLATFORM_LINK_LIBRARIES libdevilutionx_ctr) list(APPEND DEVILUTIONX_PLATFORM_COMPILE_DEFINITIONS __3DS__) +# The 3ds build handles the stripping in a custom way. +set(DEVILUTIONX_DISABLE_STRIP ON) + #SDL video mode parameters set(SDL1_VIDEO_MODE_FLAGS SDL_DOUBLEBUF|SDL_HWSURFACE) set(SDL1_FORCE_SVID_VIDEO_MODE ON) diff --git a/CMake/platforms/ps4.cmake b/CMake/platforms/ps4.cmake index aa39f6953..13a8bd7f3 100644 --- a/CMake/platforms/ps4.cmake +++ b/CMake/platforms/ps4.cmake @@ -1,19 +1,21 @@ -set(DISCORD_INTEGRATION OFF) -set(BUILD_TESTING OFF) -set(ASAN OFF) -set(UBSAN OFF) -SET(DISABLE_LTO ON) -set(NONET ON) -set(NOEXIT ON) -set(BUILD_ASSETS_MPQ ON) - -# Packbrew SDK provides SDL_image, but FindSDL2_image() fails to -# pick up its dependencies (with includes libjpeg, libwebp etc). -# One way to address this, is to do the following: -# -# target_link_libraries(${BIN_TARGET} PUBLIC ${PC_SDL2_image_LIBRARIES}) -# -# or simply use the in-tree copy as follows: -set(DEVILUTIONX_SYSTEM_SDL_IMAGE OFF) - - +set(DISCORD_INTEGRATION OFF) +set(BUILD_TESTING OFF) +set(ASAN OFF) +set(UBSAN OFF) +SET(DISABLE_LTO ON) +set(NONET ON) +set(NOEXIT ON) +set(BUILD_ASSETS_MPQ ON) + +# Packbrew SDK provides SDL_image, but FindSDL2_image() fails to +# pick up its dependencies (with includes libjpeg, libwebp etc). +# One way to address this, is to do the following: +# +# target_link_libraries(${BIN_TARGET} PUBLIC ${PC_SDL2_image_LIBRARIES}) +# +# or simply use the in-tree copy as follows: +set(DEVILUTIONX_SYSTEM_SDL_IMAGE OFF) + +# If the executable is stripped, create-fself fails with: +# Failed to build FSELF: no symbol section +set(DEVILUTIONX_DISABLE_STRIP ON) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94d50455b..9c872e119 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,6 +301,14 @@ else() Packaging/windows/devilutionx.rc Packaging/apple/AppIcon.icns Packaging/apple/LaunchScreen.storyboard) + + if(CMAKE_STRIP AND NOT DEVILUTIONX_DISABLE_STRIP) + add_custom_command( + TARGET ${BIN_TARGET} POST_BUILD + DEPENDS ${BIN_TARGET} + COMMAND $<$:${CMAKE_STRIP}> + ARGS --strip-all $) + endif() endif() if(NOT UWP_LIB)