biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / science / robotics / mujoco / mujoco-system-deps-dont-fetch.patch
blobc09787ff84c5e6ab87ffa6765adeed2ba983460b
1 diff --git a/CMakeLists.txt b/CMakeLists.txt
2 index eea180c0..efb39178 100644
3 --- a/CMakeLists.txt
4 +++ b/CMakeLists.txt
5 @@ -93,7 +93,7 @@ add_subdirectory(src/render)
6 add_subdirectory(src/thread)
7 add_subdirectory(src/ui)
9 -target_compile_definitions(mujoco PRIVATE _GNU_SOURCE CCD_STATIC_DEFINE MUJOCO_DLL_EXPORTS -DMC_IMPLEM_ENABLE)
10 +target_compile_definitions(mujoco PRIVATE _GNU_SOURCE MUJOCO_DLL_EXPORTS -DMC_IMPLEM_ENABLE)
11 if(MUJOCO_ENABLE_AVX_INTRINSICS)
12 target_compile_definitions(mujoco PUBLIC mjUSEPLATFORMSIMD)
13 endif()
14 @@ -118,7 +118,7 @@ target_link_libraries(
15 lodepng
16 qhullstatic_r
17 tinyobjloader
18 - tinyxml2
19 + tinyxml2::tinyxml2
22 set_target_properties(
23 diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake
24 index 44962272..656beeb8 100644
25 --- a/cmake/MujocoDependencies.cmake
26 +++ b/cmake/MujocoDependencies.cmake
27 @@ -93,28 +93,36 @@ set(BUILD_SHARED_LIBS
28 if(NOT TARGET lodepng)
29 FetchContent_Declare(
30 lodepng
31 - GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
32 - GIT_TAG ${MUJOCO_DEP_VERSION_lodepng}
34 +endif()
36 - FetchContent_GetProperties(lodepng)
37 - if(NOT lodepng_POPULATED)
38 - FetchContent_Populate(lodepng)
39 - # This is not a CMake project.
40 - set(LODEPNG_SRCS ${lodepng_SOURCE_DIR}/lodepng.cpp)
41 - set(LODEPNG_HEADERS ${lodepng_SOURCE_DIR}/lodepng.h)
42 - add_library(lodepng STATIC ${LODEPNG_HEADERS} ${LODEPNG_SRCS})
43 - target_compile_options(lodepng PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
44 - target_link_options(lodepng PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
45 - target_include_directories(lodepng PUBLIC ${lodepng_SOURCE_DIR})
46 +if(NOT TARGET lodepng)
47 + if(NOT MUJOCO_USE_SYSTEM_lodepng)
48 + fetchcontent_declare(
49 + lodepng
50 + GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
51 + GIT_TAG ${MUJOCO_DEP_VERSION_lodepng}
52 + )
54 + FetchContent_GetProperties(lodepng)
55 + if(NOT lodepng_POPULATED)
56 + FetchContent_Populate(lodepng)
57 + # This is not a CMake project.
58 + set(LODEPNG_SRCS ${lodepng_SOURCE_DIR}/lodepng.cpp)
59 + set(LODEPNG_HEADERS ${lodepng_SOURCE_DIR}/lodepng.h)
60 + add_library(lodepng STATIC ${LODEPNG_HEADERS} ${LODEPNG_SRCS})
61 + target_compile_options(lodepng PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
62 + target_link_options(lodepng PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
63 + target_include_directories(lodepng PUBLIC ${lodepng_SOURCE_DIR})
64 + endif()
65 + else()
66 + find_package(lodepng REQUIRED)
67 endif()
68 endif()
70 if(NOT TARGET marchingcubecpp)
71 FetchContent_Declare(
72 marchingcubecpp
73 - GIT_REPOSITORY https://github.com/aparis69/MarchingCubeCpp.git
74 - GIT_TAG ${MUJOCO_DEP_VERSION_MarchingCubeCpp}
77 FetchContent_GetProperties(marchingcubecpp)
78 @@ -124,119 +132,158 @@ if(NOT TARGET marchingcubecpp)
79 endif()
80 endif()
82 +option(MUJOCO_USE_SYSTEM_qhull "Use installed qhull version." OFF)
83 +mark_as_advanced(MUJOCO_USE_SYSTEM_qhull)
85 set(QHULL_ENABLE_TESTING OFF)
87 findorfetch(
88 USE_SYSTEM_PACKAGE
89 - OFF
90 + ${MUJOCO_USE_SYSTEM_qhull}
91 PACKAGE_NAME
92 - qhull
93 + Qhull
94 LIBRARY_NAME
95 qhull
96 - GIT_REPO
97 - https://github.com/qhull/qhull.git
98 - GIT_TAG
99 - ${MUJOCO_DEP_VERSION_qhull}
100 TARGETS
101 qhull
102 EXCLUDE_FROM_ALL
104 -# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
105 -# Add it to the target.
106 -target_include_directories(
107 - qhullstatic_r INTERFACE $<BUILD_INTERFACE:${qhull_SOURCE_DIR}/src/libqhull_r>
109 -target_compile_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
110 -target_link_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
111 +if(NOT MUJOCO_USE_SYSTEM_qhull)
112 + # MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
113 + # Add it to the target.
114 + target_include_directories(
115 + qhullstatic_r INTERFACE $<BUILD_INTERFACE:${qhull_SOURCE_DIR}/src/libqhull_r>
117 + target_compile_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
118 + target_link_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
119 +else()
120 + if(NOT TARGET qhullstatic_r)
121 + add_library(qhullstatic_r INTERFACE)
122 + set_target_properties(qhullstatic_r PROPERTIES INTERFACE_LINK_LIBRARIES Qhull::qhull_r)
124 + # Workaround as headers are installed in <prefix>/include/libqhull_r/something.h
125 + # but mujoco include them as #include <something.h>
126 + get_property(qhull_include_dirs TARGET Qhull::qhull_r PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
127 + foreach(qhull_include_dir IN LISTS qhull_include_dirs)
128 + target_include_directories(qhullstatic_r INTERFACE ${qhull_include_dirs}/libqhull_r)
129 + endforeach()
130 + target_include_directories(qhullstatic_r INTERFACE )
131 + endif()
132 +endif()
134 +option(MUJOCO_USE_SYSTEM_tinyxml2 "Use installed tinyxml2 version." OFF)
135 +mark_as_advanced(MUJOCO_USE_SYSTEM_tinyxml2)
137 set(tinyxml2_BUILD_TESTING OFF)
138 findorfetch(
139 USE_SYSTEM_PACKAGE
140 - OFF
141 + ${MUJOCO_USE_SYSTEM_tinyxml2}
142 PACKAGE_NAME
143 tinyxml2
144 LIBRARY_NAME
145 tinyxml2
146 - GIT_REPO
147 - https://github.com/leethomason/tinyxml2.git
148 - GIT_TAG
149 - ${MUJOCO_DEP_VERSION_tinyxml2}
150 TARGETS
151 - tinyxml2
152 + tinyxml2::tinyxml2
153 EXCLUDE_FROM_ALL
155 -target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
156 -target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
157 +if(NOT MUJOCO_USE_SYSTEM_tinyxml2)
158 + target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
159 + target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
160 +endif()
162 +option(MUJOCO_USE_SYSTEM_tinyobjloader "Use installed tinyobjloader version." OFF)
163 +mark_as_advanced(MUJOCO_USE_SYSTEM_tinyobjloader)
165 findorfetch(
166 USE_SYSTEM_PACKAGE
167 - OFF
168 + ${MUJOCO_USE_SYSTEM_tinyobjloader}
169 PACKAGE_NAME
170 tinyobjloader
171 LIBRARY_NAME
172 tinyobjloader
173 - GIT_REPO
174 - https://github.com/tinyobjloader/tinyobjloader.git
175 - GIT_TAG
176 - ${MUJOCO_DEP_VERSION_tinyobjloader}
177 TARGETS
178 tinyobjloader
179 EXCLUDE_FROM_ALL
182 +if(MUJOCO_USE_SYSTEM_tinyobjloader)
183 + # As of tinyobjloader v2.0.0rc10, the tinyobjloader target is named tinyobjloader in the build,
184 + # but tinyobjloader::tinyobjloader when it is installed. To deal with this, if tinyobjloader is
185 + # found in the system, we create an ALIAS
186 + # The following is equivalent to add_library(tinyobjloader ALIAS tinyobjloader::tinyobjloader),
187 + # but compatible with CMake 3.16 . Once the minimum CMake is bumped to CMake 3.18, we can use
188 + # the simpler version
189 + add_library(tinyobjloader INTERFACE IMPORTED)
190 + set_target_properties(tinyobjloader PROPERTIES INTERFACE_LINK_LIBRARIES tinyobjloader::tinyobjloader)
191 +endif()
193 +option(MUJOCO_USE_SYSTEM_sdflib "Use installed sdflib version." OFF)
194 +mark_as_advanced(MUJOCO_USE_SYSTEM_sdflib)
196 option(SDFLIB_USE_ASSIMP OFF)
197 option(SDFLIB_USE_OPENMP OFF)
198 option(SDFLIB_USE_ENOKI OFF)
200 findorfetch(
201 USE_SYSTEM_PACKAGE
202 - OFF
203 + ${MUJOCO_USE_SYSTEM_sdflib}
204 PACKAGE_NAME
205 - sdflib
206 + SdfLib
207 LIBRARY_NAME
208 sdflib
209 - GIT_REPO
210 - https://github.com/UPC-ViRVIG/SdfLib.git
211 - GIT_TAG
212 - ${MUJOCO_DEP_VERSION_sdflib}
213 TARGETS
214 - SdfLib
215 + SdfLib::SdfLib
216 EXCLUDE_FROM_ALL
218 -target_compile_options(SdfLib PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
219 -target_link_options(SdfLib PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
221 +if(NOT MUJOCO_USE_SYSTEM_sdflib)
222 + target_compile_options(SdfLib PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
223 + target_link_options(SdfLib PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
224 +endif()
226 +option(MUJOCO_USE_SYSTEM_ccd "Use installed ccd version." OFF)
227 +mark_as_advanced(MUJOCO_USE_SYSTEM_ccd)
229 set(ENABLE_DOUBLE_PRECISION ON)
230 set(CCD_HIDE_ALL_SYMBOLS ON)
231 findorfetch(
232 USE_SYSTEM_PACKAGE
233 - OFF
234 + ${MUJOCO_USE_SYSTEM_ccd}
235 PACKAGE_NAME
237 LIBRARY_NAME
239 - GIT_REPO
240 - https://github.com/danfis/libccd.git
241 - GIT_TAG
242 - ${MUJOCO_DEP_VERSION_ccd}
243 TARGETS
245 EXCLUDE_FROM_ALL
247 -target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
248 -target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
250 -# libCCD has an unconditional `#define _CRT_SECURE_NO_WARNINGS` on Windows.
251 -# TODO(stunya): Remove this after https://github.com/danfis/libccd/pull/77 is merged.
252 -if(WIN32)
253 - if(MSVC)
254 - # C4005 is the MSVC equivalent of -Wmacro-redefined.
255 - target_compile_options(ccd PRIVATE /wd4005)
256 - else()
257 - target_compile_options(ccd PRIVATE -Wno-macro-redefined)
259 +if(NOT MUJOCO_USE_SYSTEM_ccd)
260 + target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
261 + target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
262 + # This is necessary to ensure that the any library that consumes the ccd
263 + # compiled internally by MuJoCo (as static library) has CCD_EXPORT correctly
264 + # defined as an empty string. For ccd itself, this is ensured by the variable
265 + # CCD_HIDE_ALL_SYMBOLS set to ON before the call to findorfetch
266 + # See https://github.com/danfis/libccd/pull/79
267 + target_compile_definitions(ccd INTERFACE CCD_STATIC_DEFINE)
269 + # libCCD has an unconditional `#define _CRT_SECURE_NO_WARNINGS` on Windows.
270 + # TODO(stunya): Remove this after https://github.com/danfis/libccd/pull/77 is merged.
271 + if(WIN32)
272 + if(MSVC)
273 + # C4005 is the MSVC equivalent of -Wmacro-redefined.
274 + target_compile_options(ccd PRIVATE /wd4005)
275 + else()
276 + target_compile_options(ccd PRIVATE -Wno-macro-redefined)
277 + endif()
278 endif()
279 endif()
281 if(MUJOCO_BUILD_TESTS)
282 + option(MUJOCO_USE_SYSTEM_abseil "Use installed abseil version." OFF)
283 + mark_as_advanced(MUJOCO_USE_SYSTEM_abseil)
285 set(ABSL_PROPAGATE_CXX_STD ON)
287 # This specific version of Abseil does not have the following variable. We need to work with BUILD_TESTING
288 @@ -249,15 +296,11 @@ if(MUJOCO_BUILD_TESTS)
289 set(ABSL_BUILD_TESTING OFF)
290 findorfetch(
291 USE_SYSTEM_PACKAGE
292 - OFF
293 + ${MUJOCO_USE_SYSTEM_abseil}
294 PACKAGE_NAME
295 absl
296 LIBRARY_NAME
297 abseil-cpp
298 - GIT_REPO
299 - https://github.com/abseil/abseil-cpp.git
300 - GIT_TAG
301 - ${MUJOCO_DEP_VERSION_abseil}
302 TARGETS
303 absl::core_headers
304 EXCLUDE_FROM_ALL
305 @@ -268,6 +311,9 @@ if(MUJOCO_BUILD_TESTS)
306 CACHE BOOL "Build tests." FORCE
309 + option(MUJOCO_USE_SYSTEM_gtest "Use installed gtest version." OFF)
310 + mark_as_advanced(MUJOCO_USE_SYSTEM_gtest)
312 # Avoid linking errors on Windows by dynamically linking to the C runtime.
313 set(gtest_force_shared_crt
315 @@ -276,22 +322,20 @@ if(MUJOCO_BUILD_TESTS)
317 findorfetch(
318 USE_SYSTEM_PACKAGE
319 - OFF
320 + ${MUJOCO_USE_SYSTEM_gtest}
321 PACKAGE_NAME
322 GTest
323 LIBRARY_NAME
324 googletest
325 - GIT_REPO
326 - https://github.com/google/googletest.git
327 - GIT_TAG
328 - ${MUJOCO_DEP_VERSION_gtest}
329 TARGETS
330 - gtest
331 - gmock
332 - gtest_main
333 + GTest::gmock
334 + GTest::gtest_main
335 EXCLUDE_FROM_ALL
338 + option(MUJOCO_USE_SYSTEM_benchmark "Use installed benchmark version." OFF)
339 + mark_as_advanced(MUJOCO_USE_SYSTEM_benchmark)
341 set(BENCHMARK_EXTRA_FETCH_ARGS "")
342 if(WIN32 AND NOT MSVC)
343 set(BENCHMARK_EXTRA_FETCH_ARGS
344 @@ -310,15 +354,11 @@ if(MUJOCO_BUILD_TESTS)
346 findorfetch(
347 USE_SYSTEM_PACKAGE
348 - OFF
349 + ${MUJOCO_USE_SYSTEM_benchmark}
350 PACKAGE_NAME
351 benchmark
352 LIBRARY_NAME
353 benchmark
354 - GIT_REPO
355 - https://github.com/google/benchmark.git
356 - GIT_TAG
357 - ${MUJOCO_DEP_VERSION_benchmark}
358 TARGETS
359 benchmark::benchmark
360 benchmark::benchmark_main
361 @@ -328,15 +368,18 @@ if(MUJOCO_BUILD_TESTS)
362 endif()
364 if(MUJOCO_TEST_PYTHON_UTIL)
365 + option(MUJOCO_USE_SYSTEM_Eigen3 "Use installed Eigen3 version." OFF)
366 + mark_as_advanced(MUJOCO_USE_SYSTEM_Eigen3)
368 add_compile_definitions(EIGEN_MPL2_ONLY)
369 - if(NOT TARGET eigen)
370 - # Support new IN_LIST if() operator.
371 - set(CMAKE_POLICY_DEFAULT_CMP0057 NEW)
372 + if(NOT TARGET Eigen3::Eigen)
373 + if(NOT MUJOCO_USE_SYSTEM_Eigen3)
374 + # Support new IN_LIST if() operator.
375 + set(CMAKE_POLICY_DEFAULT_CMP0057 NEW)
376 + endif()
378 FetchContent_Declare(
379 Eigen3
380 - GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
381 - GIT_TAG ${MUJOCO_DEP_VERSION_Eigen3}
384 FetchContent_GetProperties(Eigen3)
385 @@ -348,6 +391,19 @@ if(MUJOCO_TEST_PYTHON_UTIL)
386 set_target_properties(
387 Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${eigen3_SOURCE_DIR}"
390 + fetchcontent_getproperties(Eigen3)
391 + # if(NOT Eigen3_POPULATED)
392 + # fetchcontent_populate(Eigen3)
394 + # # Mark the library as IMPORTED as a workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/15415
395 + # add_library(Eigen3::Eigen INTERFACE IMPORTED)
396 + # set_target_properties(
397 + # Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${eigen3_SOURCE_DIR}"
398 + # )
399 + # endif()
400 + else()
401 + find_package(Eigen3 REQUIRED)
402 endif()
403 endif()
404 endif()
405 diff --git a/plugin/sdf/CMakeLists.txt b/plugin/sdf/CMakeLists.txt
406 index 3e216fc4..e7e3a1eb 100644
407 --- a/plugin/sdf/CMakeLists.txt
408 +++ b/plugin/sdf/CMakeLists.txt
409 @@ -37,7 +37,7 @@ set(MUJOCO_SDF_SRCS
410 add_library(sdf SHARED)
411 target_sources(sdf PRIVATE ${MUJOCO_SDF_SRCS})
412 target_include_directories(sdf PRIVATE ${MUJOCO_SDF_INCLUDE})
413 -target_link_libraries(sdf PRIVATE mujoco SdfLib)
414 +target_link_libraries(sdf PRIVATE mujoco SdfLib::SdfLib)
415 target_compile_options(
417 PRIVATE ${AVX_COMPILE_OPTIONS}
418 diff --git a/python/mujoco/util/CMakeLists.txt b/python/mujoco/util/CMakeLists.txt
419 index 666a3725..d89bb499 100644
420 --- a/python/mujoco/util/CMakeLists.txt
421 +++ b/python/mujoco/util/CMakeLists.txt
422 @@ -63,8 +63,8 @@ if(BUILD_TESTING)
423 target_link_libraries(
424 array_traits_test
425 array_traits
426 - gmock
427 - gtest_main
428 + GTest::gmock
429 + GTest::gtest_main
431 gtest_add_tests(TARGET array_traits_test SOURCES array_traits_test.cc)
433 @@ -72,8 +72,8 @@ if(BUILD_TESTING)
434 target_link_libraries(
435 func_traits_test
436 func_traits
437 - gmock
438 - gtest_main
439 + GTest::gmock
440 + GTest::gtest_main
442 gtest_add_tests(TARGET func_traits_test SOURCES func_traits_test.cc)
444 @@ -81,8 +81,8 @@ if(BUILD_TESTING)
445 target_link_libraries(
446 func_wrap_test
447 func_wrap
448 - gmock
449 - gtest_main
450 + GTest::gmock
451 + GTest::gtest_main
453 gtest_add_tests(TARGET func_wrap_test SOURCES func_wrap_test.cc)
455 @@ -90,8 +90,8 @@ if(BUILD_TESTING)
456 target_link_libraries(
457 tuple_tools_test
458 func_wrap
459 - gmock
460 - gtest_main
461 + GTest::gmock
462 + GTest::gtest_main
464 gtest_add_tests(TARGET tuple_tools_test SOURCES tuple_tools_test.cc)
465 endif()
466 diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake
467 index 5141406c..75ff7884 100644
468 --- a/simulate/cmake/SimulateDependencies.cmake
469 +++ b/simulate/cmake/SimulateDependencies.cmake
470 @@ -81,10 +81,6 @@ findorfetch(
471 glfw3
472 LIBRARY_NAME
473 glfw3
474 - GIT_REPO
475 - https://github.com/glfw/glfw.git
476 - GIT_TAG
477 - ${MUJOCO_DEP_VERSION_glfw3}
478 TARGETS
479 glfw
480 EXCLUDE_FROM_ALL
481 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
482 index 122760a9..ddd90819 100644
483 --- a/test/CMakeLists.txt
484 +++ b/test/CMakeLists.txt
485 @@ -30,7 +30,7 @@ macro(mujoco_test name)
488 add_executable(${name} ${name}.cc)
489 - target_link_libraries(${name} gtest_main mujoco)
490 + target_link_libraries(${name} GTest::gtest_main mujoco)
491 target_include_directories(${name} PRIVATE ${MUJOCO_TEST_INCLUDE})
492 set_target_properties(${name} PROPERTIES BUILD_RPATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
493 # gtest_discover_tests is recommended over gtest_add_tests, but has some issues in Windows.
494 @@ -60,20 +60,20 @@ target_link_libraries(
495 absl::synchronization
496 absl::flat_hash_map
497 absl::flat_hash_set
498 - gtest
499 - gmock
500 + GTest::gtest
501 + GTest::gmock
502 mujoco::mujoco
504 target_include_directories(fixture PRIVATE ${mujoco_SOURCE_DIR}/include gmock)
506 mujoco_test(fixture_test)
507 -target_link_libraries(fixture_test fixture gmock)
508 +target_link_libraries(fixture_test fixture GTest::gmock)
510 mujoco_test(header_test)
511 -target_link_libraries(header_test fixture gmock)
512 +target_link_libraries(fixture_test fixture GTest::gmock)
514 mujoco_test(pipeline_test)
515 -target_link_libraries(pipeline_test fixture gmock)
516 +target_link_libraries(fixture_test fixture GTest::gmock)
518 add_subdirectory(benchmark)
519 add_subdirectory(engine)