Skip to content

Commit 281fa55

Browse files
committed
Resolves FoundationDB#91: Stripped debug symbols into separate file
1 parent 34cc0b0 commit 281fa55

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,33 @@ target_compile_options(fdbdoc
127127
-fno-omit-frame-pointer
128128
)
129129

130+
# 91: Strip debug symbols into separate file
131+
132+
set(strip_source_file "${CMAKE_BINARY_DIR}/bin/fdbdoc")
133+
134+
if(APPLE)
135+
set(DSYMUTIL "dsymutil")
136+
set(STRIP "strip")
137+
set(strip_destination_file ${strip_source_file}.dwarf)
138+
add_custom_command(
139+
TARGET fdbdoc
140+
COMMAND ${DSYMUTIL} --flat --minimize ${strip_source_file}
141+
COMMAND ${STRIP} -u -r ${strip_source_file}
142+
)
143+
# set fdbdoc.dwarf file to make clean directory
144+
set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${strip_source_file}.dwarf)
145+
else()
146+
set(OBJCOPY "objcopy")
147+
set(strip_destination_file ${strip_source_file}.debug)
148+
add_custom_command(
149+
TARGET fdbdoc
150+
COMMAND ${OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
151+
COMMAND ${OBJCOPY} --strip-unneeded ${strip_source_file}
152+
COMMAND ${OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
153+
)
154+
# set fdbdoc.dwarf file to make clean directory
155+
set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${strip_source_file}.debug)
156+
endif()
157+
130158
install(TARGETS fdbdoc RUNTIME DESTINATION bin)
131159
install(PROGRAMS ${FdbMonitor_EXECUTABLE_PATH} DESTINATION lib/foundationdb/document)

0 commit comments

Comments
 (0)