-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
156 lines (134 loc) · 4.24 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
147
148
149
150
151
152
153
154
155
156
# BSD 3-clause Copyright (c) 2021, New York University and Max Planck
# Gesellschaft
#
# set up the project
#
cmake_minimum_required(VERSION 3.10.2)
project(mim_control)
# specify the C++ 17 standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#
# Search for dependencies.
#
# Local depends
find_package(yaml_utils REQUIRED)
find_package(mpi_cmake_modules REQUIRED)
# External dependencies Extract major/minor python version
find_package(Eigen3 REQUIRED)
find_package(pinocchio REQUIRED)
find_package(eiquadprog REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
find_package(Python ${PYTHON_VERSION_STRING} REQUIRED)
# Specific search of boost python as it is yet not trivial.
search_for_boost_python()
# Optionnal
find_package(dynamic-graph QUIET)
find_package(dynamic-graph-python QUIET)
set(build_dynamic_graph_plugins FALSE)
if(${dynamic-graph_FOUND} AND ${dynamic-graph-python_FOUND})
set(build_dynamic_graph_plugins TRUE)
endif()
#
# Create the main library
#
# cmake-format: off
add_library(
${PROJECT_NAME} SHARED
src/impedance_controller.cpp
src/centroidal_pd_controller.cpp
src/centroidal_force_qp_controller.cpp
src/centroidal_impedance_controller.cpp)
# cmake-format: on
target_link_libraries(${PROJECT_NAME} pinocchio::pinocchio)
target_link_libraries(${PROJECT_NAME} Eigen3::Eigen)
target_link_libraries(${PROJECT_NAME} eiquadprog::eiquadprog)
target_link_libraries(${PROJECT_NAME} yaml_utils::yaml_utils)
# Includes. Add the include dependencies
target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
#
# Build the dynamic graph plugins if the dependencies are found.
#
if(${build_dynamic_graph_plugins})
# plugin name
set(plugin_name wbc)
# Create the library
add_library(
${plugin_name} SHARED
src/dynamic_graph/signal_utils.cpp
src/dynamic_graph/impedance_controller.cpp
src/dynamic_graph/centroidal_pd_controller.cpp
src/dynamic_graph/centroidal_force_qp_controller.cpp)
# Add the include dependencies.
target_include_directories(
${plugin_name} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${pybind11_INCLUDE_DIRS})
# Link the dependencies.
target_link_libraries(${plugin_name} ${PROJECT_NAME})
target_link_libraries(${plugin_name} dynamic-graph::dynamic-graph)
target_link_libraries(${plugin_name}
dynamic-graph-python::dynamic-graph-python)
# Install the target and it's python bindings.
install_dynamic_graph_plugin_python_bindings(${plugin_name})
# Install the plugin.
get_dynamic_graph_plugin_install_path(plugin_install_path)
install(
TARGETS ${plugin_name}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${plugin_install_path}
ARCHIVE DESTINATION ${plugin_install_path}
RUNTIME DESTINATION ${plugin_install_path}
INCLUDES
DESTINATION include)
endif()
#
# Install the package
#
# command to install the library and binaries
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES
DESTINATION include)
# we also need to install the header files
install(DIRECTORY include/ DESTINATION include)
#
# python bindings with pybind11#
#
# cmake-format: off
pybind11_add_module(${PROJECT_NAME}_cpp MODULE
srcpy/${PROJECT_NAME}.cpp
srcpy/impedance_controller.cpp
srcpy/centroidal_pd_controller.cpp
srcpy/centroidal_force_qp_controller.cpp
srcpy/centroidal_impedance_controller.cpp)
# cmake-format: on
target_link_libraries(${PROJECT_NAME}_cpp PRIVATE pybind11::module)
target_link_libraries(${PROJECT_NAME}_cpp PRIVATE ${PROJECT_NAME})
target_link_boost_python(${PROJECT_NAME}_cpp PRIVATE)
# install the bindings
get_python_install_dir(PYTHON_INSTALL_DIR)
install(TARGETS ${PROJECT_NAME}_cpp DESTINATION ${PYTHON_INSTALL_DIR})
#
# install python packages
#
# install the python package too
install(
DIRECTORY python/${PROJECT_NAME}
DESTINATION "${PYTHON_INSTALL_DIR}"
PATTERN "*.pyc" EXCLUDE
PATTERN "__pycache__" EXCLUDE)
#
# building documentation
#
add_documentation()
#
# create the cmake package
#
generate_cmake_package(INSTALL_EXPORT)