Skip to content

Commit 33131ac

Browse files
committed
add package and cmakelists
1 parent 094b165 commit 33131ac

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(common_interfaces_cpp)
3+
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
7+
8+
# Define a list of dependencies for easy modularity and future additions
9+
set(ros2_dependencies
10+
rclcpp
11+
nav_msgs
12+
)
13+
14+
# Find ament_cmake (required for the build system itself)
15+
find_package(ament_cmake REQUIRED)
16+
17+
# Loop through the list to find all specified packages automatically
18+
foreach(dependency IN LISTS ros2_dependencies)
19+
find_package(${dependency} REQUIRED)
20+
endforeach()
21+
22+
# Create the shared library from the source files
23+
add_library(${PROJECT_NAME} SHARED
24+
src/odometry.cpp
25+
)
26+
27+
# Specify the include directories so the compiler finds the .hpp files
28+
target_include_directories(${PROJECT_NAME} PUBLIC
29+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
30+
$<INSTALL_INTERFACE:include>
31+
)
32+
33+
# Link all listed dependencies to the library
34+
ament_target_dependencies(${PROJECT_NAME} ${ros2_dependencies})
35+
36+
# Install the include directory so other packages can do #include
37+
install(DIRECTORY include/
38+
DESTINATION include
39+
)
40+
41+
# Install the library and export the target for downstream usage
42+
install(TARGETS ${PROJECT_NAME}
43+
EXPORT ${PROJECT_NAME}
44+
ARCHIVE DESTINATION lib
45+
LIBRARY DESTINATION lib
46+
RUNTIME DESTINATION bin
47+
)
48+
49+
# Export include directories, targets, and dependencies
50+
ament_export_include_directories(include)
51+
ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET)
52+
ament_export_dependencies(${ros2_dependencies})
53+
54+
ament_package()

common_interfaces_cpp/package.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>common_interfaces_cpp</name>
5+
<version>0.0.0</version>
6+
<description>C++ shared library providing ROS 2 interfaces for Odometry.</description>
7+
<maintainer email="dummy@dummy.com">dummy</maintainer>
8+
<license>Apache License 2.0</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<depend>rclcpp</depend>
13+
<depend>nav_msgs</depend>
14+
15+
<export>
16+
<build_type>ament_cmake</build_type>
17+
</export>
18+
</package>

0 commit comments

Comments
 (0)