You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 line
1.0 KiB

  1. If ( __STRIP_SYMBOLS_INCLUDED )
  2. Return ( )
  3. EndIf ( )
  4. Set ( __STRIP_SYMBOLS_INCLUDED TRUE )
  5. CMake_Minimum_Required ( VERSION 3.0 )
  6. Find_Program ( OBJCOPY objcopy )
  7. If ( OBJCOPY STREQUAL "OBJCOPY-NOTFOUND" )
  8. Message ( FATAL_ERROR "objcopy not found" )
  9. EndIf ( )
  10. Function ( Strip_Symbols TARGET_NAME OUTPUT_FILENAME )
  11. Set ( STRIP_SRC_FILE $<TARGET_FILE:${TARGET_NAME}>)
  12. Set ( STRIP_DST_FILE ${STRIP_SRC_FILE}.dbg )
  13. Add_Custom_Command ( TARGET ${TARGET_NAME}
  14. POST_BUILD
  15. VERBATIM
  16. COMMAND ${OBJCOPY} --only-keep-debug ${STRIP_SRC_FILE} ${STRIP_DST_FILE}
  17. COMMAND ${OBJCOPY} --strip-unneeded ${STRIP_SRC_FILE}
  18. COMMAND ${OBJCOPY} --add-gnu-debuglink=${STRIP_DST_FILE} ${STRIP_SRC_FILE} )
  19. EndFunction ( )