Strip debug symbols to separate file on MacOS X
The standard Xcode toolchain on MacOS X uses strip and dsymutil, not objcopy as the GNU toolchain does.
This commit is contained in:
parent
8337669389
commit
74fdd3e25b
@ -29,10 +29,20 @@ if (CXX_COMPAT_GCC)
|
|||||||
# extracting the debug info is done by a separate utility in the GNU
|
# extracting the debug info is done by a separate utility in the GNU
|
||||||
# toolchain. check that this is actually installed.
|
# toolchain. check that this is actually installed.
|
||||||
message (STATUS "Looking for strip utility")
|
message (STATUS "Looking for strip utility")
|
||||||
find_program (OBJCOPY
|
if (APPLE)
|
||||||
objcopy
|
# MacOS X has a duo of utilities; we need both
|
||||||
${CYGWIN_INSTALL_PATH}/bin /usr/bin /usr/local/bin
|
find_program (OBJCOPY strip)
|
||||||
)
|
find_program (DSYMUTIL dsymutil)
|
||||||
|
mark_as_advanced (DSYMUTIL)
|
||||||
|
if (NOT DSYMUTIL)
|
||||||
|
set (OBJCOPY dsymutil-NOTFOUND)
|
||||||
|
endif (NOT DSYMUTIL)
|
||||||
|
else (APPLE)
|
||||||
|
find_program (OBJCOPY
|
||||||
|
objcopy
|
||||||
|
${CYGWIN_INSTALL_PATH}/bin /usr/bin /usr/local/bin
|
||||||
|
)
|
||||||
|
endif (APPLE)
|
||||||
mark_as_advanced (OBJCOPY)
|
mark_as_advanced (OBJCOPY)
|
||||||
if (OBJCOPY)
|
if (OBJCOPY)
|
||||||
message (STATUS "Looking for strip utility - found")
|
message (STATUS "Looking for strip utility - found")
|
||||||
@ -80,21 +90,37 @@ function (strip_debug_symbols targets)
|
|||||||
get_target_property (_target_soversion ${target} SOVERSION)
|
get_target_property (_target_soversion ${target} SOVERSION)
|
||||||
get_target_property (_target_version ${target} VERSION)
|
get_target_property (_target_version ${target} VERSION)
|
||||||
if (_target_soversion)
|
if (_target_soversion)
|
||||||
set (_target_file_name "${_name}${_ext}.${_target_version}")
|
# MacOS X puts the version number before the extension
|
||||||
|
if (APPLE)
|
||||||
|
set (_target_file_name "${_name}.${_target_version}${_ext}")
|
||||||
|
else (APPLE)
|
||||||
|
set (_target_file_name "${_name}${_ext}.${_target_version}")
|
||||||
|
endif (APPLE)
|
||||||
else (_target_soversion)
|
else (_target_soversion)
|
||||||
set (_target_file_name "${_name}${_ext}")
|
set (_target_file_name "${_name}${_ext}")
|
||||||
endif (_target_soversion)
|
endif (_target_soversion)
|
||||||
set (_target_file "${_dir}${_target_file_name}")
|
set (_target_file "${_dir}${_target_file_name}")
|
||||||
# do without generator expressions (which doesn't work everywhere)
|
# do without generator expressions (which doesn't work everywhere)
|
||||||
set (_debug_ext ".debug")
|
if (APPLE)
|
||||||
add_custom_command (TARGET ${target}
|
set (_debug_ext ".dSYM")
|
||||||
POST_BUILD
|
add_custom_command (TARGET ${target}
|
||||||
WORKING_DIRECTORY ${_dir}
|
POST_BUILD
|
||||||
COMMAND ${OBJCOPY} ARGS --only-keep-debug ${_target_file} ${_target_file}${_debug_ext}
|
WORKING_DIRECTORY ${_dir}
|
||||||
COMMAND ${OBJCOPY} ARGS ${_strip_args} ${_target_file}
|
COMMAND ${DSYMUTIL} ARGS --flat --out=${_target_file}${_debug_ext} ${_target_file}
|
||||||
COMMAND ${OBJCOPY} ARGS --add-gnu-debuglink=${_target_file_name}${_debug_ext} ${_target_file}
|
COMMAND ${OBJCOPY} ARGS -S ${_target_file}
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
else (APPLE)
|
||||||
|
set (_debug_ext ".debug")
|
||||||
|
add_custom_command (TARGET ${target}
|
||||||
|
POST_BUILD
|
||||||
|
WORKING_DIRECTORY ${_dir}
|
||||||
|
COMMAND ${OBJCOPY} ARGS --only-keep-debug ${_target_file} ${_target_file}${_debug_ext}
|
||||||
|
COMMAND ${OBJCOPY} ARGS ${_strip_args} ${_target_file}
|
||||||
|
COMMAND ${OBJCOPY} ARGS --add-gnu-debuglink=${_target_file_name}${_debug_ext} ${_target_file}
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endif (APPLE)
|
||||||
# add this .debug file to the list
|
# add this .debug file to the list
|
||||||
file (RELATIVE_PATH _this_debug_file "${PROJECT_BINARY_DIR}" "${_target_file}${_debug_ext}")
|
file (RELATIVE_PATH _this_debug_file "${PROJECT_BINARY_DIR}" "${_target_file}${_debug_ext}")
|
||||||
set (_debug_files ${_debug_files} ${_this_debug_file})
|
set (_debug_files ${_debug_files} ${_this_debug_file})
|
||||||
|
Loading…
Reference in New Issue
Block a user