mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
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
fc040a44ed
commit
d43ff3c003
@ -29,10 +29,20 @@ if (CXX_COMPAT_GCC)
|
||||
# extracting the debug info is done by a separate utility in the GNU
|
||||
# toolchain. check that this is actually installed.
|
||||
message (STATUS "Looking for strip utility")
|
||||
find_program (OBJCOPY
|
||||
objcopy
|
||||
${CYGWIN_INSTALL_PATH}/bin /usr/bin /usr/local/bin
|
||||
)
|
||||
if (APPLE)
|
||||
# MacOS X has a duo of utilities; we need both
|
||||
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)
|
||||
if (OBJCOPY)
|
||||
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_version ${target} VERSION)
|
||||
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)
|
||||
set (_target_file_name "${_name}${_ext}")
|
||||
endif (_target_soversion)
|
||||
set (_target_file "${_dir}${_target_file_name}")
|
||||
# do without generator expressions (which doesn't work everywhere)
|
||||
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
|
||||
)
|
||||
if (APPLE)
|
||||
set (_debug_ext ".dSYM")
|
||||
add_custom_command (TARGET ${target}
|
||||
POST_BUILD
|
||||
WORKING_DIRECTORY ${_dir}
|
||||
COMMAND ${DSYMUTIL} ARGS --flat --out=${_target_file}${_debug_ext} ${_target_file}
|
||||
COMMAND ${OBJCOPY} ARGS -S ${_target_file}
|
||||
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
|
||||
file (RELATIVE_PATH _this_debug_file "${PROJECT_BINARY_DIR}" "${_target_file}${_debug_ext}")
|
||||
set (_debug_files ${_debug_files} ${_this_debug_file})
|
||||
|
Loading…
Reference in New Issue
Block a user