Initial open sourcing of MuJoCo.

PiperOrigin-RevId: 450374687
Change-Id: Ie3225a46ce095fc28ae8e63c326a640261f562bb
This commit is contained in:
Saran Tunyasuvunakool
2022-05-23 01:08:10 -07:00
committed by Copybara-Service
parent 0e5d062302
commit 1913a02b40
275 changed files with 99607 additions and 935 deletions
+25 -14
View File
@@ -31,8 +31,9 @@
#
# Arguments:
# - ``USE_SYSTEM_PACKAGE`` one-value argument on whether to search for the
# package in the system (ON) or whether to fetch the library from a git
# repository (OFF).
# package in the system (ON) or whether to fetch the library using
# FetchContent from the specified Git repository (OFF). Note that
# FetchContent variables will override this behaviour.
# - ``PACKAGE_NAME`` name of the system-package. Ignored if
# ``USE_SYSTEM_PACKAGE`` is ``OFF``.
# - ``LIBRARY_NAME`` name of the library. Ignored if
@@ -41,9 +42,19 @@
# ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``GIT_TAG`` tag reference when fetching the library from the git
# repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an
# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter.
# - ``TARGETS`` list of targets to be satisfied. If any of these targets are
# not currently defined, this macro will attempt to either find or fetch the
# package.
# - ``EXCLUDE_FROM_ALL`` if specified, the targets are not added to the ``all``
# metatarget.
#
# Note: if ``USE_SYSTEM_PACKAGE`` is ``OFF``, FetchContent will be used to
# retrieve the specified targets. It is possible to specify any variable in
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
# override this macro behaviour.
if(COMMAND FindOrFetch)
return()
@@ -76,10 +87,14 @@ macro(FindOrFetch)
if(NOT _ARGS_TARGETS)
message(FATAL_ERROR "mujoco::FindOrFetch: TARGETS must be specified.")
endif()
set(targets_found TRUE)
message(CHECK_START
"mujoco::FindOrFetch: checking for targets in package `${_ARGS_PACKAGE_NAME}`"
)
foreach(target ${_ARGS_TARGETS})
if(NOT TARGET ${target})
message(STATUS "mujoco::FindOrFetch: target `${target}` not defined.")
message(CHECK_FAIL "target `${target}` not defined.")
set(targets_found FALSE)
break()
endif()
@@ -88,16 +103,14 @@ macro(FindOrFetch)
# If targets are not found, use `find_package` or `FetchContent...` to get it.
if(NOT targets_found)
if(${_ARGS_USE_SYSTEM_PACKAGE})
message(
STATUS
"mujoco::FindOrFetch: Attempting to find `${_ARGS_PACKAGE_NAME}` in system packages..."
message(CHECK_START
"mujoco::FindOrFetch: finding `${_ARGS_PACKAGE_NAME}` in system packages..."
)
find_package(${_ARGS_PACKAGE_NAME} REQUIRED)
message(STATUS "mujoco::FindOrFetch: Found `${_ARGS_PACKAGE_NAME}` in system packages.")
message(CHECK_PASS "found")
else()
message(
STATUS
"mujoco::FindOrFetch: Attempting to fetch `${_ARGS_LIBRARY_NAME}` from `${_ARGS_GIT_REPO}`..."
message(CHECK_START
"mujoco::FindOrFetch: Using FetchContent to retrieve `${_ARGS_LIBRARY_NAME}`"
)
FetchContent_Declare(
${_ARGS_LIBRARY_NAME}
@@ -118,11 +131,9 @@ macro(FindOrFetch)
else()
FetchContent_MakeAvailable(${_ARGS_LIBRARY_NAME})
endif()
message(
STATUS "mujoco::FindOrFetch: Fetched `${_ARGS_LIBRARY_NAME}` from `${_ARGS_GIT_REPO}`."
)
message(CHECK_PASS "Done")
endif()
else()
message(STATUS "mujoco::FindOrFetch: `${_ARGS_PACKAGE_NAME}` targets found.")
message(CHECK_PASS "found")
endif()
endmacro()