Skip to content

Commit

Permalink
changes to build under ROS2, added CI
Browse files Browse the repository at this point in the history
  • Loading branch information
berndpfrommer committed Apr 11, 2024
1 parent 15e0fd7 commit 1d828d6
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 53 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# continuous integration workflow
#
name: build repo

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
branches: [master]

jobs:
build_ros2:
uses: ros-misc-utilities/ros_build_scripts/.github/workflows/ros2_recent_ci.yml@master
with:
repo: ${{ github.event.repository.name }}
# vcs_url: https://raw.githubusercontent.com/${{ github.repository }}/master/${{ github.event.repository.name }}.repos
100 changes: 56 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,59 @@
cmake_minimum_required(VERSION 3.5)
project(apriltag_mit)
#
# Copyright 2024 Bernd Pfrommer <[email protected]>
#

set(USE_ROS TRUE)
set(CMAKE_CXX_STANDARD 11)
cmake_minimum_required(VERSION 3.16)

project(apriltag_mit VERSION 1.0.0 LANGUAGES CXX)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

set(CMAKE_CXX_CLANG_TIDY clang-tidy)

find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(include ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})

if(USE_ROS)
find_package(catkin REQUIRED COMPONENTS roslib)
catkin_package(DEPENDS
OpenCV
EIGEN3
INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME})

include_directories(${catkin_INCLUDE_DIRS})
file(GLOB CC_FILES ${PROJECT_SOURCE_DIR}/src/*.cc)
add_library(${PROJECT_NAME} SHARED ${CC_FILES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})

if(CATKIN_ENABLE_TESTING)
catkin_add_gtest(test_apriltag_mit test/test_apriltag_mit.cpp)
target_link_libraries(test_apriltag_mit ${catkin_LIBRARIES} ${PROJECT_NAME})
endif()

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
else()
message(STATUS "Source: " ${PROJECT_SOURCE_DIR})
message(STATUS "Binary: " ${PROJECT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
link_directories(${PROJECT_SOURCE_DIR}/lib)

file(GLOB CC_FILES ${PROJECT_SOURCE_DIR}/src/*.cc)
add_library(${PROJECT_NAME} SHARED ${CC_FILES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})
endif()
find_package(OpenCV REQUIRED core calib3d)

file(GLOB CC_FILES ${PROJECT_SOURCE_DIR}/src/*.cc)
add_library(${PROJECT_NAME} SHARED ${CC_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC opencv_core opencv_calib3d Eigen3::Eigen)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)

target_include_directories(
${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include
)

install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# generate the ConfigVersion.cmake file that will be included by Config.cmake
write_basic_package_version_file(
${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)

# generate the *Config.cmake file
configure_file(cmake/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY)

# generate Targets.cmake file from exports learned during the installation
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

# install the generated version and config files
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
7 changes: 7 additions & 0 deletions cmake/apriltag_mitConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(CMakeFindDependencyMacro)

find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED core)

# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/apriltag_mitTargets.cmake")
22 changes: 13 additions & 9 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<package format="2">
<?xml version="1.0"?>
<package format="3">
<name>apriltag_mit</name>
<version>0.3.0</version>
<description>A C++ Apriltag library</description>
<version>1.0.0</version>
<description>ROS2 package wrapper for the MIT apriltag detector</description>
<author>Michael Kaess</author>
<maintainer email="[email protected]">Chao Qu</maintainer>
<license>GPLv3</license>
<maintainer email="[email protected]">Bernd Pfrommer</maintainer>
<license>GPLv2</license>

<depend>opencv</depend>
<depend>eigen</depend>

<export>
<build_type>cmake</build_type>
</export>

<buildtool_depend>catkin</buildtool_depend>
<depend>roslib</depend>
<test_depend>gtest</test_depend>
<test_depend>rosunit</test_depend>
</package>

0 comments on commit 1d828d6

Please sign in to comment.