CMakeLists.txt 5.19 KB
Newer Older
Thomas Moulard's avatar
Thomas Moulard committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright 2011, Thomas Moulard, Olivier Stasse, JRL, CNRS/AIST
#
# This file is part of sot-hrp2.
# sot-hrp2 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-hrp2 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-hrp2. If not, see <http://www.gnu.org/licenses/>.

INCLUDE(../cmake/python.cmake)
17 18
FINDPYTHON()
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
Thomas Moulard's avatar
Thomas Moulard committed
19 20 21 22 23 24 25 26

FUNCTION(COMPILE_PLUGIN NAME SOURCES ENTITIES)
  ADD_LIBRARY(${NAME} SHARED ${SOURCES})
  SET_TARGET_PROPERTIES(${lib} PROPERTIES
    PREFIX ""
    SOVERSION ${PROJECT_VERSION})

  PKG_CONFIG_USE_DEPENDENCY(${NAME} dynamic-graph)
27
  PKG_CONFIG_USE_DEPENDENCY(${NAME} eigen3)
Thomas Moulard's avatar
Thomas Moulard committed
28
  PKG_CONFIG_USE_DEPENDENCY(${NAME} sot-core)
29
  PKG_CONFIG_USE_DEPENDENCY(${NAME} pinocchio)
30

31
  INSTALL(TARGETS ${NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugin)
Thomas Moulard's avatar
Thomas Moulard committed
32 33 34 35 36 37

  # build python submodule
  STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${NAME})
  SET(NEW_ENTITY_CLASS ${ENTITIES})
  DYNAMIC_GRAPH_PYTHON_MODULE("sot/hrp2/${PYTHON_LIBRARY_NAME}"
    ${NAME}
38
    sot-hrp2-${PYTHON_LIBRARY_NAME}-wrap
Thomas Moulard's avatar
Thomas Moulard committed
39 40 41 42
    )
ENDFUNCTION()

# Compile plug-ins.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
#IF (HRP2_DYNAMICS_FOUND)
#  MESSAGE(STATUS "Add dynamic-hrp2_14 plugin")
#  COMPILE_PLUGIN(dynamic-hrp2_14 dynamic-hrp2_14.cc DynamicHrp2_14)
#  PKG_CONFIG_USE_DEPENDENCY(dynamic-hrp2_14 hrp2-dynamics)
#ENDIF()

#IF (HRP2_10_OPTIMIZED_FOUND)
#  MESSAGE(STATUS "Add dynamic-hrp2_10 plugin")
#  COMPILE_PLUGIN(dynamic-hrp2_10 dynamic-hrp2_10.cc DynamicHrp2_10)
#  PKG_CONFIG_USE_DEPENDENCY(dynamic-hrp2_10 hrp2-10-optimized)
#ENDIF()

#IF (HRP2_10_OPTIMIZED_FOUND)
#  CONFIG_FILES(dynamic_graph/sot/hrp2_10/robot.py)
#ENDIF()

#IF (HRP2_DYNAMICS_FOUND)
#  CONFIG_FILES(dynamic_graph/sot/hrp2_14/robot.py)
#ENDIF()
62

Thomas Moulard's avatar
Thomas Moulard committed
63 64 65 66 67 68
# Install Python files.
SET(PYTHON_MODULE_DIR
  ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/hrp2)
SET(PYTHON_MODULE_BUILD_DIR
  ${CMAKE_CURRENT_BINARY_DIR}/dynamic_graph/sot/hrp2)

69 70 71
SET(PYTHON_MODULE dynamic_graph/sot/hrp2)
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "__init__.py" )
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "hrp2.py" )
72

Thomas Moulard's avatar
Thomas Moulard committed
73
SET(FILES __init__.py robot.py)
74

Thomas Moulard's avatar
Thomas Moulard committed
75
# Install dynamic_graph.sot.hrp2_14
76 77 78 79
SET(PYTHON_MODULE dynamic_graph/sot/hrp2_14)
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "__init__.py" )
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "robot.py" "${PYTHON_SITELIB}")
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "prologue.py")
Thomas Moulard's avatar
Thomas Moulard committed
80 81

