CMakeLists.txt 5.26 KB
Newer Older
1
# Copyright (C) 2017-2018 LAAS-CNRS
2
3
4
#
# Author: Olivier Stasse
#
Olivier Stasse's avatar
Olivier Stasse committed
5
cmake_minimum_required(VERSION 2.8.3)
6

Olivier Stasse's avatar
Olivier Stasse committed
7
8
set(CXX_DISABLE_WERROR True)

9
10
set(WARNING_CXX_FLAGS "${WARNING_CXX_FLAGS} -Werror=format-security")

Olivier Stasse's avatar
Olivier Stasse committed
11
12
13
14
15
16
17
18
19
20
21
SET(PROJECT_ORG stack-of-tasks)
set(PROJECT_DESCRIPTION "roscontrol_sot")
set(PROJECT_NAME roscontrol_sot)
set(PROJECT_URL "https://github.com/stack-of-tasks/roscontrol_sot")

# Export CMake Target
SET(PROJECT_USE_CMAKE_EXPORT TRUE)

# Disable failing compilation when a compilation error appears
set(CXX_DISABLE_WERROR False)

22
include(cmake/base.cmake)
Olivier Stasse's avatar
Olivier Stasse committed
23
24
25
26
27
28
29
30
31
32

# Specify the project.
cmake_policy(SET CMP0048 NEW)
PROJECT(${PROJECT_NAME}
  LANGUAGES
  CXX
  VERSION
  ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
  )

33
34
35
36
include(cmake/ros.cmake)
include(cmake/GNUInstallDirs.cmake)
include(cmake/python.cmake)

Olivier Stasse's avatar
Olivier Stasse committed
37
38
find_package(PkgConfig REQUIRED)

39
add_required_dependency(bullet)
40
add_required_dependency("urdfdom")
41

Olivier Stasse's avatar
Olivier Stasse committed
42
SET(CATKIN_REQUIRED_COMPONENTS
Olivier Stasse's avatar
Olivier Stasse committed
43
  temperature_sensor_controller  
44
  pal_hardware_interfaces
Olivier Stasse's avatar
Olivier Stasse committed
45
46
47
  controller_interface
  controller_manager
  pal_common_msgs
Olivier Stasse's avatar
Olivier Stasse committed
48
49
50
51
52
  roscpp
  std_msgs
  dynamic_graph_bridge
  control_msgs
  sensor_msgs
Olivier Stasse's avatar
Olivier Stasse committed
53
54
55
56
57
58
59
60
61
62
63
64
  realtime_tools  )

SET(CATKIN_DEPENDS_LIBRARIES ros_bridge sot_loader rcsot_controller)

SET(CATKIN_REQUIRED_COMPONENTS ${CATKIN_REQUIRED_COMPONENTS} rospy)
SET(CATKIN_DEPENDS_LIBRARIES ${CATKIN_DEPENDS_LIBRARIES} ros_interpreter)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  ${CATKIN_REQUIRED_COMPONENTS}
Olivier Stasse's avatar
Olivier Stasse committed
65
66
)

67
68
69
70
71
72
## LAAS cmake submodule part
set(PROJECT_DESCRIPTION "Integration of the Stack of Tasks in roscontrol")
set(PROJECT_NAME roscontrol_sot)
set(PROJECT_URL "https://github.com/stack-of-tasks/roscontrol_sot")


Olivier Stasse's avatar
Olivier Stasse committed
73
include_directories(include tests ${catkin_INCLUDE_DIRS} ${bullet_INCLUDE_DIRS})
Olivier Stasse's avatar
Olivier Stasse committed
74
75
76

link_directories(${bullet_LIBRARY_DIRS})

Olivier Stasse's avatar
Olivier Stasse committed
77
78
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")

79
80
81
82
83
84
85
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_INSTALL_RPATH "${LIBRARY_OUTPUT_PATH}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}")

# Add dependency through jrl-cmakemodules to compile
# this code without catkin_make
Olivier Stasse's avatar
Olivier Stasse committed
86
#add_project_dependency(dynamic_graph_bridge REQUIRED)
Olivier Stasse's avatar
Olivier Stasse committed
87
88
89
90
add_project_dependency(dynamic-graph REQUIRED )
add_project_dependency(dynamic-graph-python REQUIRED )
add_project_dependency(sot-core REQUIRED )
add_required_dependency("pinocchio" REQUIRED)
Olivier Stasse's avatar
Olivier Stasse committed
91

Olivier Stasse's avatar
Olivier Stasse committed
92
93
# This is necessary so that the pc file generated by catking is similar
# to the on done directly by jrl-cmake-modules
94
catkin_package(CATKIN_DEPENDS
Olivier Stasse's avatar
Olivier Stasse committed
95
96
97
  temperature_sensor_controller
  pal_hardware_interfaces
  controller_interface controller_manager  
Olivier Stasse's avatar
Olivier Stasse committed
98
99
100
101
  roscpp
  realtime_tools
  message_runtime
  dynamic_graph_bridge
Olivier Stasse's avatar
Olivier Stasse committed
102
LIBRARIES ${CATKIN_DEPENDS_LIBRARIES} )
Olivier Stasse's avatar
Olivier Stasse committed
103

104
# Detect the controller interface version to switch code
Olivier Stasse's avatar
Olivier Stasse committed
105
106
if(controller_interface_FOUND)
  if (${controller_interface_VERSION} VERSION_GREATER "0.2.5")
107
    add_definitions(-DCONTROLLER_INTERFACE_KINETIC)
Olivier Stasse's avatar
Olivier Stasse committed
108
109
  endif(${controller_interface_VERSION} VERSION_GREATER "0.2.5")
endif(controller_interface_FOUND)
110

111
112
# Detect if temperature sensor controller package is found
# if yes then it is a PARL Robotics Forked code.
Olivier Stasse's avatar
Olivier Stasse committed
113
if(temperature_sensor_controller_FOUND)
114
  add_definitions(-DTEMPERATURE_SENSOR_CONTROLLER)
Olivier Stasse's avatar
Olivier Stasse committed
115
endif(temperature_sensor_controller_FOUND)
116

Olivier Stasse's avatar
Olivier Stasse committed
117
118
119
120
121
LIST(APPEND LOGGING_WATCHED_VARIABLES
  TEMPERATURE_SENSOR_CONTROLLER_FOUND
  CONTROLLER_INTERFACE_FOUND
  CONTROLLER_INTERFACE_VERSION )
  
122

Olivier Stasse's avatar
Olivier Stasse committed
123
124
125
126
127
128
129
###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
Guilhem Saurel's avatar
Guilhem Saurel committed
130
include_directories(
Olivier Stasse's avatar
Olivier Stasse committed
131
132
133
134
  ${catkin_INCLUDE_DIRS}
  )

## Declare a C++ library
Guilhem Saurel's avatar
Guilhem Saurel committed
135
add_library(rcsot_controller
Olivier Stasse's avatar
Olivier Stasse committed
136
137
138
139
src/roscontrol-sot-controller.cpp
src/log.cpp
)

Olivier Stasse's avatar
Olivier Stasse committed
140
pkg_config_use_dependency(rcsot_controller pinocchio NO_INCLUDE_SYSTEM)
Olivier Stasse's avatar
Olivier Stasse committed
141
142
## Add cmake target dependencies of the executable
## same as for the library above
Olivier Stasse's avatar
Olivier Stasse committed
143
144
# add_dependencies(roscontrol_sot_node ${${PROJECT_NAME}_EXPORTED_TARGETS}
#     ${catkin_EXPORTED_TARGETS})
Olivier Stasse's avatar
Olivier Stasse committed
145
146
147
148
149
150
151

## Specify libraries to link a library or executable target against
target_link_libraries(rcsot_controller
  ${catkin_LIBRARIES}
  ${bullet_LIBRARIES}
  )

Olivier Stasse's avatar
Olivier Stasse committed
152
153
154
#target_link_libraries(rcsot_controller urdfdom optional
#  NO_INCLUDE_SYSTEM)
target_link_libraries(rcsot_controller dynamic-graph::dynamic-graph)
Olivier Stasse's avatar
Olivier Stasse committed
155
156

## Mark executables and/or libraries for installation
Olivier Stasse's avatar
Olivier Stasse committed
157
158
159
install(TARGETS rcsot_controller
  EXPORT ${TARGETS_EXPORT_NAME}    
  DESTINATION lib )
Olivier Stasse's avatar
Olivier Stasse committed
160

161
162
ADD_EXECUTABLE(roscontrol-sot-parse-log
  src/roscontrol-sot-parse-log.cc)
Olivier Stasse's avatar
Olivier Stasse committed
163
164
165
install(TARGETS roscontrol-sot-parse-log
  EXPORT ${TARGETS_EXPORT_NAME}    
  DESTINATION bin )
Olivier Stasse's avatar
Olivier Stasse committed
166
167
168
169
170
171
172

foreach(dir config launch)
  install(DIRECTORY ${dir}
    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  )
endforeach()

Olivier Stasse's avatar
Olivier Stasse committed
173

Olivier Stasse's avatar
Olivier Stasse committed
174
#ADD_SUBDIRECTORY(tests)
Olivier Stasse's avatar
Olivier Stasse committed
175

Olivier Stasse's avatar
Olivier Stasse committed
176
177
178
179
180
181
182
183
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
  LIST(APPEND LOGGING_WATCHED_VARIABLES
    ${_variableName}
    )
endforeach()

184
SETUP_PROJECT_FINALIZE()
Olivier Stasse's avatar
Olivier Stasse committed
185

Olivier Stasse's avatar
Olivier Stasse committed
186
187
188
189
190
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
    message(STATUS "${_variableName}=${${_variableName}}")
endforeach()