Skip to content

Commit

Permalink
export targets (#403)
Browse files Browse the repository at this point in the history
* wip export targets

Signed-off-by: Karsten Knese <[email protected]>

* correct include dirs

Signed-off-by: Karsten Knese <[email protected]>

* relative include paths for vendor packages

Signed-off-by: Karsten Knese <[email protected]>

* cleanup rosbag2_test_common

Signed-off-by: Karsten Knese <[email protected]>

* cleanup shared_queues_vendor package

Signed-off-by: Karsten Knese <[email protected]>

* cleanup sqlite3 vendor package

Signed-off-by: Karsten Knese <[email protected]>

* cleanup zstd_vendor package

Signed-off-by: Karsten Knese <[email protected]>

* cleanup rosbag2_compression

Signed-off-by: Karsten Knese <[email protected]>

* touchups for isolated build

Signed-off-by: Knese Karsten <[email protected]>

* export typesupport

Signed-off-by: Karsten Knese <[email protected]>

* organize included dependencies

Signed-off-by: Karsten Knese <[email protected]>

* unknown import target for sqlite3

Signed-off-by: Karsten Knese <[email protected]>

* try debugging windows

Signed-off-by: Karsten Knese <[email protected]>

* remove fatal error warning

Signed-off-by: Karsten Knese <[email protected]>

* limit amount of change

Signed-off-by: Karsten Knese <[email protected]>

* use CMAKE_INSTALL_PREFIX

Signed-off-by: Karsten Knese <[email protected]>

* fatal_error only when required

Signed-off-by: Karsten Knese <[email protected]>
  • Loading branch information
Karsten1987 authored May 20, 2020
1 parent f32a63c commit ead6f74
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 55 deletions.
24 changes: 10 additions & 14 deletions rosbag2_compression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ find_package(rcutils REQUIRED)
find_package(rosbag2_cpp)
find_package(rosbag2_storage REQUIRED)
find_package(zstd_vendor REQUIRED)
find_package(zstd REQUIRED)

add_library(${PROJECT_NAME}_zstd
SHARED
Expand All @@ -34,13 +35,12 @@ add_library(${PROJECT_NAME}_zstd
target_include_directories(${PROJECT_NAME}_zstd
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${zstd_vendor_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}_zstd ${zstd_vendor_LIBRARIES})
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(${PROJECT_NAME}_zstd
rcpputils
rcutils
rosbag2_storage)
rosbag2_storage
zstd)
# Causes the visibility macros to use dllexport rather than dllimport.
# This is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME}_zstd
Expand Down Expand Up @@ -70,21 +70,17 @@ install(
DESTINATION include)

install(
TARGETS ${PROJECT_NAME}_zstd
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

install(
TARGETS ${PROJECT_NAME}
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_zstd
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME}_zstd)
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(rosbag2_storage rcutils zstd_vendor)
ament_export_libraries(${PROJECT_NAME} ${PROJECT_NAME}_zstd)
ament_export_targets(export_${PROJECT_NAME})
# order matters here, first vendor, then zstd
ament_export_dependencies(rcpputils rcutils rosbag2_cpp rosbag2_storage zstd_vendor zstd)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
Expand Down
5 changes: 4 additions & 1 deletion rosbag2_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ ament_target_dependencies(${PROJECT_NAME}
rosbag2_storage
rosidl_runtime_c
rosidl_runtime_cpp
rosidl_typesupport_introspection_cpp
rosidl_typesupport_cpp
rosidl_typesupport_introspection_cpp
)

target_include_directories(${PROJECT_NAME}
Expand All @@ -87,16 +87,19 @@ install(

install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(pluginlib
rosbag2_storage
rosidl_runtime_c
rosidl_runtime_cpp
rosidl_typesupport_cpp
rosidl_typesupport_introspection_cpp
)

Expand Down
26 changes: 16 additions & 10 deletions rosbag2_storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,38 @@ find_package(rcutils REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)

add_library(
rosbag2_storage
${PROJECT_NAME}
SHARED
src/rosbag2_storage/metadata_io.cpp
src/rosbag2_storage/ros_helper.cpp
src/rosbag2_storage/storage_factory.cpp
src/rosbag2_storage/base_io_interface.cpp)
target_include_directories(rosbag2_storage PUBLIC include)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(
rosbag2_storage
${PROJECT_NAME}
pluginlib
rcpputils
rcutils
yaml_cpp_vendor)

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(rosbag2_storage PRIVATE "ROSBAG2_STORAGE_BUILDING_DLL")
target_compile_definitions(${PROJECT_NAME} PRIVATE "ROSBAG2_STORAGE_BUILDING_DLL")

# prevent pluginlib from using boost
target_compile_definitions(rosbag2_storage PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

install(
DIRECTORY include/
DESTINATION include)

install(
TARGETS rosbag2_storage
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
Expand All @@ -64,6 +69,7 @@ install(

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(pluginlib yaml_cpp_vendor)

if(BUILD_TESTING)
Expand All @@ -78,7 +84,7 @@ if(BUILD_TESTING)
SHARED
test/rosbag2_storage/test_plugin.cpp
test/rosbag2_storage/test_read_only_plugin.cpp)
target_link_libraries(test_plugin rosbag2_storage)
target_link_libraries(test_plugin ${PROJECT_NAME})
install(
TARGETS test_plugin
ARCHIVE DESTINATION lib
Expand All @@ -90,21 +96,21 @@ if(BUILD_TESTING)
test/rosbag2_storage/test_storage_factory.cpp)
if(TARGET test_storage_factory)
target_include_directories(test_storage_factory PRIVATE include)
target_link_libraries(test_storage_factory rosbag2_storage)
target_link_libraries(test_storage_factory ${PROJECT_NAME})
endif()

ament_add_gmock(test_ros_helper
test/rosbag2_storage/test_ros_helper.cpp)
if(TARGET test_ros_helper)
target_include_directories(test_ros_helper PRIVATE include)
target_link_libraries(test_ros_helper rosbag2_storage)
target_link_libraries(test_ros_helper ${PROJECT_NAME})
endif()

ament_add_gmock(test_metadata_serialization
test/rosbag2_storage/test_metadata_serialization.cpp)
if(TARGET test_metadata_serialization)
target_include_directories(test_metadata_serialization PRIVATE include)
target_link_libraries(test_metadata_serialization rosbag2_storage)
target_link_libraries(test_metadata_serialization ${PROJECT_NAME})
ament_target_dependencies(test_metadata_serialization rosbag2_test_common)
endif()
endif()
Expand Down
6 changes: 5 additions & 1 deletion rosbag2_test_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME} INTERFACE rclcpp rcutils)
ament_target_dependencies(${PROJECT_NAME} INTERFACE rclcpp rcutils)

install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME})
install(
DIRECTORY include/
DESTINATION include)
Expand All @@ -42,4 +45,5 @@ endif()
ament_export_dependencies(rclcpp rcutils)

ament_export_include_directories(include)
ament_export_targets(export_${PROJECT_NAME})
ament_package()
22 changes: 11 additions & 11 deletions rosbag2_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ find_package(ament_index_cpp REQUIRED)
if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(ament_lint_auto REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(rmw_fastrtps_cpp QUIET)
find_package(rosbag2_compression REQUIRED)
find_package(rosbag2_cpp REQUIRED)
find_package(rosbag2_storage REQUIRED)
find_package(rosbag2_storage_default_plugins REQUIRED)
find_package(rosbag2_test_common REQUIRED)
find_package(std_msgs REQUIRED)
find_package(test_msgs REQUIRED)

ament_lint_auto_find_test_dependencies()

find_package(rmw_fastrtps_cpp QUIET)
# disable tests that depends on rosbag2_converter_default_plugins at runtime
if(rmw_fastrtps_cpp_FOUND)
find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(rosbag2_compression REQUIRED)
find_package(rosbag2_cpp REQUIRED)
find_package(rosbag2_storage REQUIRED)
find_package(rosbag2_storage_default_plugins REQUIRED)
find_package(rosbag2_test_common REQUIRED)
find_package(std_msgs REQUIRED)
find_package(test_msgs REQUIRED)

ament_add_gmock(test_rosbag2_record_end_to_end
test/rosbag2_tests/test_rosbag2_record_end_to_end.cpp
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
34 changes: 24 additions & 10 deletions shared_queues_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ find_package(ament_cmake REQUIRED)

include(ExternalProject)
# Single producer single consumer queue by moodycamel - header only, don't build, install
ExternalProject_Add(singleproducerconsumer
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/single
ExternalProject_Add(ext-singleproducerconsumer
PREFIX singleproducerconsumer
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download
URL https://github.com/cameron314/readerwriterqueue/archive/ef7dfbf553288064347d51b8ac335f1ca489032a.zip
URL_MD5 64c673dd381b8fae9254053ad7b2be4d
TIMEOUT 60
Expand All @@ -17,8 +18,9 @@ ExternalProject_Add(singleproducerconsumer
)

# Concurrent and blocking concurrent queue by moodycamel - header only, don't build, install
ExternalProject_Add(concurrentqueue
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/multiple
ExternalProject_Add(ext-concurrentqueue
PREFIX concurrentqueue
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download
URL https://github.com/cameron314/concurrentqueue/archive/8f65a8734d77c3cc00d74c0532efca872931d3ce.zip
URL_MD5 71a0d932cc89150c2ade85f0d9cac9dc
TIMEOUT 60
Expand All @@ -28,16 +30,28 @@ ExternalProject_Add(concurrentqueue
INSTALL_COMMAND ""
)

add_library(singleproducerconsumer INTERFACE)
target_include_directories(singleproducerconsumer INTERFACE $<INSTALL_INTERFACE:include/moodycamel>)

add_library(concurrentqueue INTERFACE)
target_include_directories(concurrentqueue INTERFACE $<INSTALL_INTERFACE:include/moodycamel>)

install(
TARGETS singleproducerconsumer concurrentqueue
EXPORT export_${PROJECT_NAME}
INCLUDES DESTINATION include
)

# Install headers
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer-prefix/src/singleproducerconsumer/atomicops.h"
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer-prefix/src/singleproducerconsumer/readerwriterqueue.h"
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue-prefix/src/concurrentqueue/concurrentqueue.h"
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue-prefix/src/concurrentqueue/blockingconcurrentqueue.h"
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer/src/ext-singleproducerconsumer/atomicops.h"
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer/src/ext-singleproducerconsumer/readerwriterqueue.h"
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue/src/ext-concurrentqueue/concurrentqueue.h"
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue/src/ext-concurrentqueue/blockingconcurrentqueue.h"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/moodycamel
)

ament_export_include_directories(include)

ament_package()
ament_export_targets(export_${PROJECT_NAME})
ament_package()
16 changes: 11 additions & 5 deletions sqlite3_vendor/cmake/Modules/FindSQLite3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@

# First attempt to find Config-file package
find_package(SQLite3 CONFIG QUIET)

if (NOT SQLite3_FOUND)


if (SQLite3_FOUND)
message("Found SQLite3 from installed package in ${SQLite3_DIR}")
# https://cmake.org/cmake/help/latest/module/FindSQLite3.html
list(APPEND SQLite3_TARGETS SQLite::SQLite3)
else()
# Get package location hint from environment variable (if any)
if(NOT SQLite3_ROOT_DIR AND DEFINED ENV{SQLite3_ROOT_DIR})
set(SQLite3_ROOT_DIR "$ENV{SQLite3_ROOT_DIR}" CACHE PATH
Expand Down Expand Up @@ -74,11 +75,16 @@ if (NOT SQLite3_FOUND)
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLite3_LIBRARY
SQLite3_INCLUDE_DIR)

set(SQLite3_FOUND ${SQLITE3_FOUND}) # Enforce case-correctness: Set appropriately cased variable...
set(SQLite3_FOUND ${SQLite3_FOUND}) # Enforce case-correctness: Set appropriately cased variable...
unset(SQLITE3_FOUND) # ...and unset uppercase variable generated by find_package_handle_standard_args

if(SQLite3_FOUND)
set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
set(SQLite3_LIBRARIES ${SQLite3_LIBRARY})

add_library(SQLite::SQLite3 UNKNOWN IMPORTED)
set_property(TARGET SQLite::SQLite3 PROPERTY IMPORTED_LOCATION ${SQLite3_LIBRARY})
set_property(TARGET SQLite::SQLite3 PROPERTY INCLUDE_DIRECTORIES ${SQLite3_INCLUDE_DIR})
list(APPEND SQLite3_TARGETS SQLite::SQLite3)
endif()
endif()
8 changes: 5 additions & 3 deletions zstd_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ macro(build_zstd)
SOURCE_SUBDIR build/cmake
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install
-DZSTD_BUILD_STATIC=OFF
-DZSTD_BUILD_SHARED=ON
-DZSTD_BUILD_PROGRAMS=OFF
${extra_cmake_args})

install(
Expand All @@ -49,7 +52,6 @@ else()
message(STATUS "Found Zstd, skipping build.")
endif()

ament_export_libraries(zstd)
ament_export_include_directories(include)
install(DIRECTORY cmake DESTINATION share/${PROJECT_NAME})

ament_package()
ament_package(CONFIG_EXTRAS zstd_vendor-extras.cmake)
41 changes: 41 additions & 0 deletions zstd_vendor/cmake/Modules/Findzstd.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Get package location hint from environment variable (if any)
if(NOT zstd_ROOT_DIR AND DEFINED ENV{zstd_ROOT_DIR})
set(zstd_ROOT_DIR "$ENV{zstd_ROOT_DIR}" CACHE PATH
"zstd base directory location (optional, used for nonstandard installation paths)")
endif()

# Search path for nonstandard package locations
if(zstd_ROOT_DIR)
set(zstd_INCLUDE_PATH PATHS "${zstd_ROOT_DIR}/include" NO_DEFAULT_PATH)
set(zstd_LIBRARY_PATH PATHS "${zstd_ROOT_DIR}/lib" NO_DEFAULT_PATH)
else()
set(zstd_INCLUDE_PATH "")
set(zstd_LIBRARY_PATH "")
endif()

# Find headers and libraries
find_path(zstd_INCLUDE_DIR NAMES zstd.h PATH_SUFFIXES "zstd" ${zstd_INCLUDE_PATH})
find_library(zstd_LIBRARY NAMES zstd PATH_SUFFIXES "zstd" ${zstd_LIBRARY_PATH})

mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY)

# Output variables generation
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zstd DEFAULT_MSG zstd_LIBRARY zstd_INCLUDE_DIR)

set(zstd_FOUND ${ZSTD_FOUND}) # Enforce case-correctness: Set appropriately cased variable...
unset(ZSTD_FOUND) # ...and unset uppercase variable generated by find_package_handle_standard_args

if(zstd_FOUND)
set(zstd_INCLUDE_DIRS ${zstd_INCLUDE_DIR})
set(zstd_LIBRARIES ${zstd_LIBRARY})

if(NOT TARGET zstd::zstd)
add_library(zstd::zstd UNKNOWN IMPORTED)
set_property(TARGET zstd::zstd PROPERTY IMPORTED_LOCATION ${zstd_LIBRARY})
set_property(TARGET zstd::zstd PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${zstd_INCLUDE_DIR})
endif()
list(APPEND zstd_TARGETS zstd::zstd)
elseif(zstd_FIND_REQUIRED)
message(FATAL_ERROR "Unable to find zstd")
endif()
1 change: 1 addition & 0 deletions zstd_vendor/zstd_vendor-extras.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
list(INSERT CMAKE_MODULE_PATH 0 "${zstd_vendor_DIR}/Modules")

0 comments on commit ead6f74

Please sign in to comment.