Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to build as an ament package #817

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions cpp/foxglove-websocket/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
cmake_minimum_required(VERSION 3.15)
project(FoxgloveWebSocket CXX)

find_package(ament_cmake QUIET)
set(COMPILING_FOR_ROS2 OFF)
if(${ament_cmake_FOUND})
set(COMPILING_FOR_ROS2 ON)
message(STATUS "Compiling for ROS2")
endif()

find_package(nlohmann_json REQUIRED)
find_package(websocketpp REQUIRED)

add_library(foxglove_websocket src/base64.cpp src/parameter.cpp src/serialization.cpp src/server_factory.cpp)
target_include_directories(foxglove_websocket
PUBLIC include
SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${nlohmann_json_INCLUDE_DIRS}
${websocketpp_INCLUDE_DIRS}
)
Expand All @@ -21,6 +29,24 @@ else()
endif()

install(TARGETS foxglove_websocket)
INSTALL (DIRECTORY ${CMAKE_SOURCE_DIR}/include/
install(
TARGETS foxglove_websocket
EXPORT FoxgloveWebSocketTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
INSTALL (DIRECTORY include/
DESTINATION include)
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses/)

if(COMPILING_FOR_ROS2)
ament_target_dependencies(foxglove_websocket nlohmann_json websocketpp)

ament_export_targets(FoxgloveWebSocketTargets HAS_LIBRARY_TARGET)
ament_export_dependencies(nlohmann_json websocketpp)
ament_export_include_directories(include)
ament_export_libraries(foxglove_websocket)
ament_package()
endif()
18 changes: 18 additions & 0 deletions cpp/foxglove-websocket/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>FoxgloveWebSocket</name>
<version>1.3.0</version>
<description>Websocket protocol librory for use with foxglove studio</description>
<maintainer email="[email protected]">maintainer_name</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>libwebsocketpp-dev</depend>
<depend>zlib</depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>