1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
find_package(ament_cmake_gtest REQUIRED)
include("../cmake/class_loader_hide_library_symbols.cmake")
# Link this 'library' to set the compile-time options requested
add_library(project_options INTERFACE)
include(../cmake/sanitizers.cmake)
enable_sanitizers(project_options)
add_library(${PROJECT_NAME}_TestPlugins1 EXCLUDE_FROM_ALL SHARED plugins1.cpp)
target_link_libraries(${PROJECT_NAME}_TestPlugins1 ${PROJECT_NAME})
class_loader_hide_library_symbols(${PROJECT_NAME}_TestPlugins1)
add_library(${PROJECT_NAME}_TestPlugins2 EXCLUDE_FROM_ALL SHARED plugins2.cpp)
target_link_libraries(${PROJECT_NAME}_TestPlugins2 ${PROJECT_NAME})
class_loader_hide_library_symbols(${PROJECT_NAME}_TestPlugins2)
# These plugins are loaded using dlopen() with RTLD_GLOBAL in utest and may cause side effects
# in other tests if they are used elsewhere.
add_library(${PROJECT_NAME}_TestGlobalPlugins EXCLUDE_FROM_ALL SHARED global_plugins.cpp)
target_link_libraries(${PROJECT_NAME}_TestGlobalPlugins ${PROJECT_NAME})
class_loader_hide_library_symbols(${PROJECT_NAME}_TestGlobalPlugins)
if(WIN32)
set(append_library_dirs "$<TARGET_FILE_DIR:${PROJECT_NAME}>;$<TARGET_FILE_DIR:${PROJECT_NAME}_TestPlugins1>")
else()
set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR}")
endif()
ament_add_gtest(${PROJECT_NAME}_utest utest.cpp
APPEND_LIBRARY_DIRS "${append_library_dirs}"
)
if(TARGET ${PROJECT_NAME}_utest)
if(ament_cmake_FOUND)
target_include_directories(${PROJECT_NAME}_utest
PUBLIC "../include")
target_link_libraries(${PROJECT_NAME}_utest
console_bridge::console_bridge)
else()
target_include_directories(${PROJECT_NAME}_utest
PUBLIC "../include" ${console_bridge_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}_utest)
endif()
target_link_libraries(${PROJECT_NAME}_utest ${PROJECT_NAME} project_options)
if(NOT WIN32)
target_link_libraries(${PROJECT_NAME}_utest pthread)
endif()
add_dependencies(${PROJECT_NAME}_utest
${PROJECT_NAME}_TestPlugins1
${PROJECT_NAME}_TestPlugins2
${PROJECT_NAME}_TestGlobalPlugins)
endif()
ament_add_gtest(${PROJECT_NAME}_unique_ptr_test unique_ptr_test.cpp
APPEND_LIBRARY_DIRS "${append_library_dirs}"
)
if(TARGET ${PROJECT_NAME}_unique_ptr_test)
if(ament_cmake_FOUND)
target_include_directories(${PROJECT_NAME}_unique_ptr_test
PUBLIC "../include")
else()
target_include_directories(${PROJECT_NAME}_unique_ptr_test
PUBLIC "../include")
target_link_libraries(${PROJECT_NAME}_unique_ptr_test)
endif()
target_link_libraries(${PROJECT_NAME}_unique_ptr_test ${PROJECT_NAME} project_options)
if(NOT WIN32)
target_link_libraries(${PROJECT_NAME}_unique_ptr_test pthread)
endif()
add_dependencies(${PROJECT_NAME}_unique_ptr_test
${PROJECT_NAME}_TestPlugins1
${PROJECT_NAME}_TestPlugins2)
endif()
add_subdirectory(fviz_case_study)
|