CMakeLists.txt 8.21 KB
Newer Older
Thomas Moulard's avatar
Thomas Moulard committed
1
# Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
Francois Bleibel's avatar
Francois Bleibel committed
2

3
4
5
6
7
# Verbosity level
IF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
  ADD_DEFINITIONS(-DVP_DEBUG_MODE=${CMAKE_VERBOSITY_LEVEL} -DVP_DEBUG)
ENDIF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))

8
9
10
# The main include dir
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)

11
#define DEBUG=2 if we're building in debug mode (what for?)
Francois Bleibel's avatar
Francois Bleibel committed
12
IF("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)
13
  ADD_DEFINITIONS(-DDEBUG=2)
Francois Bleibel's avatar
Francois Bleibel committed
14
ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)
15

16
IF(UNIX)
17
  ADD_DEFINITIONS(-pthread)
18
ENDIF(UNIX)
Francois Bleibel's avatar
Francois Bleibel committed
19

20
21
22
# The main library name
SET(SOTCORE_LIB_NAME ${PROJECT_NAME})

23
#This project will create many plugins as shared libraries, listed here
24
SET(plugins
25
26
27
28
29
30
  sot/sot

  math/op-point-modifier

  matrix/operator
  matrix/derivator
Joseph Mirabel's avatar
Joseph Mirabel committed
31
  matrix/double-constant
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  matrix/fir-filter
  matrix/integrator-abstract
  matrix/integrator-euler
  matrix/matrix-constant
  matrix/vector-constant
  matrix/vector-to-rotation

  task/gain-adaptive
  task/task-pd
  task/gain-hyperbolic
  task/task
  task/task-conti
  task/task-unilateral

  feature/feature-point6d
47
  feature/feature-pose
48
49
50
51
52
53
54
55
56
57
58
  feature/feature-vector3
  feature/feature-generic
  feature/feature-joint-limits
  feature/feature-1d
  feature/feature-point6d-relative
  feature/feature-visual-point
  feature/feature-task
  feature/feature-line-distance
  feature/feature-posture
  feature/visual-point-projecter

59
60
61
  filters/filter-differentiator
  filters/madgwickahrs

62
63
  traces/reader

Joseph Mirabel's avatar
Joseph Mirabel committed
64
  tools/event
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  tools/time-stamp
  tools/timer
  tools/seq-play
  tools/sequencer
  tools/robot-simu
  tools/motion-period
  tools/neck-limitation
  tools/mailbox-vector
  tools/kalman
  tools/joint-limitator
  tools/gripper-control
  tools/com-freezer
  tools/clamp-workspace
  tools/binary-int-to-uint
  tools/periodic-call-entity
  tools/joint-trajectory-entity
81
  tools/latch
Joseph Mirabel's avatar
Joseph Mirabel committed
82
  tools/switch
83
84
  tools/exp-moving-avg
  tools/gradient-ascent
85
  tools/parameter-server
86
87
88

  control/control-gr
  control/control-pd
89

90
  )
Francois Bleibel's avatar
Francois Bleibel committed
91

92
93
# TODO
IF(WIN32)
94
95
96
97
98
99
100
101
  LIST(REMOVE_ITEM plugins
    tools/mailbox-vector
    matrix/binary-op
    matrix/derivator
    matrix/fir-filter
    matrix/integrator-abstract
    matrix/integrator-euler
    )
102
ENDIF(WIN32)
103

Francois Bleibel's avatar
Francois Bleibel committed
104
set(ADDITIONAL_feature-task_LIBS feature-generic task)
105
106
set(ADDITIONAL_feature-point6d-relative_LIBS feature-point6d)

Joseph Mirabel's avatar
Joseph Mirabel committed
107
set(ADDITIONAL_sot_LIBS task)
Thomas Moulard's avatar
Thomas Moulard committed
108
109

set(ADDITIONAL_sequencer_LIBS sot)
110
111
112
113
114

set(ADDITIONAL_task-conti_LIBS task)
set(ADDITIONAL_task-pd_LIBS task)
set(ADDITIONAL_task-unilateral_LIBS task)

115
#Build sot-core
116
117
SET(LIBRARY_NAME ${SOTCORE_LIB_NAME})

118
#sot-core library sources
119
SET(${LIBRARY_NAME}_SOURCES
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  debug/debug.cpp
  debug/contiifstream.cpp

  exception/exception-abstract.cpp
  exception/exception-dynamic.cpp
  exception/exception-factory.cpp
  exception/exception-feature.cpp
  exception/exception-signal.cpp
  exception/exception-task.cpp
  exception/exception-tools.cpp

  signal/signal-cast.cpp

  feature/feature-abstract.cpp

  task/task-abstract.cpp
  task/multi-bound.cpp

  sot/flags.cpp
  sot/memory-task-sot.cpp

  factory/pool.cpp

  tools/utils-windows
  tools/periodic-call
  tools/device
  tools/trajectory
147
  tools/robot-utils
148
149

  matrix/matrix-svd
150

151
152
153
154
  filters/causal-filter

  utils/stop-watch

155
  )
156

157
ADD_LIBRARY(${LIBRARY_NAME}
Francois Bleibel's avatar
Francois Bleibel committed
158
  SHARED
159
  ${${LIBRARY_NAME}_SOURCES})
Francois Bleibel's avatar
Francois Bleibel committed
160

Olivier Stasse's avatar
Olivier Stasse committed
161
162
163
164
165
166
167
168
169
170
target_include_directories(${LIBRARY_NAME}
  PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/>
  INTERFACE
  $<INSTALL_INTERFACE:include>
)

