diff --git a/CMakeLists.txt b/CMakeLists.txt index 844555c1..b8abe511 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,10 @@ if (UNIX) add_definitions(-DUNIXCOMMON) endif() +if(CMAKE_COMPILER_IS_GNUCC) + find_program(OBJCOPY objcopy) +endif() + if(${CMAKE_SYSTEM} MATCHES "Linux") add_definitions(-DLINUX) if(${SRB2_SYSTEM_BITS} EQUAL 64) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index dc93b6e4..b4eeeeb5 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -208,6 +208,18 @@ if(${SDL2_FOUND}) -DHAVE_SDL ) + ## strip debug symbols into separate file when using gcc + if(CMAKE_COMPILER_IS_GNUCC) + if(${CMAKE_BUILD_TYPE} MATCHES Debug) + message(STATUS "Will make separate debug symbols in *.debug") + add_custom_command(TARGET ${SRB2_SDL2_EXE_NAME} POST_BUILD + COMMAND ${OBJCOPY} --only-keep-debug $ $.debug + COMMAND ${OBJCOPY} --strip-debug $ + COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ + ) + endif() + endif() + #### Installation #### if (CLANG) install(TARGETS ${SRB2_SDL2_EXE_NAME}