Skip to content

Commit af92828

Browse files
committed
make ros2 version build with paho libs installed via apt
1 parent 9d058f1 commit af92828

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

mqtt_client/CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@ if(${ROS_VERSION} EQUAL 2)
1717

1818
find_package(mqtt_client_interfaces REQUIRED)
1919
find_package(rclcpp REQUIRED)
20-
find_package(sensor_msgs REQUIRED)
2120
find_package(std_msgs REQUIRED)
2221

23-
find_package(PahoMqttCpp REQUIRED)
24-
set(PahoMqttCpp_LIBRARIES PahoMqttCpp::paho-mqttpp3)
22+
# Paho MQTT C++ apt package doesn't include cMake config
23+
# find_package(PahoMqttCpp REQUIRED)
24+
find_library(PahoMqttC_LIBRARY libpaho-mqtt3as.so.1 REQUIRED)
25+
find_library(PahoMqttCpp_LIBRARY libpaho-mqttpp3.so.1 REQUIRED)
2526

2627
add_executable(${PROJECT_NAME} src/MqttClient.ros2.cpp)
2728

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

33+
target_link_libraries(${PROJECT_NAME}
34+
${PahoMqttC_LIBRARY}
35+
${PahoMqttCpp_LIBRARY}
36+
)
37+
3238
ament_target_dependencies(${PROJECT_NAME}
3339
mqtt_client_interfaces
34-
PahoMqttCpp
3540
rclcpp
36-
sensor_msgs
3741
std_msgs
3842
)
3943

@@ -287,4 +291,4 @@ elseif(${ROS_VERSION} EQUAL 1)
287291
## Add folders to be run by python nosetests
288292
# catkin_add_nosetests(test)
289293

290-
endif()
294+
endif()

mqtt_client/package.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
<!-- ROS2 -->
2525
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
26+
<depend condition="$ROS_VERSION == 2">libpaho-mqtt-dev</depend>
27+
<depend condition="$ROS_VERSION == 2">libpaho-mqttpp-dev</depend>
2628
<depend condition="$ROS_VERSION == 2">rclcpp</depend>
2729
<depend condition="$ROS_VERSION == 2">rcpputils</depend>
2830

@@ -39,4 +41,4 @@
3941
<nodelet condition="$ROS_VERSION == 1" plugin="${prefix}/nodelet_plugins.xml" />
4042
</export>
4143

42-
</package>
44+
</package>

0 commit comments

Comments
 (0)