Skip to content

Commit

Permalink
Merge pull request #4 from ICube-Robotics/add_basic_gtests
Browse files Browse the repository at this point in the history
* Build test against libs from build dir

* fix libusb-dev setup

* Update README.md
  • Loading branch information
tpoignonec authored Sep 13, 2023
2 parents f5d01b6 + 902a2a7 commit d559181
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM ros:${ROS_DISTRO}

COPY . /ros2_dev/src/fd_sdk_vendor
RUN apt update && apt upgrade -y
RUN apt install -y libusb-1.0-0-dev
RUN apt install -y python3-pip
RUN apt install -y git tree clang-format-14 cppcheck
RUN pip install pre-commit
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED libusb-1.0)

find_package(ament_cmake REQUIRED)
include(FetchContent)

Expand Down Expand Up @@ -59,7 +62,7 @@ target_link_libraries(
${PROJECT_NAME} INTERFACE
${CMAKE_INSTALL_PREFIX}/lib/libdhd.so.${VERSION_SDK_MAJOR}
${CMAKE_INSTALL_PREFIX}/lib/libdrd.so.${VERSION_SDK_MAJOR}
usb-1.0
${libusb-1.0_LIBRARIES}
)

# Testing
Expand All @@ -71,6 +74,25 @@ if(BUILD_TESTING)
set(ament_cmake_cpplint_FOUND TRUE)

ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(
test_dhd
test/test_dhd.cpp
test/test_drd.cpp
)
target_include_directories(
test_dhd
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${fd_sdk_binaries_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(test_dhd
${dhd_LIBS}
${drd_LIBS}
${libusb-1.0_LIBRARIES}
)
endif()

# Install
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# fd_sdk_vendor
ROS 2 vendor package for Force Dimension SDK (version 3.16.0).

Author: Thibault Poignonec ([email protected])
***Tested with a Humble ROS distribution only (Ubuntu 22.04 LTS)***

[![CI](https://github.com/ICube-Robotics/fd_sdk_vendor/actions/workflows/ci.yml/badge.svg)](https://github.com/ICube-Robotics/fd_sdk_vendor/actions/workflows/ci.yml)

Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_test</buildtool_depend>
<buildtool_depend>pkg-config</buildtool_depend>

<test_depend>ament_cmake_copyright</test_depend>
<test_depend>ament_cmake_lint_cmake</test_depend>
Expand Down

0 comments on commit d559181

Please sign in to comment.