Use ament_export_link_flags() to export -rdynamic from tracetools

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
Christophe Bedard 2020-03-08 23:08:25 -04:00
parent 2691fae27f
commit ae9dd2431b
2 changed files with 8 additions and 14 deletions

View file

@ -112,6 +112,13 @@ install(
ament_export_include_directories(include)
if(TRACETOOLS_LTTNG_ENABLED)
ament_export_libraries(${PROJECT_NAME} ${LTTNG_LIBRARIES})
# Export -rdynamic for downtream packages to use when calling
# ament_target_dependencies()
# which is needed to resolve function addresses to symbols when
# using function pointers directly/without std::bind()
# (the flag should not be used on Windows, but TRACETOOLS_LTTNG_ENABLED
# should never be true on Windows anyway, so there is no need to check)
ament_export_link_flags("-rdynamic")
else()
ament_export_libraries(${PROJECT_NAME})
endif()
@ -127,6 +134,7 @@ if(BUILD_TESTING)
if(TRACETOOLS_LTTNG_ENABLED)
ament_add_gtest(test_utils test/test_utils.cpp)
if(TARGET test_utils)
# Since we cannot use ament_target_dependencies(... tracetools) in the same file
target_link_libraries(test_utils ${PROJECT_NAME} -rdynamic)
endif()
endif()

View file

@ -31,13 +31,6 @@ if(BUILD_TESTING)
find_package(std_srvs REQUIRED)
find_package(tracetools REQUIRED)
# Avoid using -rdynamic on Windows
if(NOT WIN32)
set(RDYNAMIC_FLAG "-rdynamic")
else()
set(RDYNAMIC_FLAG "")
endif()
add_executable(test_publisher
src/test_publisher.cpp
)
@ -46,7 +39,6 @@ if(BUILD_TESTING)
std_msgs
tracetools
)
target_link_libraries(test_publisher "${RDYNAMIC_FLAG}")
add_executable(test_intra
src/test_intra.cpp
)
@ -55,7 +47,6 @@ if(BUILD_TESTING)
std_msgs
tracetools
)
target_link_libraries(test_intra "${RDYNAMIC_FLAG}")
add_executable(test_ping
src/test_ping.cpp
)
@ -64,7 +55,6 @@ if(BUILD_TESTING)
std_msgs
tracetools
)
target_link_libraries(test_ping "${RDYNAMIC_FLAG}")
add_executable(test_pong
src/test_pong.cpp
)
@ -73,7 +63,6 @@ if(BUILD_TESTING)
std_msgs
tracetools
)
target_link_libraries(test_pong "${RDYNAMIC_FLAG}")
add_executable(test_timer
src/test_timer.cpp
)
@ -81,7 +70,6 @@ if(BUILD_TESTING)
rclcpp
tracetools
)
target_link_libraries(test_timer "${RDYNAMIC_FLAG}")
add_executable(test_service_ping
src/test_service_ping.cpp
)
@ -90,7 +78,6 @@ if(BUILD_TESTING)
std_srvs
tracetools
)
target_link_libraries(test_service_ping "${RDYNAMIC_FLAG}")
add_executable(test_service_pong
src/test_service_pong.cpp
)
@ -99,7 +86,6 @@ if(BUILD_TESTING)
std_srvs
tracetools
)
target_link_libraries(test_service_pong "${RDYNAMIC_FLAG}")
install(TARGETS
test_intra