File: cmake.patch

package info (click to toggle)
mujoco 2.2.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 39,800 kB
  • sloc: ansic: 28,947; cpp: 28,897; cs: 14,241; python: 10,465; xml: 5,104; sh: 93; makefile: 34
file content (354 lines) | stat: -rw-r--r-- 10,082 bytes parent folder | download | duplicates (2)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
Description: patching upstream cmake to avoid downloading any source from
 through network, and force use system libraries for all dependencies.
Author: Mo Zhou <lumin@debian.org>
Forwarded: Not needed.
Index: mujoco/cmake/MujocoDependencies.cmake
===================================================================
--- mujoco.orig/cmake/MujocoDependencies.cmake
+++ mujoco/cmake/MujocoDependencies.cmake
@@ -79,119 +79,15 @@ set(BUILD_SHARED_LIBS
     CACHE INTERNAL "Build SHARED libraries"
 )
 
-if(NOT TARGET lodepng)
-  FetchContent_Declare(
-    lodepng
-    GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
-    GIT_TAG ${MUJOCO_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()
-
-# TODO(fraromano) We fetch qhull before the other libraries as it needs to go before until https://github.com/qhull/qhull/pull/111 is merged.
-set(QHULL_ENABLE_TESTING OFF)
-# We need Git to apply the patch using git apply.
-find_package(Git REQUIRED)
-
-findorfetch(
-  USE_SYSTEM_PACKAGE
-  OFF
-  PACKAGE_NAME
-  qhull
-  LIBRARY_NAME
-  qhull
-  GIT_REPO
-  https://github.com/qhull/qhull.git
-  GIT_TAG
-  ${MUJOCO_DEP_VERSION_qhull}
-  TARGETS
-  qhull
-  # TODO(fraromano) Remove when https://github.com/qhull/qhull/pull/112 is merged.
-  # Do not fail if patch fails. This will happen the second time we run CMake as the sources will be already patched.
-  PATCH_COMMAND
-  "${GIT_EXECUTABLE}"
-  "apply"
-  "-q"
-  "${PROJECT_SOURCE_DIR}/cmake/qhull_fix_testing.patch"
-  "||"
-  "${CMAKE_COMMAND}"
-  "-E"
-  "true"
-  EXCLUDE_FROM_ALL
-)
-# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
-# Add it to the target.
-target_include_directories(
-  qhullstatic_r INTERFACE $<BUILD_INTERFACE:${qhull_SOURCE_DIR}/src/libqhull_r>
-)
-target_compile_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
-
-set(tinyxml2_BUILD_TESTING OFF)
-findorfetch(
-  USE_SYSTEM_PACKAGE
-  OFF
-  PACKAGE_NAME
-  tinyxml2
-  LIBRARY_NAME
-  tinyxml2
-  GIT_REPO
-  https://github.com/leethomason/tinyxml2.git
-  GIT_TAG
-  ${MUJOCO_DEP_VERSION_tinyxml2}
-  TARGETS
-  tinyxml2
-  EXCLUDE_FROM_ALL
-)
-target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
-
-findorfetch(
-  USE_SYSTEM_PACKAGE
-  OFF
-  PACKAGE_NAME
-  tinyobjloader
-  LIBRARY_NAME
-  tinyobjloader
-  GIT_REPO
-  https://github.com/tinyobjloader/tinyobjloader.git
-  GIT_TAG
-  ${MUJOCO_DEP_VERSION_tinyobjloader}
-  TARGETS
-  tinyobjloader
-  EXCLUDE_FROM_ALL
-)
-
-set(ENABLE_DOUBLE_PRECISION ON)
-set(CCD_HIDE_ALL_SYMBOLS ON)
-findorfetch(
-  USE_SYSTEM_PACKAGE
-  OFF
-  PACKAGE_NAME
-  ccd
-  LIBRARY_NAME
-  ccd
-  GIT_REPO
-  https://github.com/danfis/libccd.git
-  GIT_TAG
-  ${MUJOCO_DEP_VERSION_ccd}
-  TARGETS
-  ccd
-  EXCLUDE_FROM_ALL
-)
-target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+execute_process(COMMAND dpkg-architecture -q DEB_HOST_MULTIARCH OUTPUT_VARIABLE MULTIARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
+add_library(lodepng SHARED IMPORTED)
+find_library(LODEPNG_LIBRARY lodepng HINTS /usr/lib/${MULTIARCH}/)
+set_property(TARGET lodepng PROPERTY IMPORTED_LOCATION "${LODEPNG_LIBRARY}")
+message(${LODEPNG_LIBRARY})
+find_package(Qhull REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
+find_package(tinyxml2 REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
+find_package(tinyobjloader REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
+find_package(ccd REQUIRED HINTS /usr/lib/${MULTIARCH})
 
 # libCCD has an unconditional `#define _CRT_SECURE_NO_WARNINGS` on Windows.
 # TODO(stunya): Remove this after https://github.com/danfis/libccd/pull/77 is merged.
@@ -214,85 +110,16 @@ if(MUJOCO_BUILD_TESTS)
       CACHE INTERNAL "Build tests."
   )
 
-  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
-  )
+  find_package(absl REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
 
   set(BUILD_TESTING
       ${BUILD_TESTING_OLD}
       CACHE BOOL "Build tests." FORCE
   )
 
-  # Avoid linking errors on Windows by dynamically linking to the C runtime.
-  set(gtest_force_shared_crt
-      ON
-      CACHE BOOL "" FORCE
-  )
-
-  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(BENCHMARK_EXTRA_FETCH_ARGS "")
-  if(WIN32 AND NOT MSVC)
-    set(BENCHMARK_EXTRA_FETCH_ARGS
-        PATCH_COMMAND
-        "sed"
-        "-i"
-        "-e"
-        "s/-std=c++11/-std=c++14/g"
-        "-e"
-        "s/HAVE_CXX_FLAG_STD_CXX11/HAVE_CXX_FLAG_STD_CXX14/g"
-        "${CMAKE_BINARY_DIR}/_deps/benchmark-src/CMakeLists.txt"
-    )
-  endif()
+  find_package(GTest REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
+  find_package(benchmark REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
 
-  set(BENCHMARK_ENABLE_TESTING OFF)
-
-  findorfetch(
-    USE_SYSTEM_PACKAGE
-    OFF
-    PACKAGE_NAME
-    benchmark
-    LIBRARY_NAME
-    benchmark
-    GIT_REPO
-    https://github.com/google/benchmark.git
-    GIT_TAG
-    ${MUJOCO_DEP_VERSION_benchmark}
-    TARGETS
-    benchmark::benchmark
-    benchmark::benchmark_main
-    ${BENCHMARK_EXTRA_FETCH_ARGS}
-    EXCLUDE_FROM_ALL
-  )
 endif()
 
 if(MUJOCO_TEST_PYTHON_UTIL)
@@ -301,22 +128,7 @@ if(MUJOCO_TEST_PYTHON_UTIL)
     # Support new IN_LIST if() operator.
     set(CMAKE_POLICY_DEFAULT_CMP0057 NEW)
 
-    FetchContent_Declare(
-      Eigen3
-      GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
-      GIT_TAG ${MUJOCO_DEP_VERSION_Eigen3}
-    )
-
-    FetchContent_GetProperties(Eigen3)
-    if(NOT Eigen3_POPULATED)
-      FetchContent_Populate(Eigen3)
-
-      # Mark the library as IMPORTED as a workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/15415
-      add_library(Eigen3::Eigen INTERFACE IMPORTED)
-      set_target_properties(
-        Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${eigen3_SOURCE_DIR}"
-      )
-    endif()
+    find_package(Eigen3 REQUIRED)
   endif()
 endif()
 
Index: mujoco/sample/cmake/SampleDependencies.cmake
===================================================================
--- mujoco.orig/sample/cmake/SampleDependencies.cmake
+++ mujoco/sample/cmake/SampleDependencies.cmake
@@ -69,26 +69,7 @@ if(MUJOCO_EXTRAS_STATIC_GLFW)
   )
 endif()
 
-set(GLFW_BUILD_EXAMPLES OFF)
-set(GLFW_BUILD_TESTS OFF)
-set(GLFW_BUILD_DOCS OFF)
-set(GLFW_INSTALL OFF)
-
-findorfetch(
-  USE_SYSTEM_PACKAGE
-  MUJOCO_SAMPLES_USE_SYSTEM_GLFW
-  PACKAGE_NAME
-  glfw
-  LIBRARY_NAME
-  glfw
-  GIT_REPO
-  https://github.com/glfw/glfw.git
-  GIT_TAG
-  ${MUJOCO_DEP_VERSION_glfw}
-  TARGETS
-  glfw
-  EXCLUDE_FROM_ALL
-)
+find_package(glfw3 REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
 
 if(MUJOCO_EXTRAS_STATIC_GLFW)
   set(BUILD_SHARED_LIBS
Index: mujoco/sample/CMakeLists.txt
===================================================================
--- mujoco.orig/sample/CMakeLists.txt
+++ mujoco/sample/CMakeLists.txt
@@ -168,19 +168,4 @@ if(_INSTALL_SAMPLES)
     PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT samples
   )
 
-  if(NOT MUJOCO_SAMPLES_USE_SYSTEM_GLFW)
-    # We downloaded GLFW. Depending if it is a static or shared LIBRARY we might
-    # need to install it.
-    get_target_property(MJ_GLFW_LIBRARY_TYPE glfw TYPE)
-    if(MJ_GLFW_LIBRARY_TYPE STREQUAL SHARED_LIBRARY)
-      install(
-        TARGETS glfw
-        EXPORT ${PROJECT_NAME}
-        RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT samples
-        LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT samples
-        ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT samples
-        PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT samples
-      )
-    endif()
-  endif()
 endif()
Index: mujoco/CMakeLists.txt
===================================================================
--- mujoco.orig/CMakeLists.txt
+++ mujoco/CMakeLists.txt
@@ -69,6 +69,7 @@ target_include_directories(
   mujoco
   PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
          $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>
+         /usr/include/libqhull_r/
   PRIVATE src
 )
 
@@ -101,7 +102,7 @@ target_link_libraries(
   mujoco
   PRIVATE ccd
           lodepng
-          qhullstatic_r
+          qhull_r
           tinyobjloader
           tinyxml2
 )
Index: mujoco/simulate/cmake/SimulateDependencies.cmake
===================================================================
--- mujoco.orig/simulate/cmake/SimulateDependencies.cmake
+++ mujoco/simulate/cmake/SimulateDependencies.cmake
@@ -74,21 +74,7 @@ set(GLFW_BUILD_TESTS OFF)
 set(GLFW_BUILD_DOCS OFF)
 set(GLFW_INSTALL OFF)
 
-findorfetch(
-  USE_SYSTEM_PACKAGE
-  MUJOCO_SIMULATE_USE_SYSTEM_GLFW
-  PACKAGE_NAME
-  glfw
-  LIBRARY_NAME
-  glfw
-  GIT_REPO
-  https://github.com/glfw/glfw.git
-  GIT_TAG
-  ${MUJOCO_DEP_VERSION_glfw}
-  TARGETS
-  glfw
-  EXCLUDE_FROM_ALL
-)
+find_package(glfw3 REQUIRED HINTS /usr/lib/${MULTIARCH}/cmake)
 
 if(MUJOCO_EXTRAS_STATIC_GLFW)
   set(BUILD_SHARED_LIBS