171
172
173
174
175
IF (${SUFFIX_SO_VERSION})
  SET_TARGET_PROPERTIES(${LIBRARY_NAME}
    PROPERTIES
    SOVERSION ${PROJECT_VERSION})
ENDIF()
Francois Bleibel's avatar
Francois Bleibel committed
176

Olivier Stasse's avatar
Olivier Stasse committed
177
target_link_libraries(${LIBRARY_NAME} dynamic-graph::dynamic-graph)
Francois Bleibel's avatar
Francois Bleibel committed
178

179

Olivier Stasse's avatar
Olivier Stasse committed
180
#PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)
181
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
Olivier Stasse's avatar
Olivier Stasse committed
182
183
184
#IF(BUILD_PYTHON_INTERFACE)
#  PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph-python)
#ENDIF(BUILD_PYTHON_INTERFACE)
185

186
IF(UNIX)
187
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
188
ENDIF(UNIX)
Francois Bleibel's avatar
Francois Bleibel committed
189

190
191
192
193
IF(UNIX AND NOT APPLE)
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} pthread)
ENDIF(UNIX AND NOT APPLE)

194
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
195

196
197
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
  INSTALL(TARGETS ${LIBRARY_NAME}
Olivier Stasse's avatar
Olivier Stasse committed
198
199
200
201
202
203
    EXPORT ${TARGETS_EXPORT_NAME}
    PUBLIC_HEADER
    INCLUDES DESTINATION include
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    )
204
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
205
206

#Plugins compilation, link, and installation
207
#Compiles a plugin. The plugin library is ${LIBRARY_NAME}
208
FOREACH(plugin ${plugins})
209
210
  #retrieve plugin name
  GET_FILENAME_COMPONENT(LIBRARY_NAME ${plugin} NAME)
211

212
213
214
215
216
217
218
219
220
221
222
223
  # only one source file per plugin
  ADD_LIBRARY(${LIBRARY_NAME}
    SHARED
    ${plugin}.cpp)

  #remove the "lib" prefix from the plugin output name
  SET_TARGET_PROPERTIES(${LIBRARY_NAME}
    PROPERTIES
    PREFIX "")

  SET_TARGET_PROPERTIES(${LIBRARY_NAME}
    PROPERTIES
224
    INSTALL_RPATH ${PLUGINDIR}
225
226
227
228
229
230
231
    )
  IF (${SUFFIX_SO_VERSION})
    SET_TARGET_PROPERTIES(${LIBRARY_NAME}
      PROPERTIES
      SOVERSION ${PROJECT_VERSION}
      )
  ENDIF()
232
233
234
235

  # Link with sot-core library
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${SOTCORE_LIB_NAME})
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
Olivier Stasse's avatar
Olivier Stasse committed
236
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dynamic-graph::dynamic-graph)
237
238
239
240
241
242

  ADD_DEPENDENCIES	 (${LIBRARY_NAME} ${SOTCORE_LIB_NAME})

  IF(ADDITIONAL_${LIBRARY_NAME}_LIBS)
    ADD_DEPENDENCIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
    TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
243
244
  ENDIF(ADDITIONAL_${LIBRARY_NAME}_LIBS)

245
246
247
248
249
  # Linux dynamic loading library flags
  IF(UNIX)
    TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
  ENDIF(UNIX)

Olivier Stasse's avatar
Olivier Stasse committed
250
  #PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)
251
  PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
252
253

  # build python submodule
254
255
256
257
258
259
260
  IF(BUILD_PYTHON_INTERFACE)
    STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${LIBRARY_NAME})
    DYNAMIC_GRAPH_PYTHON_MODULE("sot/core/${PYTHON_LIBRARY_NAME}"
      ${LIBRARY_NAME}
      sot-core-${PYTHON_LIBRARY_NAME}-wrap
      )
  ENDIF(BUILD_PYTHON_INTERFACE)
261
262
263
264

  IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
    # Install plugins
    INSTALL(TARGETS ${LIBRARY_NAME}
Olivier Stasse's avatar
Olivier Stasse committed
265
266
267
      EXPORT ${TARGETS_EXPORT_NAME}
      PUBLIC_HEADER
      INCLUDES DESTINATION include
268
      LIBRARY DESTINATION ${PLUGINDIR}
Olivier Stasse's avatar
Olivier Stasse committed
269
      )
270
271
  ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
  
272
ENDFOREACH(plugin)
florent's avatar
florent committed
273

274
IF(BUILD_PYTHON_INTERFACE)
275
276
277
  SET(NO_INSTALL_OF_INIT_PY 0)
  DYNAMIC_GRAPH_PYTHON_MODULE("sot/core" ${SOTCORE_LIB_NAME} wrap
    ${NO_INSTALL_OF_INIT_PY})
278

279
  # Install empty __init__.py files in intermediate directories.
280
  
281
282
283
284
  INSTALL(FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/__init__.py
    DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot
    )
285

286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
  INSTALL(FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/__init__.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/math_small_entities.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/feature_position.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/feature_position_relative.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/matrix_util.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/meta_tasks.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/meta_task_6d.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/meta_tasks_kine.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/meta_tasks_kine_relative.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/meta_task_posture.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/meta_task_visual_point.py
    DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/core
    )
  INSTALL(FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/utils/__init__.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/utils/attime.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/utils/history.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/utils/thread_interruptible_loop.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/utils/viewer_loger.py
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/core/utils/viewer_helper.py
    DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/core/utils
    )
ENDIF(BUILD_PYTHON_INTERFACE)