-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
250 lines (201 loc) · 7.68 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
###################################################################################
# MIT License #
# #
# Copyright (c) 2024 Lucas Maggi #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
###################################################################################
################################################
## CMAKE REQUIREMENTS ##
################################################
cmake_minimum_required(VERSION 3.17)
################################################
## PROJECT INFO ##
################################################
project(
mujoco_man
VERSION 0.0.0
DESCRIPTION "MuJoCo Motion Antecipation example"
)
################################################
## PROJECT FLAGS ##
################################################
set(MUJOCO_MAN_USE_HARDWARE_ENCODING OFF)
# set(CMAKE_BUILD_TYPE Debug)
################################################
## PROJECT FLAGS LOGIC ##
################################################
# Here is the logic: Use CUDA and FFMPEG for video encoding
# If hardware encoding is set to ON
if (MUJOCO_MAN_USE_HARDWARE_ENCODING)
set(MUJOCO_MAN_USE_CUDA ON)
set(MUJOCO_MAN_USE_FFMPEG ON)
set(MUJOCO_MAN_USE_OPENCV OFF)
add_compile_definitions(USE_CUDA)
add_compile_definitions(USE_FFMPEG)
# Here is the logic: Use OpenCV for video encoding
# If hardware encoding is set to OFF
else()
set(MUJOCO_MAN_USE_CUDA OFF)
set(MUJOCO_MAN_USE_FFMPEG OFF)
set(MUJOCO_MAN_USE_OPENCV ON)
add_compile_definitions(USE_OPENCV)
endif()
################################################
## INCLUDE FETCH CONTENT ##
################################################
include(FetchContent)
################################################
## SPECIAL CXX COMPILATION FLAGS ##
################################################
## Compile as C++11 only in C++ compilation context
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -pthread -O3 -D__STDC_CONSTANT_MACROS -mavx"
)
################################################
## OpenGL ##
################################################
find_package(OpenGL REQUIRED)
################################################
## OpenCV ##
################################################
# NOTE: OpenCV is just being used for video encoding
# In the context of SOFTWARE video encoding.
if (MUJOCO_MAN_USE_OPENCV)
find_package( OpenCV REQUIRED )
endif()
################################################
## FFMPEG ##
################################################
# NOTE: FFMPEG is just being used for video encoding
# In the context of HARDWARE video encoding.
if (MUJOCO_MAN_USE_FFMPEG)
include(FindPkgConfig)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
libavdevice
libavfilter
libavformat
libavcodec
libswresample
libswscale
libavutil
)
endif()
################################################
## GLFW ##
################################################
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.3.8
)
FetchContent_GetProperties(glfw)
if(NOT glfw_POPULATED)
FetchContent_Populate(glfw)
set(glfw_BUILD_SHARED_LIBS ON)
add_subdirectory(
${glfw_SOURCE_DIR} ${glfw_BINARY_DIR}
)
endif()
################################################
## IMGUI ##
################################################
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.90
)
FetchContent_GetProperties(imgui)
if(NOT imgui_POPULATED)
FetchContent_Populate(imgui)
include_directories(${imgui_SOURCE_DIR})
set(imgui_SOURCES
${imgui_SOURCE_DIR}/imconfig.h
${imgui_SOURCE_DIR}/imgui_demo.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.h
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.h
${imgui_SOURCE_DIR}/imgui_internal.h
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui.h
${imgui_SOURCE_DIR}/imstb_rectpack.h
${imgui_SOURCE_DIR}/imstb_textedit.h
${imgui_SOURCE_DIR}/imstb_truetype.h
)
endif()
################################################
## MUJOCO ##
################################################
set(mujoco_BUILD_TESTING OFF)
FetchContent_Declare(
mujoco
GIT_REPOSITORY https://github.com/google-deepmind/mujoco.git
GIT_TAG 3.1.1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
# OVERRIDE_FIND_PACKAGE # 3.24 needed to work with find_package
# find_package(mujoco) 3.24 needed to work with FetchContent
# set(FETCHCONTENT_QUIET OFF)
FetchContent_GetProperties(mujoco)
if(NOT mujoco_POPULATED)
FetchContent_Populate(mujoco)
add_subdirectory(
${mujoco_SOURCE_DIR} ${mujoco_BINARY_DIR}
EXCLUDE_FROM_ALL
)
endif()
################################################
## INCLUDES ##
################################################
include_directories(
include
${mujoco_SOURCE_DIR}/include
${glfw_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
)
################################################
## EXECUTABLES ##
################################################
add_executable(
mujoco_man
src/basic.cpp
)
################################################
## LINKING ##
################################################
if (MUJOCO_MAN_USE_HARDWARE_ENCODING)
if (MUJOCO_MAN_USE_FFMPEG)
target_link_libraries(mujoco_man PkgConfig::LIBAV)
endif()
else()
target_link_libraries(
mujoco_man
PUBLIC
mujoco
OpenGL
glfw
${OpenCV_LIBS}
)
endif()