Skip to content
Snippets Groups Projects
CMakeLists.txt 10.2 KiB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
#
# Copyright (c) 2015-2016 CNRS
# Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France.
Nicolas Mansard's avatar
Nicolas Mansard committed
#
# This file is part of Pinocchio
Florent Lamiraux's avatar
Florent Lamiraux committed
# pinocchio 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.
Florent Lamiraux's avatar
Florent Lamiraux committed
# pinocchio 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
Florent Lamiraux's avatar
Florent Lamiraux committed
# pinocchio If not, see
# <http://www.gnu.org/licenses/>.
Nicolas Mansard's avatar
Nicolas Mansard committed

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/eigen.cmake)
INCLUDE(cmake/python.cmake)

SET(PROJECT_NAME pinocchio)
SET(PROJECT_DESCRIPTION "Rigid multi body dynamics algorithms")
jcarpent's avatar
jcarpent committed
SET(PROJECT_URL "http://github.com/stack-of-tasks/pinocchio")
Nicolas Mansard's avatar
Nicolas Mansard committed

SET(DOXYGEN_USE_MATHJAX YES)

IF(APPLE)
  SET(CMAKE_MACOSX_RPATH TRUE)
  SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
  SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
  if("${isSystemDir}" STREQUAL "-1")
     set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  endif("${isSystemDir}" STREQUAL "-1")
ENDIF(APPLE)

# This should go to jrl-cmakemodules if accepted - Similar to ADD_DOC_DEPENDENC but with a requiered option
# This macro is for requiered components which must not appear as a dependence of the main library
MACRO(ADD_SEPARATE_DEPENDENCY PKG_CONFIG_STRING)
  SET(PKG_CONFIG_DEBUG_STRING "")
  FOREACH(ARG ${ARGN})
    SET(PKG_CONFIG_DEBUG_STRING ${ARG})
  ENDFOREACH()
  ADD_DEPENDENCY(0 1 ${PKG_CONFIG_STRING} "${PKG_CONFIG_DEBUG_STRING}")
ENDMACRO(ADD_SEPARATE_DEPENDENCY)

Nicolas Mansard's avatar
Nicolas Mansard committed
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)

SETUP_PROJECT()

IF(WIN32)
  SET(LINK copy_if_different)
ELSE(WIN32)
  SET(LINK create_symlink)
ENDIF(WIN32)

# --- OPTIONS ----------------------------------------
OPTION (BUILD_BENCHMARK "Build the benchmarks" OFF)
OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON)
OPTION (BUILD_UTILS "Build the utils" OFF)
OPTION (INITIALIZE_WITH_NAN "Initialize Eigen entries with NaN" OFF)
OPTION (BUILD_TESTS_WITH_HPP "Build geom tests and benchmarks with hpp to do comparisons" OFF)
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON)
jcarpent's avatar
jcarpent committed
  MESSAGE (STATUS "Initialize with NaN all the Eigen entries.")
  ADD_DEFINITIONS(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
ENDIF (INITIALIZE_WITH_NAN)
Nicolas Mansard's avatar
Nicolas Mansard committed
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
ADD_OPTIONAL_DEPENDENCY("metapod >= 1.0.7")
ADD_OPTIONAL_DEPENDENCY("urdfdom >= 0.2.0")
ADD_OPTIONAL_DEPENDENCY("lua5.1")
ADD_OPTIONAL_DEPENDENCY("hpp-fcl >= 0.4.2")
jcarpent's avatar
jcarpent committed
# Spetcial care of Eigen3 greater than 3.2.9
IF(EIGEN3_FOUND)
jcarpent's avatar
jcarpent committed
  IF(${EIGEN3_VERSION} VERSION_GREATER "3.2.9")
    ADD_DEFINITIONS(-DEIGEN3_FUTURE)
    SET(EIGEN3_FUTURE TRUE)
    PKG_CONFIG_APPEND_CFLAGS("-DEIGEN3_FUTURE")
jcarpent's avatar
jcarpent committed
  ELSE(${EIGEN3_VERSION} VERSION_GREATER "3.2.9")
    SET(EIGEN3_FUTURE FALSE)
  ENDIF(${EIGEN3_VERSION} VERSION_GREATER "3.2.9")
ENDIF(EIGEN3_FOUND)

# Special care of urdfdom less than 0.3.0
IF(URDFDOM_FOUND)
  IF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
    ADD_DEFINITIONS(-DURDFDOM_COLLISION_WITH_GROUP_NAME)
    SET(URDFDOM_COLLISION_WITH_GROUP_NAME TRUE)
    PKG_CONFIG_APPEND_CFLAGS("-DURDFDOM_COLLISION_WITH_GROUP_NAME")
  ENDIF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
ENDIF(URDFDOM_FOUND)

SET(BOOST_REQUIERED_COMPONENTS filesystem system)
SET(BOOST_BUILD_COMPONENTS unit_test_framework)
SET(BOOST_OPTIONAL_COMPONENTS "")

IF(BUILD_PYTHON_INTERFACE)
  SET(BOOST_OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS} python)
  FINDPYTHON(2.7 EXACT REQUIRED)
