-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
201 lines (174 loc) · 4.7 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Copyright 2022 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.16)
# INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
# Default to GLVND if available.
set(CMAKE_POLICY_DEFAULT_CMP0072 NEW)
# This line has to appear before 'PROJECT' in order to be able to disable incremental linking
set(MSVC_INCREMENTAL_DEFAULT ON)
project(
mujoco_mpc
VERSION 0.1.0
DESCRIPTION "MuJoCo predictive control"
HOMEPAGE_URL "https://github.com/google-deepmind/mujoco_mpc"
)
enable_language(C)
enable_language(CXX)
if(APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
endif()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(MpcOptions)
include(MujocoMacOS)
option(MJPC_BUILD_TESTS "Build tests for MJPC" ON)
option(MJPC_GRPC_BUILD_TESTS "Build tests for gRPC" ON)
option(MJPC_BUILD_GRPC_SERVICE "Build MJPC gRPC service." OFF)
option(PYMJPC_BUILD_TESTS "Build tests for Python bindings" ON)
include(FindOrFetch)
find_package(Python)
find_package(Threads REQUIRED)
set(MUJOCO_BUILD_EXAMPLES OFF)
set(MUJOCO_BUILD_SIMULATE ON)
set(MUJOCO_BUILD_TESTS OFF)
set(MUJOCO_TEST_PYTHON_UTIL OFF)
set(MUJOCO_MPC_MUJOCO_GIT_TAG
a1b6026b8c29efd10fe0fb67bd5213541ccb1362
CACHE STRING "Git revision for MuJoCo."
)
findorfetch(
USE_SYSTEM_PACKAGE
OFF
PACKAGE_NAME
mujoco
LIBRARY_NAME
mujoco
GIT_REPO
https://github.com/google-deepmind/mujoco.git
GIT_TAG
${MUJOCO_MPC_MUJOCO_GIT_TAG}
TARGETS
mujoco::mujoco
mujoco::platform_ui_adapter
EXCLUDE_FROM_ALL
)
set(MUJOCO_DEP_VERSION_abseil
c8a2f92586fe9b4e1aff049108f5db8064924d8e # LTS 20230125.1
CACHE STRING "Version of `abseil` to be fetched."
)
set(MUJOCO_DEP_VERSION_glfw3
7482de6071d21db77a7236155da44c172a7f6c9e # 3.3.8
CACHE STRING "Version of `glfw` to be fetched."
)
set(MJPC_DEP_VERSION_lodepng
b4ed2cd7ecf61d29076169b49199371456d4f90b
CACHE STRING "Version of `lodepng` to be fetched."
)
set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS
OFF
CACHE INTERNAL "Build SHARED libraries"
)
findorfetch(
USE_SYSTEM_PACKAGE
OFF
PACKAGE_NAME
GTest
LIBRARY_NAME
googletest
GIT_REPO
https://github.com/google/googletest.git
GIT_TAG
${MUJOCO_DEP_VERSION_gtest}
TARGETS
gtest
gmock
gtest_main
EXCLUDE_FROM_ALL
)
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_BUILD_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
OFF
PACKAGE_NAME
absl
LIBRARY_NAME
abseil-cpp
GIT_REPO
https://github.com/abseil/abseil-cpp.git
GIT_TAG
${MUJOCO_DEP_VERSION_abseil}
TARGETS
absl::core_headers
EXCLUDE_FROM_ALL
)
set(GLFW_BUILD_EXAMPLES OFF)
set(GLFW_BUILD_TESTS OFF)
set(GLFW_BUILD_DOCS OFF)
set(GLFW_INSTALL OFF)
findorfetch(
USE_SYSTEM_PACKAGE
MJPC_USE_SYSTEM_GLFW
PACKAGE_NAME
glfw
LIBRARY_NAME
glfw
GIT_REPO
https://github.com/glfw/glfw.git
GIT_TAG
${MUJOCO_DEP_VERSION_glfw3}
TARGETS
glfw
EXCLUDE_FROM_ALL
)
set(BUILD_SHARED_LIBS
${BUILD_SHARED_LIBS_OLD}
CACHE BOOL "Build SHARED libraries" FORCE
)
unset(BUILD_SHARED_LIBS_OLD)
FetchContent_Declare(
menagerie
GIT_REPOSITORY https://github.com/google-deepmind/mujoco_menagerie.git
GIT_TAG main
)
FetchContent_GetProperties(menagerie)
if(NOT menagerie_POPULATED)
FetchContent_Populate(menagerie)
endif()
if(NOT TARGET lodepng)
FetchContent_Declare(
lodepng
GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
GIT_TAG ${MJPC_DEP_VERSION_lodepng}
)
FetchContent_GetProperties(lodepng)
if(NOT lodepng_POPULATED)
FetchContent_Populate(lodepng)
# This is not a CMake project.
set(LODEPNG_SRCS ${lodepng_SOURCE_DIR}/lodepng.cpp)
set(LODEPNG_HEADERS ${lodepng_SOURCE_DIR}/lodepng.h)
add_library(lodepng STATIC ${LODEPNG_HEADERS} ${LODEPNG_SRCS})
target_compile_options(lodepng PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
target_link_options(lodepng PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
target_include_directories(lodepng PUBLIC ${lodepng_SOURCE_DIR})
endif()
endif()
set(MJPC_COMPILE_OPTIONS "${AVX_COMPILE_OPTIONS}" "${EXTRA_COMPILE_OPTIONS}")
set(MJPC_LINK_OPTIONS "${EXTRA_LINK_OPTIONS}")
add_subdirectory(mjpc)
if(MJPC_BUILD_GRPC_SERVICE)
add_subdirectory(grpc)
endif()