Skip to content

Instantly share code, notes, and snippets.

@YarikTH
Last active May 14, 2019 06:45
Show Gist options
  • Select an option

  • Save YarikTH/5ecb69db541eb38977a971d61712d0e5 to your computer and use it in GitHub Desktop.

Select an option

Save YarikTH/5ecb69db541eb38977a971d61712d0e5 to your computer and use it in GitHub Desktop.
cmake: Separate debug symbols on gcc
# https://git.magicalgirl.moe/STJr/SRB2/commit/e08bd452279dbeedbf876fec465ea51a137455a8
## 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 $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}> $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}>.debug
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}>
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:${SRB2_SDL2_EXE_NAME}>.debug $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}>
)
endif()
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment