CMakeLists.txt 3.84 KB
Newer Older
Olivier Stasse's avatar
Olivier Stasse committed
1
2
# Copyright 2010, 2019 JRL, CNRS/AIST, LAAS CNRS
# See LICENSE file.
Francois Bleibel's avatar
Francois Bleibel committed
3

Guilhem Saurel's avatar
Guilhem Saurel committed
4
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
Francois Bleibel's avatar
Francois Bleibel committed
5

Olivier Stasse's avatar
Olivier Stasse committed
6
7
8
9
10
SET(PROJECT_ORG stack-of-tasks)
SET(PROJECT_NAME sot-core)
SET(PROJECT_DESCRIPTION "Hierarchical task solver plug-in for dynamic-graph.")
SET(PROJECT_URL "http://github.com/${PROJECT_ORG}/${PROJECT_NAME}")

Guilhem Saurel's avatar
Guilhem Saurel committed
11
12
OPTION(BUILD_PYTHON_INTERFACE "Build the python binding" ON)
OPTION(INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python binding" OFF)
13
14
15
16
OPTION(SUFFIX_SO_VERSION
  "Suffix shared library name by a string depending on git status of project"
  ON)

Guilhem Saurel's avatar
Guilhem Saurel committed
17
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
18
19
  # Export CMake Target
  SET(PROJECT_USE_CMAKE_EXPORT TRUE)
20
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
Olivier Stasse's avatar
Olivier Stasse committed
21

22
23
24
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)

Thomas Moulard's avatar
Thomas Moulard committed
25
INCLUDE(cmake/base.cmake)
Guilhem Saurel's avatar
Guilhem Saurel committed
26
27
INCLUDE(cmake/python.cmake)
INCLUDE(cmake/boost.cmake)
Francois Bleibel's avatar
Francois Bleibel committed
28

Olivier Stasse's avatar
Olivier Stasse committed
29
# Specify the project.
30
31
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
Francois Bleibel's avatar
Francois Bleibel committed
32

33
34
SET(BOOST_COMPONENTS filesystem system thread program_options unit_test_framework)

35
36
37
38
39
40
41
IF(BUILD_PYTHON_INTERFACE)
  FINDPYTHON()
  STRING(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
  SET(${PY_NAME}_INSTALL_DIR ${PYTHON_SITELIB}/${PY_NAME})
  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
  SET(PYTHON_INSTALL_DIR
    ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/dynamic_graph/sot/core)
Guilhem Saurel's avatar
Guilhem Saurel committed
42
  ADD_PROJECT_DEPENDENCY(dynamic-graph-python 3.0.0 REQUIRED PKG_CONFIG_REQUIRES "dynamic-graph-python >= 3.0.0")
43
  SET(BOOST_COMPONENTS ${BOOST_COMPONENTS} python)
44
45
ENDIF(BUILD_PYTHON_INTERFACE)

46
SEARCH_FOR_BOOST()
Guilhem Saurel's avatar
Guilhem Saurel committed
47
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES eigen3)
Guilhem Saurel's avatar
Guilhem Saurel committed
48

Olivier Stasse's avatar
Olivier Stasse committed
49
SET(DOXYGEN_USE_MATHJAX YES)
Francois Bleibel's avatar
Francois Bleibel committed
50

Thomas Moulard's avatar
Thomas Moulard committed
51
52
53
54
55
SET(PKG_CONFIG_ADDITIONAL_VARIABLES
  ${PKG_CONFIG_ADDITIONAL_VARIABLES}
  plugindirname
  plugindir
  )
Francois Bleibel's avatar
Francois Bleibel committed
56

57
58
59
60
61
# Specific to PKG module
# FIXME: to be changed into lib/dynamic-graph
# to avoid name collision when installing dynamic-graph in /usr.
SET(PLUGINDIR "${CMAKE_INSTALL_FULL_LIBDIR}/plugin")

Guilhem Saurel's avatar
Guilhem Saurel committed
62
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
63
64
65
  # Extra macros for sot-core
  install(FILES "src/sot-coreMacros.cmake"
    DESTINATION "${CONFIG_INSTALL_DIR}")
Guilhem Saurel's avatar
Guilhem Saurel committed
66
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
Olivier Stasse's avatar
Olivier Stasse committed
67
68
69

set(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}
include(\"\${CMAKE_CURRENT_LIST_DIR}/sot-coreMacros.cmake\")")
Francois Bleibel's avatar
Francois Bleibel committed
70

71
72
PKG_CONFIG_APPEND_LIBS("sot-core")

Thomas Moulard's avatar
Thomas Moulard committed
73
# Search for dependencies.
Francois Bleibel's avatar
Francois Bleibel committed
74
# Boost
Olivier Stasse's avatar
Olivier Stasse committed
75
76
77
SET(BOOST_COMPONENTS
  thread filesystem program_options
  unit_test_framework system regex )
Francois Bleibel's avatar
Francois Bleibel committed
78

Guilhem Saurel's avatar
Guilhem Saurel committed
79
80
ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED PKG_CONFIG_REQUIRES dynamic-graph)
ADD_PROJECT_DEPENDENCY(pinocchio 2.3.1 REQUIRED PKG_CONFIG_REQUIRES "pinocchio >= 2.3.1")
81
82

SEARCH_FOR_BOOST()
Francois Bleibel's avatar
Francois Bleibel committed
83
84

ADD_SUBDIRECTORY(include)
Thomas Moulard's avatar
Thomas Moulard committed
85
86
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(unitTesting)
87
#ADD_SUBDIRECTORY(doc)
Francois Bleibel's avatar
Francois Bleibel committed
88

89
90
91
92
# **********************************
# Robot_utils_sot_py PYTHON module *
# **********************************
IF(BUILD_PYTHON_INTERFACE)
93
  IF(NOT CMAKE_VERSION VERSION_LESS "3.12" AND NOT WIN32)
94
    Python_add_library(robot_utils_sot_py MODULE src/tools/robot-utils-py.cpp)
95
  ELSE(NOT CMAKE_VERSION VERSION_LESS "3.12" AND NOT WIN32)
96
97
    PYTHON_ADD_MODULE(robot_utils_sot_py src/tools/robot-utils-py.cpp)
  ENDIF()
Olivier Stasse's avatar
Olivier Stasse committed
98
99
100
  TARGET_LINK_LIBRARIES(robot_utils_sot_py
    ${Boost_LIBRARIES}
    ${PYTHON_LIBRARIES} ${LIBRARY_NAME}
Guilhem Saurel's avatar
Guilhem Saurel committed
101
102
103
104
    dynamic-graph::dynamic-graph
    pinocchio::pinocchio
    )
  TARGET_INCLUDE_DIRECTORIES(robot_utils_sot_py PUBLIC pinocchio::pinocchio)
105
106
107
108
  TARGET_LINK_BOOST_PYTHON(robot_utils_sot_py)
  INSTALL(TARGETS robot_utils_sot_py DESTINATION ${PYTHON_INSTALL_DIR})
ENDIF(BUILD_PYTHON_INTERFACE)

109
110
# We do not want the project to be finalized if this is
# to install only the  python interface.
Guilhem Saurel's avatar
Guilhem Saurel committed
111
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
Olivier Stasse's avatar
Olivier Stasse committed
112
  SETUP_PROJECT_PACKAGE_FINALIZE()
113
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
Olivier Stasse's avatar
Olivier Stasse committed
114
115

get_cmake_property(_variableNames VARIABLES)
Guilhem Saurel's avatar
Guilhem Saurel committed
116
117
list(SORT _variableNames)
foreach(_variableName ${_variableNames})
Olivier Stasse's avatar
Olivier Stasse committed
118
119
    message(STATUS "${_variableName}=${${_variableName}}")
endforeach()