-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathCMakeLists.txt
165 lines (153 loc) · 4.71 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
157
158
159
160
161
162
163
164
165
# Copyright 2020 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5)
project(dmr_controllers_py
DESCRIPTION "DM Robotics: Controllers (Python)"
VERSION 0.1
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Variables.
set(DMR_PYTHON_VERSION "3.10" CACHE STRING "Python version.")
set(PYTHONVERSION ${DMR_PYTHON_VERSION})
set(PYBIND11_PYTHON_VERSION ${PYTHONVERSION} CACHE STRING "")
set(PYBIND11_PYTHON_VERSION ${PYTHONVERSION})
add_definitions(-DPYBIND11_PYTHON_VERSION="${PYTHONVERSION}")
add_definitions(-DDM_ROBOTICS_USE_NEW_MUJOCO_BINDINGS=1)
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Release")
endif()
set(BUILD_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
endif()
if((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
set(PROJECT_WARNING_FLAGS_DEBUG "")
set(PROJECT_WARNING_FLAGS_RELEASE "")
list(APPEND PROJECT_WARNING_FLAGS_DEBUG -Wall)
list(APPEND PROJECT_WARNING_FLAGS_DEBUG -Wextra)
list(APPEND PROJECT_WARNING_FLAGS_DEBUG -Woverloaded-virtual)
list(APPEND PROJECT_WARNING_FLAGS_DEBUG -pedantic)
# For now use the same properties.
set(PROJECT_WARNING_FLAGS_RELEASE ${PROJECT_WARNING_FLAGS_DEBUG})
endif()
# Options.
option(DMR_CONTROLLERS_PY_USE_SYSTEM_absl
"If ON, it will attempt to find `absl` as a system dependency. If OFF, it will fetch `absl` from the git repo if not found."
OFF
)
option(DMR_CONTROLLERS_PY_USE_SYSTEM_pybind11
"If ON, it will attempt to find `pybind11` as a system dependency. If OFF, it will fetch `pybind11` from the git repo if not found."
OFF
)
# Absl
FindOrFetch(
USE_SYSTEM_PACKAGE
DMR_CONTROLLERS_USE_SYSTEM_absl
PACKAGE_NAME
absl
LIBRARY_NAME
abseil-cpp
GIT_REPO
https://github.com/abseil/abseil-cpp.git
GIT_TAG
lts_2021_11_02
TARGETS
absl::span
absl::hash
absl::btree
absl::flat_hash_map
absl::hashtablez_sampler
absl::strings
absl::status
)
# Pybind11
FindOrFetch(
USE_SYSTEM_PACKAGE
DMR_CONTROLLERS_USE_SYSTEM_pybind11
PACKAGE_NAME
pybind11
LIBRARY_NAME
pybind11
GIT_REPO
https://github.com/pybind/pybind11.git
GIT_TAG
v2.9.2
TARGETS
pybind11::headers
)
# Python Bindings
set(SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cartesian_6d_to_joint_velocity_mapper.cc
${CMAKE_CURRENT_SOURCE_DIR}/cartesian_6d_to_joint_velocity_mapper_python_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/cartesian_6d_to_joint_velocity_mapper_python_helpers.cc
${CMAKE_CURRENT_SOURCE_DIR}/joint_velocity_filter.cc
${CMAKE_CURRENT_SOURCE_DIR}/joint_velocity_filter_python_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/joint_velocity_filter_python_helpers.cc
${CMAKE_CURRENT_SOURCE_DIR}/pybind_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/pybind_utils.cc
)
# Cartesian 6d mapper
pybind11_add_module(cartesian_6d_to_joint_velocity_mapper_pybind
${SRCS}
)
set_target_properties(cartesian_6d_to_joint_velocity_mapper_pybind
PROPERTIES
OUTPUT_NAME "cartesian_6d_to_joint_velocity_mapper"
)
target_include_directories(cartesian_6d_to_joint_velocity_mapper_pybind
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_link_libraries(cartesian_6d_to_joint_velocity_mapper_pybind
PRIVATE
absl::span
absl::hash
absl::btree
absl::flat_hash_map
absl::hashtablez_sampler
absl::strings
absl::status
dmr_mujoco
dmr_lsqp_core
dmr_controllers_lsqp
)
# Joint velocity mapper
pybind11_add_module(joint_velocity_filter_pybind
${SRCS}
)
set_target_properties(joint_velocity_filter_pybind
PROPERTIES
OUTPUT_NAME "joint_velocity_filter"
)
target_include_directories(joint_velocity_filter_pybind
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_link_libraries(joint_velocity_filter_pybind
PRIVATE
absl::span
absl::hash
absl::btree
absl::flat_hash_map
absl::hashtablez_sampler
absl::strings
absl::status
dmr_mujoco
dmr_lsqp_core
dmr_controllers_lsqp
)