jcarpent's avatar
jcarpent committed
  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) 
ENDIF(BUILD_PYTHON_INTERFACE)

SET(BOOST_COMPONENTS ${BOOST_REQUIERED_COMPONENTS} ${BOOST_OPTIONAL_COMPONENTS} ${BOOST_BUILD_COMPONENTS})
# Variable containing all the cflags definition relative to optional dependencies
SET(CFLAGS_DEPENDENCIES)

# Path to boost headers
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})

Nicolas Mansard's avatar
Nicolas Mansard committed
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
  spatial/symmetric3.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
  spatial/se3.hpp
  spatial/motion.hpp
  spatial/force.hpp
  spatial/inertia.hpp
  spatial/fwd.hpp
  spatial/skew.hpp
  spatial/act-on-set.hpp
SET(${PROJECT_NAME}_MULTIBODY_JOINT_HEADERS
  multibody/joint/fwd.hpp
  multibody/joint/joint-base.hpp
  multibody/joint/joint-revolute.hpp
  multibody/joint/joint-revolute-unaligned.hpp
  multibody/joint/joint-revolute-unbounded.hpp
  multibody/joint/joint-spherical.hpp
  multibody/joint/joint-spherical-ZYX.hpp
  multibody/joint/joint-prismatic.hpp
  multibody/joint/joint-prismatic-unaligned.hpp
  multibody/joint/joint-planar.hpp
  multibody/joint/joint-translation.hpp
  multibody/joint/joint-free-flyer.hpp
  multibody/joint/joint-variant.hpp
  multibody/joint/joint-basic-visitors.hpp
  multibody/joint/joint-basic-visitors.hxx
  multibody/joint/joint-composite.hpp
SET(${PROJECT_NAME}_MULTIBODY_HEADERS
  multibody/fwd.hpp
  multibody/constraint.hpp
  multibody/force-set.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
  multibody/model.hpp
jcarpent's avatar
jcarpent committed
  algorithm/aba.hpp
  algorithm/aba.hxx
  algorithm/rnea.hpp
  algorithm/crba.hxx
  algorithm/finite-differences.hpp
  algorithm/finite-differences.hxx
  algorithm/jacobian.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
  algorithm/cholesky.hpp
  algorithm/cholesky.hxx
  algorithm/kinematics.hxx
  algorithm/dynamics.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
  algorithm/center-of-mass.hpp
  algorithm/energy.hpp
  algorithm/frames.hpp
  algorithm/compute-all-terms.hpp
  algorithm/copy.hpp
  algorithm/check.hpp
SET(${PROJECT_NAME}_PARSERS_HEADERS
  parsers/sample-models.hpp
  parsers/utils.hpp
  parsers/srdf.hpp
  ) 

  LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
    parsers/urdf.hpp
    parsers/urdf/utils.hpp
  ADD_DEFINITIONS(-DWITH_URDFDOM)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_URDFDOM")
LIST(APPEND ${PROJECT_NAME}_MULTIBODY_HEADERS
  multibody/fcl.hpp
  multibody/geometry.hpp
  multibody/geometry.hxx
  )
LIST(APPEND ${PROJECT_NAME}_ALGORITHM_HEADERS
  algorithm/geometry.hpp
  algorithm/geometry.hxx
  )
IF(HPP_FCL_FOUND)
  LIST(APPEND ${PROJECT_NAME}_SPATIAL_HEADERS
    spatial/fcl-pinocchio-conversions.hpp
    )

  ADD_DEFINITIONS(-DWITH_HPP_FCL)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_HPP_FCL")
IF(LUA5_1_FOUND)
  LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
    parsers/lua.hpp
    parsers/lua/lua_tables.hpp
  ADD_DEFINITIONS(-DWITH_LUA)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_LUA")
ENDIF(LUA5_1_FOUND)

SET(HEADERS
  ${${PROJECT_NAME}_MATH_HEADERS}
  ${${PROJECT_NAME}_TOOLS_HEADERS}
  ${${PROJECT_NAME}_SPATIAL_HEADERS}
  ${${PROJECT_NAME}_MULTIBODY_JOINT_HEADERS}
  ${${PROJECT_NAME}_MULTIBODY_HEADERS}
  ${${PROJECT_NAME}_PARSERS_HEADERS}
  ${${PROJECT_NAME}_ALGORITHM_HEADERS}
  exception.hpp
  assert.hpp
 )
LIST(REMOVE_DUPLICATES HEADERS)

Nicolas Mansard's avatar
Nicolas Mansard committed
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/math")
Nicolas Mansard's avatar
Nicolas Mansard committed
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/spatial")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody/joint")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/parsers/lua")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/parsers")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/parsers/urdf")
Nicolas Mansard's avatar
Nicolas Mansard committed
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/tools")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/algorithm")
Nicolas Mansard's avatar
Nicolas Mansard committed

