Skip to content

Commit 94bc5c7

Browse files
committed
[CMake] Fix optionnal dep temperature_sensor_controller
1 parent d438243 commit 94bc5c7

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

CMakeLists.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ SEARCH_FOR_BOOST_PYTHON()
3434
add_required_dependency(bullet)
3535
add_required_dependency(urdfdom)
3636

37-
SET(CATKIN_REQUIRED_COMPONENTS
38-
temperature_sensor_controller
37+
find_package(catkin REQUIRED COMPONENTS
3938
pal_hardware_interfaces
4039
controller_interface
4140
controller_manager
@@ -47,8 +46,7 @@ SET(CATKIN_REQUIRED_COMPONENTS
4746
realtime_tools
4847
rospy
4948
)
50-
51-
find_package(catkin REQUIRED COMPONENTS ${CATKIN_REQUIRED_COMPONENTS})
49+
find_package(temperature_sensor_controller)
5250

5351
ADD_PROJECT_DEPENDENCY(dynamic-graph-python 4.0.0 REQUIRED)
5452
ADD_PROJECT_DEPENDENCY(dynamic_graph_bridge REQUIRED)
@@ -65,19 +63,26 @@ endif(controller_interface_FOUND)
6563

6664
# Detect if temperature sensor controller package is found
6765
# if yes then it is a PAL Robotics Forked code.
68-
if(temperature_sensor_controller_FOUND)
69-
add_definitions(-DTEMPERATURE_SENSOR_CONTROLLER)
70-
endif(temperature_sensor_controller_FOUND)
7166

7267
add_library(rcsot_controller
7368
src/roscontrol-sot-controller.cpp
7469
src/log.cpp
7570
)
76-
TARGET_INCLUDE_DIRECTORIES(rcsot_controller SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
77-
TARGET_INCLUDE_DIRECTORIES(rcsot_controller PUBLIC $<INSTALL_INTERFACE:include>)
78-
TARGET_LINK_LIBRARIES(rcsot_controller ${catkin_LIBRARIES} ${bullet_LIBRARIES}
79-
sot-core::sot-core dynamic_graph_bridge::sot_loader
71+
target_include_directories(rcsot_controller SYSTEM PUBLIC
72+
${catkin_INCLUDE_DIRS}
73+
$<INSTALL_INTERFACE:include>)
74+
target_link_libraries(rcsot_controller
75+
${catkin_LIBRARIES}
76+
${bullet_LIBRARIES}
77+
sot-core::sot-core
78+
dynamic_graph_bridge::sot_loader
8079
${control_toolbox_LIBRARIES})
80+
if (temperature_sensor_controller_FOUND)
81+
target_compile_definitions(rcsot_controller PUBLIC TEMPERATURE_SENSOR_CONTROLLER)
82+
message("temperature_sensor_controller_LIBRARIES: ${temperature_sensor_controller_LIBRARIES}")
83+
target_include_directories(rcsot_controller SYSTEM PUBLIC ${temperature_sensor_controller_INCLUDE_DIRS})
84+
target_link_libraries(rcsot_controller ${temperature_sensor_controller_LIBRARIES})
85+
endif()
8186

8287
IF(SUFFIX_SO_VERSION)
8388
SET_TARGET_PROPERTIES(rcsot_controller PROPERTIES SOVERSION ${PROJECT_VERSION})

0 commit comments

Comments
 (0)