# Install dynamic_graph.sot.hrp2_10
82 83 84 85
SET(PYTHON_MODULE dynamic_graph/sot/hrp2_10)
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "__init__.py" )
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "robot.py" "${PYTHON_SITELIB}")
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "prologue.py")
86

87 88 89 90 91 92 93 94 95 96 97 98 99 100
# Add the library to wrap the device of HRP2.
MACRO(build_hrp2_device)

  SET(DEVICE_NAME sot-hrp2-device)
  ADD_LIBRARY(${DEVICE_NAME}
    SHARED
    sot-hrp2-device.cpp
  )

  # Link the dynamic library containing the SoT with its dependencies.
  PKG_CONFIG_USE_DEPENDENCY(${DEVICE_NAME} "dynamic-graph")
  PKG_CONFIG_USE_DEPENDENCY(${DEVICE_NAME} "dynamic-graph-python")
  PKG_CONFIG_USE_DEPENDENCY(${DEVICE_NAME} "sot-core")

101
  PKG_CONFIG_USE_DEPENDENCY(${DEVICE_NAME} "dynamic_graph_bridge")
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

  IF(UNIX AND NOT APPLE)
    TARGET_LINK_LIBRARIES(${DEVICE_NAME} ${Boost_LIBRARIES})
  ENDIF(UNIX AND NOT APPLE)

  INSTALL(TARGETS ${DEVICE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})

  # build python submodule
  STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${DEVICE_NAME})
  SET(NEW_ENTITY_CLASS ${ENTITIES})
  DYNAMIC_GRAPH_PYTHON_MODULE("sot/hrp2/${PYTHON_LIBRARY_NAME}"
    ${DEVICE_NAME}
    sot-hrp2-${PYTHON_LIBRARY_NAME}-wrap
    )

ENDMACRO()

build_hrp2_device()

# Add the library to wrap the controller of HRP2.
122 123
MACRO(build_hrp2_controller robotnumber)

124 125 126 127 128 129 130 131 132 133
  SET(CONTROLLER_NAME sot-hrp2-${robotnumber}-controller)
  ADD_LIBRARY(${CONTROLLER_NAME}
    SHARED
    sot-hrp2-controller.cpp
    sot-hrp2-${robotnumber}-controller.cpp
  )

  # Link the dynamic library containing the SoT with its dependencies.
  PKG_CONFIG_USE_DEPENDENCY(${CONTROLLER_NAME} "dynamic-graph")
  PKG_CONFIG_USE_DEPENDENCY(${CONTROLLER_NAME} "dynamic-graph-python")
134
  PKG_CONFIG_USE_DEPENDENCY(${CONTROLLER_NAME} "sot-core")
135

136
  PKG_CONFIG_USE_DEPENDENCY(${CONTROLLER_NAME} "dynamic_graph_bridge")
137

138 139
  ADD_DEPENDENCIES(${CONTROLLER_NAME} "sot-hrp2-device")
  TARGET_LINK_LIBRARIES(${CONTROLLER_NAME} "sot-hrp2-device")
140 141
  TARGET_LINK_LIBRARIES(${CONTROLLER_NAME} "ros_bridge")
  TARGET_LINK_LIBRARIES(${CONTROLLER_NAME} "ros_interpreter")
142 143 144 145 146
  
  IF(UNIX AND NOT APPLE)
    TARGET_LINK_LIBRARIES(${CONTROLLER_NAME} ${Boost_LIBRARIES})
  ENDIF(UNIX AND NOT APPLE)

147
  INSTALL(TARGETS ${CONTROLLER_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
148

149
ENDMACRO()
150

151 152 153 154 155 156 157
#TODO: which? 10 or 14?
build_hrp2_controller("14")
build_hrp2_controller("10")

#IF (HRP2_10_OPTIMIZED_FOUND)
#  build_hrp2_controller("10")
#ENDIF()
158

159 160 161
#IF (HRP2_DYNAMICS_FOUND)
#  build_hrp2_controller("14")
#ENDIF()
162