FOREACH(header ${HEADERS})
Nicolas Mansard's avatar
Nicolas Mansard committed
  GET_FILENAME_COMPONENT(headerName ${header} NAME)
  GET_FILENAME_COMPONENT(headerPath ${header} PATH)
  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E ${LINK}
    ${${PROJECT_NAME}_SOURCE_DIR}/src/${header}
    ${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/${header})
  INSTALL(FILES ${${PROJECT_NAME}_SOURCE_DIR}/src/${header}
    DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/${headerPath}
Nicolas Mansard's avatar
Nicolas Mansard committed
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
ENDFOREACH(header)

# --- MAIN LIBRARY -------------------------------------------------------------

# --- BINDINGS -----------------------------------------------------------------
SET(PYWRAP ${PROJECT_NAME}_pywrap)
ADD_SUBDIRECTORY(bindings)

# --- EXECUTABLES --------------------------------------------------------------
ADD_SUBDIRECTORY(utils)

# --- UNIT TESTS ---------------------------------------------------------------

# --- BENCHMARKS ---------------------------------------------------------------
ADD_SUBDIRECTORY(benchmark)
# --- PACKAGING ----------------------------------------------------------------
PKG_CONFIG_APPEND_LIBS (${PROJECT_NAME})
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_REQUIERED_COMPONENTS})
FOREACH(cflags ${CFLAGS_DEPENDENCIES})
  PKG_CONFIG_APPEND_CFLAGS(${cflags})
ENDFOREACH(cflags ${CFLAGS_DEPENDENCIES})

Nicolas Mansard's avatar
Nicolas Mansard committed
SETUP_PROJECT_FINALIZE()