Skip to content

Commit

Permalink
update cmake and package files (#22)
Browse files Browse the repository at this point in the history
* update CmakeLists and package.xml for server.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* update CmakeLists and package.xml for client.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* add dependent packages to build check scripts.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* add if statement to process yaml-cpp differently in CMake.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

---------

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
fujitatomoya committed Apr 30, 2024
1 parent 5a9959b commit 0f0e64e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 46 deletions.
1 change: 1 addition & 0 deletions scripts/build-verification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function install_prerequisites () {
echo "[${FUNCNAME[0]}]: update and install dependent packages."
apt update && apt upgrade -y
apt install -y ros-${ROS_DISTRO}-desktop ros-${ROS_DISTRO}-rmw-cyclonedds-cpp --no-install-recommends
apt install -y libyaml-cpp-dev libboost-program-options-dev libboost-filesystem-dev
cd $there
}

Expand Down
56 changes: 46 additions & 10 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,71 @@
cmake_minimum_required(VERSION 3.5)
project(parameter_server VERSION 1.0.0)
project(parameter_server VERSION 1.0.1)

# Default to C++14
# Set Release build if no build type was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type for the build. Possible values are: Debug, Release, RelWithDebInfo, MinSizeRel"
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif()

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

# Enable additional warnings and warnings as errors
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)

find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rcutils)
find_package(rcutils REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rmw REQUIRED)

find_package(Boost REQUIRED COMPONENTS program_options filesystem)
find_package(yaml_cpp_vendor REQUIRED)

include_directories(include)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${yaml_cpp_vendor_INCLUDE_DIRS})

add_executable(server
src/parameter_server.cpp
src/main.cpp
)
ament_target_dependencies(server rclcpp rclcpp_components std_msgs)
target_link_libraries(server ${Boost_LIBRARIES} ${yaml_cpp_vendor_LIBRARIES})

# yaml-cpp updates CMake thing significantly on v0.8.0 or later.
# so we ended up having the if statement to process differently instead of creating branches.
# see https://github.com/jbeder/yaml-cpp/releases/tag/0.8.0
find_package(yaml-cpp 0.8.0 QUIET)
if (yaml-cpp_FOUND)
message(STATUS "yaml-cpp package is greater equal than version 0.8.0")
target_link_libraries(server
rclcpp::rclcpp
rcutils::rcutils
${Boost_LIBRARIES}
yaml-cpp::yaml-cpp
)
else()
message(STATUS "yaml-cpp package is less than version 0.8.0")
find_package(yaml-cpp REQUIRED)
target_link_libraries(server
rclcpp::rclcpp
rcutils::rcutils
${Boost_LIBRARIES}
yaml-cpp
)
endif()

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

ament_target_dependencies(server rclcpp rclcpp_components std_msgs rcutils)

install(TARGETS server DESTINATION lib/${PROJECT_NAME})

Expand Down
23 changes: 8 additions & 15 deletions server/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>parameter_server</name>
<version>1.0.0</version>
<version>1.0.1</version>
<description>
ros2 parameter server that other nodes can write/read parameters including persistent parameters.
</description>
Expand All @@ -12,22 +12,15 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>rclcpp</build_depend>
<build_depend>rclcpp_components</build_depend>
<build_depend>rcutils</build_depend>
<build_depend>rmw</build_depend>
<build_depend>rmw_implementation_cmake</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>yaml_cpp_vendor</build_depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>rcutils</depend>
<depend>rmw</depend>
<depend>rmw_implementation_cmake</depend>
<depend>std_msgs</depend>
<depend>yaml_cpp_vendor</depend>

<exec_depend>launch_ros</exec_depend>
<exec_depend>rclcpp</exec_depend> <exec_depend>yaml_cpp_vendor</exec_depend>

<exec_depend>rclcpp_components</exec_depend>
<exec_depend>rcutils</exec_depend>
<exec_depend>rmw</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>yaml_cpp_vendor</exec_depend>

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
35 changes: 28 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
cmake_minimum_required(VERSION 3.5)
project(ros2_persistent_parameter_server_test)
project(ros2_persistent_parameter_server_test VERSION 1.0.1)

# Set Release build if no build type was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type for the build. Possible values are: Debug, Release, RelWithDebInfo, MinSizeRel"
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif()

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

# Enable additional warnings and warnings as errors
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp_components REQUIRED)

find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rcutils REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rmw REQUIRED)

include_directories(include)

add_executable(client
src/test.cpp
src/persist_parameter_client.cpp
)

ament_target_dependencies(client rclcpp rclcpp_components)
target_link_libraries(client
rclcpp::rclcpp
rcutils::rcutils
)

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

ament_target_dependencies(client rclcpp rclcpp_components std_msgs rcutils)

install(TARGETS client DESTINATION lib/${PROJECT_NAME})

Expand Down
27 changes: 13 additions & 14 deletions test/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros2_persistent_parameter_server_test</name>
<version>1.0.0</version>
<description>Client test demo for persistent parameter server</description>
<maintainer email="Bingtao.Du@sony.com">dbt</maintainer>
<version>1.0.1</version>
<description>
Client test demo for persistent parameter server
</description>
<maintainer email="Tomoya.Fujita@sony.com">dbt</maintainer>
<license>Apache License 2.0</license>
<author email="Tomoya.Fujita@sony.com">Tomoya Fujita></author>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>rclcpp_components</build_depend>
<build_depend>rcutils</build_depend>
<build_depend>rmw</build_depend>
<build_depend>rmw_implementation_cmake</build_depend>
<build_depend>std_msgs</build_depend>

<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>rcutils</depend>
<depend>rmw</depend>
<depend>rmw_implementation_cmake</depend>
<depend>std_msgs</depend>

<exec_depend>launch_ros</exec_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>rclcpp_components</exec_depend>
<exec_depend>rcutils</exec_depend>
<exec_depend>rmw</exec_depend>
<exec_depend>std_msgs</exec_depend>

<test_depend>launch</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down

0 comments on commit 0f0e64e

Please sign in to comment.