CMakeLists.txt 4.63 KB
Newer Older
andreadelprete's avatar
andreadelprete committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright 2014, Andrea Del Prete, LAAS/CNRS
#
# This file is part of sot-torque-control.
# sot-torque-control is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# sot-torque-control is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Lesser Public License for more details.  You should have
# received a copy of the GNU Lesser General Public License along with
# sot-torque-control. If not, see <http://www.gnu.org/licenses/>.

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

# The main include dir
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
23
24
25
IF(BUILD_PYTHON_INTERFACE)
  LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})
ENDIF(BUILD_PYTHON_INTERFACE)
andreadelprete's avatar
andreadelprete committed
26
27
28
29
30
31
32
33
34
35
36
37

#define DEBUG=2 if we're building in debug mode (what for?)
IF("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)
  ADD_DEFINITIONS(-DDEBUG=2)
ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)

IF(UNIX)
  ADD_DEFINITIONS(-pthread)
ENDIF(UNIX)

#This project will create many plugins as shared libraries, listed here
SET(plugins
Olivier Stasse's avatar
Olivier Stasse committed
38
  admittance-controller  
39
  base-estimator
Olivier Stasse's avatar
Olivier Stasse committed
40
41
42
43
44
45
  control-manager
  current-controller
  device-torque-ctrl  
  free-flyer-locator
  imu_offset_compensation  
  inverse-dynamics-balance-controller
Olivier Stasse's avatar
Olivier Stasse committed
46
  joint-torque-controller
andreadelprete's avatar
andreadelprete committed
47
  joint-trajectory-generator
Olivier Stasse's avatar
Olivier Stasse committed
48
49
  numerical-difference  
  position-controller  
50
  se3-trajectory-generator
51
  torque-offset-estimator
52
  trace-player
andreadelprete's avatar
andreadelprete committed
53
54
  )

55
56
57
IF(DDP_ACTUATOR_SOLVER_FOUND)
  SET(plugins ${plugins} ddp-actuator-solver )
ENDIF(DDP_ACTUATOR_SOLVER_FOUND)
andreadelprete's avatar
andreadelprete committed
58
59
60
61

#Plugins compilation, link, and installation
#Compiles a plugin. The plugin library is ${LIBRARY_NAME}
FOREACH(plugin ${plugins})
62
63
64

  message( " Build plugin ${plugin}")
  
andreadelprete's avatar
andreadelprete committed
65
66
  #retrieve plugin name
  GET_FILENAME_COMPONENT(LIBRARY_NAME ${plugin} NAME)
67

andreadelprete's avatar
andreadelprete committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  # 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
    SOVERSION ${PROJECT_VERSION}
    INSTALL_RPATH ${DYNAMIC_GRAPH_PLUGINDIR})

  # Link with sot-torque-control library
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${SOTTORQUECONTROL_LIB_NAME})
  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})

  ADD_DEPENDENCIES(${LIBRARY_NAME} ${SOTTORQUECONTROL_LIB_NAME})

  IF(ADDITIONAL_${LIBRARY_NAME}_LIBS)
    ADD_DEPENDENCIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
    TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
92
93
  ENDIF(ADDITIONAL_${LIBRARY_NAME}_LIBS)

andreadelprete's avatar
andreadelprete committed
94
95
96
97
98
99
100
101
102
103
104
  # Linux dynamic loading library flags
  IF(UNIX)
    TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
  ENDIF(UNIX)

  IF(UNIX AND NOT APPLE)
    TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dl pthread)
  ENDIF(UNIX AND NOT APPLE)

  PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)
  PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} sot-core)
105
  PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
andreadelprete's avatar
andreadelprete committed
106

107
  IF(DDP_ACTUATOR_SOLVER_FOUND)
108
109
110
111
    SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/find-external/qpOASES")
    FIND_PACKAGE("qpOASES" REQUIRED)
    INCLUDE_DIRECTORIES(SYSTEM ${qpOASES_INCLUDE_DIRS})
    TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${qpOASES_LIBRARIES})
112
113
114
    PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} ddp-actuator-solver )
  ENDIF(DDP_ACTUATOR_SOLVER_FOUND)

andreadelprete's avatar
andreadelprete committed
115
116
  # build python submodule
  # (replace minus with underscore to make Python happy)
117
118
119
120
121
122
123
  IF(BUILD_PYTHON_INTERFACE)
    STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${LIBRARY_NAME})
    DYNAMIC_GRAPH_PYTHON_MODULE("sot/torque_control/${PYTHON_LIBRARY_NAME}"
      ${LIBRARY_NAME}
      sot-torque-control-${PYTHON_LIBRARY_NAME}-wrap
      )
  ENDIF(BUILD_PYTHON_INTERFACE)
124
125
126
127
128
  IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
    # Install plugins
    INSTALL(TARGETS ${LIBRARY_NAME}
      DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR})
  ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
andreadelprete's avatar
andreadelprete committed
129
130
131
ENDFOREACH(plugin)

# Bindings Python
132
133
IF(BUILD_PYTHON_INTERFACE)
  DYNAMIC_GRAPH_PYTHON_MODULE("sot/torque_control" ${SOTTORQUECONTROL_LIB_NAME} wrap)
andreadelprete's avatar
andreadelprete committed
134

135
136
137
138
139
140
  # Install empty __init__.py files in intermediate directories.
  INSTALL(FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/torque_control/__init__.py
    DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/torque_control
  )
ENDIF(BUILD_PYTHON_INTERFACE)