| 1 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
# SPDX-License-Identifier: Apache-2.0. |
| 3 |
|
| 4 |
include(GNUInstallDirs) |
| 5 |
|
| 6 |
function(aws_prepare_shared_lib_exports target) |
| 7 |
if (BUILD_SHARED_LIBS) |
| 8 |
install(TARGETS ${target} |
| 9 |
EXPORT ${target}-targets |
| 10 |
ARCHIVE |
| 11 |
DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 12 |
COMPONENT Development |
| 13 |
LIBRARY |
| 14 |
DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 15 |
NAMELINK_SKIP |
| 16 |
COMPONENT Runtime |
| 17 |
RUNTIME |
| 18 |
DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 19 |
COMPONENT Runtime) |
| 20 |
install(TARGETS ${target} |
| 21 |
EXPORT ${target}-targets |
| 22 |
LIBRARY |
| 23 |
DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 24 |
NAMELINK_ONLY |
| 25 |
COMPONENT Development) |
| 26 |
else() |
| 27 |
install(TARGETS ${target} |
| 28 |
EXPORT ${target}-targets |
| 29 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 30 |
COMPONENT Development) |
| 31 |
endif() |
| 32 |
endfunction() |
| 33 |
|
| 34 |
function(aws_prepare_symbol_visibility_args target lib_prefix) |
| 35 |
if (BUILD_SHARED_LIBS) |
| 36 |
target_compile_definitions(${target} PUBLIC "-D${lib_prefix}_USE_IMPORT_EXPORT") |
| 37 |
target_compile_definitions(${target} PRIVATE "-D${lib_prefix}_EXPORTS") |
| 38 |
endif() |
| 39 |
endfunction() |
| 40 |
|
| 41 |
# Strips debug info from the target shared library or executable, and puts it in a $<TARGET_FILE:${target}>.dbg |
| 42 |
# archive, then links the original binary to the dbg archive so gdb will find it |
| 43 |
# This only applies to Unix shared libs and executables, windows has pdbs. |
| 44 |
# This is only done on Release and RelWithDebInfo build types |
| 45 |
function(aws_split_debug_info target) |
| 46 |
if (UNIX AND CMAKE_BUILD_TYPE MATCHES Rel AND CMAKE_STRIP AND CMAKE_OBJCOPY) |
| 47 |
get_target_property(target_type ${target} TYPE) |
| 48 |
if (target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "EXECUTABLE") |
| 49 |
add_custom_command(TARGET ${target} POST_BUILD |
| 50 |
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:${target}> $<TARGET_FILE:${target}>.dbg |
| 51 |
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded $<TARGET_FILE:${target}> |
| 52 |
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:${target}>.dbg $<TARGET_FILE:${target}>) |
| 53 |
endif() |
| 54 |
endif() |
| 55 |
endfunction() |