[mujoco] Add new port (#28993)

* Add new port mujoco

* Add usage text.

---------

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
This commit is contained in:
talregev 2023-02-16 23:32:07 +02:00 committed by GitHub
parent b6dceb5053
commit 3eafaa76fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 250 additions and 0 deletions

View File

@ -0,0 +1,172 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e34b07e..56ed5e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,7 +87,7 @@ add_subdirectory(src/xml)
add_subdirectory(src/render)
add_subdirectory(src/ui)
-target_compile_definitions(mujoco PRIVATE _GNU_SOURCE CCD_STATIC_DEFINE MUJOCO_DLL_EXPORTS)
+target_compile_definitions(mujoco PRIVATE _GNU_SOURCE MUJOCO_DLL_EXPORTS)
if(MUJOCO_ENABLE_AVX_INTRINSICS)
target_compile_definitions(mujoco PUBLIC mjUSEPLATFORMSIMD)
endif()
@@ -110,9 +110,9 @@ target_link_libraries(
mujoco
PRIVATE ccd
lodepng
- qhullstatic_r
- tinyobjloader
- tinyxml2
+ Qhull::qhull_r
+ tinyobjloader::tinyobjloader
+ tinyxml2::tinyxml2
)
set_target_properties(
diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake
index 9c12ef7..af09f8a 100644
--- a/cmake/MujocoDependencies.cmake
+++ b/cmake/MujocoDependencies.cmake
@@ -79,7 +79,7 @@ set(BUILD_SHARED_LIBS
CACHE INTERNAL "Build SHARED libraries"
)
-if(NOT TARGET lodepng)
+if(0)
FetchContent_Declare(
lodepng
GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
@@ -99,35 +99,57 @@ if(NOT TARGET lodepng)
endif()
endif()
+findorfetch(
+ USE_SYSTEM_PACKAGE
+ ON
+ PACKAGE_NAME
+ lodepng
+ LIBRARY_NAME
+ lodepng
+ GIT_REPO
+ https://github.com/lvandeve/lodepng.git
+ GIT_TAG
+ ${MUJOCO_DEP_VERSION_lodepng}
+ TARGETS
+ lodepng
+ EXCLUDE_FROM_ALL
+)
+
set(QHULL_ENABLE_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
- qhull
+ Qhull
LIBRARY_NAME
- qhull
+ Qhull
GIT_REPO
https://github.com/qhull/qhull.git
GIT_TAG
${MUJOCO_DEP_VERSION_qhull}
TARGETS
- qhull
+ Qhull
EXCLUDE_FROM_ALL
)
# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
# Add it to the target.
+if(0)
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})
+endif()
+
+include_directories(
+ ${Qhull_DIR}/../../include/libqhull_r
+)
set(tinyxml2_BUILD_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
tinyxml2
LIBRARY_NAME
@@ -140,12 +162,14 @@ findorfetch(
tinyxml2
EXCLUDE_FROM_ALL
)
+if(0)
target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+endif()
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
tinyobjloader
LIBRARY_NAME
@@ -163,7 +187,7 @@ set(ENABLE_DOUBLE_PRECISION ON)
set(CCD_HIDE_ALL_SYMBOLS ON)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
ccd
LIBRARY_NAME
@@ -176,11 +200,14 @@ findorfetch(
ccd
EXCLUDE_FROM_ALL
)
+if(0)
target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+endif()
# 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.
+if(0)
if(WIN32)
if(MSVC)
# C4005 is the MSVC equivalent of -Wmacro-redefined.
@@ -189,6 +216,7 @@ if(WIN32)
target_compile_options(ccd PRIVATE -Wno-macro-redefined)
endif()
endif()
+endif()
if(MUJOCO_BUILD_TESTS)
set(ABSL_PROPAGATE_CXX_STD ON)
diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake
index fa539c2..8b3b239 100644
--- a/simulate/cmake/SimulateDependencies.cmake
+++ b/simulate/cmake/SimulateDependencies.cmake
@@ -86,7 +86,7 @@ findorfetch(
GIT_TAG
${MUJOCO_DEP_VERSION_glfw3}
TARGETS
- glfw
+ glfw3
EXCLUDE_FROM_ALL
)
@@ -98,7 +98,7 @@ if(MUJOCO_EXTRAS_STATIC_GLFW)
unset(BUILD_SHARED_LIBS_OLD)
endif()
-if(NOT SIMULATE_STANDALONE)
+if(0)
target_compile_options(glfw PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
target_link_options(glfw PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
endif()

View File

@ -0,0 +1,32 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO deepmind/mujoco
REF ${VERSION}
SHA512 518b9ae09ea7cd4d2095df1be985a30957c6d57846933e111c326e45b61ac002bea014cd0d7902653c85e61ef0ba156b3324eff0edb5613467fe8e07e92dd6da
PATCHES
fix_dependencies.patch
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DMUJOCO_BUILD_EXAMPLES=OFF
-DMUJOCO_BUILD_TESTS=OFF
-DMUJOCO_TEST_PYTHON_UTIL=OFF
-DSIMULATE_BUILD_EXECUTABLE=OFF
-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON
-DMUJOCO_SIMULATE_USE_SYSTEM_MUJOCO=ON
)
vcpkg_cmake_install(ADD_BIN_TO_PATH)
vcpkg_cmake_config_fixup(
CONFIG_PATH lib/cmake/${PORT}
)
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

4
ports/mujoco/usage Normal file
View File

@ -0,0 +1,4 @@
mujoco provides CMake targets:
find_package(mujoco CONFIG REQUIRED)
target_link_libraries(main PRIVATE mujoco::mujoco)

29
ports/mujoco/vcpkg.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "mujoco",
"version": "2.3.2",
"description": "Multi-Joint dynamics with Contact.",
"homepage": "mujoco.org",
"license": "Apache-2.0",
"supports": "!(windows & static)",
"dependencies": [
{
"name": "ccd",
"features": [
"double-precision"
]
},
"glfw3",
"lodepng",
"qhull",
"tinyobjloader",
"tinyxml2",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@ -5228,6 +5228,10 @@
"baseline": "1.0.2",
"port-version": 3
},
"mujoco": {
"baseline": "2.3.2",
"port-version": 0
},
"mujs": {
"baseline": "1.3.2",
"port-version": 1

9
versions/m-/mujoco.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "086053d3e52e0d7565733cf06db736f2e1617a63",
"version": "2.3.2",
"port-version": 0
}
]
}