Merge pull request #266099 from tmplt/feat/mujoco-3.0.0

mujoco: 2.3.7 -> 3.0.1, add Python bindings
This commit is contained in:
Samuel Ainsworth 2023-12-02 15:47:04 -08:00 committed by GitHub
commit d71187cf33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 957 additions and 218 deletions

View File

@ -1,122 +1,184 @@
{ cmake
{ cereal_1_3_2
, cmake
, fetchFromGitHub
, fetchFromGitLab
, git
, glfw
, glm
, lib
, libGL
, spdlog
, stdenv
, xorg
}:
let
# See https://github.com/deepmind/mujoco/blob/c9246e1f5006379d599e0bcddf159a8616d31441/cmake/MujocoDependencies.cmake#L17-L55
abseil-cpp = fetchFromGitHub {
owner = "abseil";
repo = "abseil-cpp";
rev = "c2435f8342c2d0ed8101cb43adfd605fdc52dca2";
hash = "sha256-PLoI7ix+reUqkZ947kWzls8lujYqWXk9A9a55UcfahI=";
};
benchmark = fetchFromGitHub {
owner = "google";
repo = "benchmark";
rev = "2dd015dfef425c866d9a43f2c67d8b52d709acb6";
hash = "sha256-pUW9YVaujs/y00/SiPqDgK4wvVsaM7QUp/65k0t7Yr0=";
};
ccd = fetchFromGitHub {
owner = "danfis";
repo = "libccd";
rev = "7931e764a19ef6b21b443376c699bbc9c6d4fba8";
hash = "sha256-TIZkmqQXa0+bSWpqffIgaBela0/INNsX9LPM026x1Wk=";
};
eigen3 = fetchFromGitLab {
owner = "libeigen";
repo = "eigen";
rev = "211c5dfc6741a5570ad007983c113ef4d144f9f3";
hash = "sha256-oT/h8QkL0vwaflh46Zsnu9Db1b65AP6p//nAga8M5jI=";
};
googletest = fetchFromGitHub {
owner = "google";
repo = "googletest";
rev = "b796f7d44681514f58a683a3a71ff17c94edb0c1";
hash = "sha256-LVLEn+e7c8013pwiLzJiiIObyrlbBHYaioO/SWbItPQ=";
};
lodepng = fetchFromGitHub {
owner = "lvandeve";
repo = "lodepng";
rev = "b4ed2cd7ecf61d29076169b49199371456d4f90b";
hash = "sha256-5cCkdj/izP4e99BKfs/Mnwu9aatYXjlyxzzYiMD/y1M=";
};
qhull = fetchFromGitHub {
owner = "qhull";
repo = "qhull";
rev = "0c8fc90d2037588024d9964515c1e684f6007ecc";
hash = "sha256-Ptzxad3ewmKJbbcmrBT+os4b4SR976zlCG9F0nq0x94=";
};
tinyobjloader = fetchFromGitHub {
owner = "tinyobjloader";
repo = "tinyobjloader";
rev = "1421a10d6ed9742f5b2c1766d22faa6cfbc56248";
hash = "sha256-9z2Ne/WPCiXkQpT8Cun/pSGUwgClYH+kQ6Dx1JvW6w0=";
};
tinyxml2 = fetchFromGitHub {
owner = "leethomason";
repo = "tinyxml2";
rev = "9a89766acc42ddfa9e7133c7d81a5bda108a0ade";
hash = "sha256-YGAe4+Ttv/xeou+9FoJjmQCKgzupTYdDhd+gzvtz/88=";
pin = {
# See https://github.com/google-deepmind/mujoco/blob/3.0.0/cmake/MujocoDependencies.cmake#L17-L64
abseil-cpp = fetchFromGitHub {
owner = "abseil";
repo = "abseil-cpp";
rev = "fb3621f4f897824c0dbe0615fa94543df6192f30";
hash = "sha256-uNGrTNg5G5xFGtc+BSWE389x0tQ/KxJQLHfebNWas/k=";
};
benchmark = fetchFromGitHub {
owner = "google";
repo = "benchmark";
rev = "344117638c8ff7e239044fd0fa7085839fc03021";
hash = "sha256-gztnxui9Fe/FTieMjdvfJjWHjkImtlsHn6fM1FruyME=";
};
ccd = fetchFromGitHub {
owner = "danfis";
repo = "libccd";
rev = "7931e764a19ef6b21b443376c699bbc9c6d4fba8";
hash = "sha256-TIZkmqQXa0+bSWpqffIgaBela0/INNsX9LPM026x1Wk=";
};
eigen3 = fetchFromGitLab {
owner = "libeigen";
repo = "eigen";
rev = "e8515f78ac098329ab9f8cab21c87caede090a3f";
hash = "sha256-HXKtFJsKGpug+wNPjYynTuyaG0igo3oG4rFQktveh1g=";
};
googletest = fetchFromGitHub {
owner = "google";
repo = "googletest";
rev = "f8d7d77c06936315286eb55f8de22cd23c188571";
hash = "sha256-t0RchAHTJbuI5YW4uyBPykTvcjy90JW9AOPNjIhwh6U=";
};
lodepng = fetchFromGitHub {
owner = "lvandeve";
repo = "lodepng";
rev = "b4ed2cd7ecf61d29076169b49199371456d4f90b";
hash = "sha256-5cCkdj/izP4e99BKfs/Mnwu9aatYXjlyxzzYiMD/y1M=";
};
qhull = fetchFromGitHub {
owner = "qhull";
repo = "qhull";
rev = "0c8fc90d2037588024d9964515c1e684f6007ecc";
hash = "sha256-Ptzxad3ewmKJbbcmrBT+os4b4SR976zlCG9F0nq0x94=";
};
tinyobjloader = fetchFromGitHub {
owner = "tinyobjloader";
repo = "tinyobjloader";
rev = "1421a10d6ed9742f5b2c1766d22faa6cfbc56248";
hash = "sha256-9z2Ne/WPCiXkQpT8Cun/pSGUwgClYH+kQ6Dx1JvW6w0=";
};
tinyxml2 = fetchFromGitHub {
owner = "leethomason";
repo = "tinyxml2";
rev = "9a89766acc42ddfa9e7133c7d81a5bda108a0ade";
hash = "sha256-YGAe4+Ttv/xeou+9FoJjmQCKgzupTYdDhd+gzvtz/88=";
};
marchingcubecpp = fetchFromGitHub {
owner = "aparis69";
repo = "MarchingCubeCpp";
rev = "5b79e5d6bded086a0abe276a4b5a69fc17ae9bf1";
hash = "sha256-L0DH1GJZ/3vatQAU/KZj/2xTKE6Fwcw9eQYzLdqX2N4=";
};
tmd = stdenv.mkDerivation rec {
name = "TriangleMeshDistance";
src = fetchFromGitHub {
owner = "InteractiveComputerGraphics";
repo = name;
rev = "e55a15c20551f36242fd6368df099a99de71d43a";
hash = "sha256-vj6TMMT8mp7ciLa5nzVAhMWPcAHXq+ZwHlWsRA3uCmg=";
};
installPhase = ''
mkdir -p $out/include/tmd
cp ${name}/include/tmd/${name}.h $out/include/tmd/
'';
};
sdflib = stdenv.mkDerivation rec {
name = "SdfLib";
src = fetchFromGitHub {
owner = "UPC-ViRVIG";
repo = name;
rev = "7c49cfba9bbec763b5d0f7b90b26555f3dde8088";
hash = "sha256-5bnQ3rHH9Pw1jRVpZpamFnhIJHWnGm6krgZgIBqNtVg=";
};
patches = [ ./sdflib-system-deps.patch ];
cmakeFlags = [
"-DSDFLIB_USE_ASSIMP=OFF"
"-DSDFLIB_USE_OPENMP=OFF"
"-DSDFLIB_USE_ENOKI=OFF"
"-DSDFLIB_USE_SYSTEM_GLM=ON"
"-DSDFLIB_USE_SYSTEM_SPDLOG=ON"
"-DSDFLIB_USE_SYSTEM_CEREAL=ON"
"-DSDFLIB_USE_SYSTEM_TRIANGLEMESHDISTANCE=ON"
];
nativeBuildInputs = [ cmake ];
buildInputs = [
pin.tmd
# Mainline. The otherwise pinned glm realease from 2018 does
# not build due to test failures and missing files.
glm
spdlog
cereal_1_3_2
];
};
};
# See https://github.com/deepmind/mujoco/blob/c9246e1f5006379d599e0bcddf159a8616d31441/simulate/cmake/SimulateDependencies.cmake#L32-L35
glfw3 = fetchFromGitHub {
owner = "glfw";
repo = "glfw";
rev = "7482de6071d21db77a7236155da44c172a7f6c9e";
hash = "sha256-4+H0IXjAwbL5mAWfsIVhW0BSJhcWjkQx4j2TrzZ3aIo=";
};
in
stdenv.mkDerivation rec {
in stdenv.mkDerivation rec {
pname = "mujoco";
version = "2.3.7";
version = "3.0.1";
src = fetchFromGitHub {
owner = "deepmind";
owner = "google-deepmind";
repo = pname;
rev = version;
hash = "sha256-LgpA+iPGqciHuWBSD6/7yvZ7p+vo48ZYKjjrDZSnAwE=";
hash = "sha256-UXE+7KDti8RarpoJoo9Ei3TgW/Qdnj3ASRo8uTWhGrU=";
};
patches = [ ./dependencies.patch ];
patches = [ ./mujoco-system-deps-dont-fetch.patch ];
nativeBuildInputs = [ cmake git ];
nativeBuildInputs = [ cmake ];
buildInputs = [
libGL
xorg.libX11
xorg.libXcursor
xorg.libXext
xorg.libXi
xorg.libXinerama
xorg.libXrandr
pin.sdflib
glm
# non-numerical
spdlog
cereal_1_3_2
glfw
];
cmakeFlags = [
"-DMUJOCO_USE_SYSTEM_sdflib=ON"
"-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON"
"-DMUJOCO_SAMPLES_USE_SYSTEM_GLFW=ON"
];
# Move things into place so that cmake doesn't try downloading dependencies.
preConfigure = ''
mkdir -p build/_deps
ln -s ${abseil-cpp} build/_deps/abseil-cpp-src
ln -s ${benchmark} build/_deps/benchmark-src
ln -s ${ccd} build/_deps/ccd-src
ln -s ${eigen3} build/_deps/eigen3-src
ln -s ${glfw3} build/_deps/glfw3-src
ln -s ${googletest} build/_deps/googletest-src
ln -s ${lodepng} build/_deps/lodepng-src
ln -s ${qhull} build/_deps/qhull-src
ln -s ${tinyobjloader} build/_deps/tinyobjloader-src
ln -s ${tinyxml2} build/_deps/tinyxml2-src
ln -s ${pin.abseil-cpp} build/_deps/abseil-cpp-src
ln -s ${pin.benchmark} build/_deps/benchmark-src
ln -s ${pin.ccd} build/_deps/ccd-src
ln -s ${pin.eigen3} build/_deps/eigen3-src
ln -s ${pin.googletest} build/_deps/googletest-src
ln -s ${pin.lodepng} build/_deps/lodepng-src
ln -s ${pin.qhull} build/_deps/qhull-src
ln -s ${pin.tinyobjloader} build/_deps/tinyobjloader-src
ln -s ${pin.tinyxml2} build/_deps/tinyxml2-src
ln -s ${pin.marchingcubecpp} build/_deps/marchingcubecpp-src
'';
passthru.pin = { inherit (pin) lodepng eigen3 abseil-cpp; };
meta = with lib; {
description = "Multi-Joint dynamics with Contact. A general purpose physics simulator.";
homepage = "https://mujoco.org/";
license = licenses.asl20;
maintainers = with maintainers; [ samuela ];
maintainers = with maintainers; [ samuela tmplt ];
};
}

View File

@ -1,114 +0,0 @@
diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake
index 3e322ea..980aace 100644
--- a/cmake/MujocoDependencies.cmake
+++ b/cmake/MujocoDependencies.cmake
@@ -87,8 +87,6 @@ set(BUILD_SHARED_LIBS
if(NOT TARGET lodepng)
FetchContent_Declare(
lodepng
- GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
- GIT_TAG ${MUJOCO_DEP_VERSION_lodepng}
)
FetchContent_GetProperties(lodepng)
@@ -127,10 +125,6 @@ findorfetch(
qhull
LIBRARY_NAME
qhull
- GIT_REPO
- https://github.com/qhull/qhull.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_qhull}
TARGETS
qhull
EXCLUDE_FROM_ALL
@@ -151,10 +145,6 @@ findorfetch(
tinyxml2
LIBRARY_NAME
tinyxml2
- GIT_REPO
- https://github.com/leethomason/tinyxml2.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_tinyxml2}
TARGETS
tinyxml2
EXCLUDE_FROM_ALL
@@ -169,10 +159,6 @@ findorfetch(
tinyobjloader
LIBRARY_NAME
tinyobjloader
- GIT_REPO
- https://github.com/tinyobjloader/tinyobjloader.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_tinyobjloader}
TARGETS
tinyobjloader
EXCLUDE_FROM_ALL
@@ -187,10 +173,6 @@ findorfetch(
ccd
LIBRARY_NAME
ccd
- GIT_REPO
- https://github.com/danfis/libccd.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_ccd}
TARGETS
ccd
EXCLUDE_FROM_ALL
@@ -227,10 +209,6 @@ if(MUJOCO_BUILD_TESTS)
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
@@ -254,10 +232,6 @@ if(MUJOCO_BUILD_TESTS)
GTest
LIBRARY_NAME
googletest
- GIT_REPO
- https://github.com/google/googletest.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_gtest}
TARGETS
gtest
gmock
@@ -288,10 +262,6 @@ if(MUJOCO_BUILD_TESTS)
benchmark
LIBRARY_NAME
benchmark
- GIT_REPO
- https://github.com/google/benchmark.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_benchmark}
TARGETS
benchmark::benchmark
benchmark::benchmark_main
@@ -308,8 +278,6 @@ if(MUJOCO_TEST_PYTHON_UTIL)
FetchContent_Declare(
Eigen3
- GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
- GIT_TAG ${MUJOCO_DEP_VERSION_Eigen3}
)
FetchContent_GetProperties(Eigen3)
diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake
index fa539c2..5985d5a 100644
--- a/simulate/cmake/SimulateDependencies.cmake
+++ b/simulate/cmake/SimulateDependencies.cmake
@@ -81,10 +81,6 @@ findorfetch(
glfw3
LIBRARY_NAME
glfw3
- GIT_REPO
- https://github.com/glfw/glfw.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_glfw3}
TARGETS
glfw
EXCLUDE_FROM_ALL

View File

@ -0,0 +1,538 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 285250b..32d03e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,7 +92,7 @@ add_subdirectory(src/render)
add_subdirectory(src/thread)
add_subdirectory(src/ui)
-target_compile_definitions(mujoco PRIVATE _GNU_SOURCE CCD_STATIC_DEFINE MUJOCO_DLL_EXPORTS -DMC_IMPLEM_ENABLE)
+target_compile_definitions(mujoco PRIVATE _GNU_SOURCE MUJOCO_DLL_EXPORTS -DMC_IMPLEM_ENABLE)
if(MUJOCO_ENABLE_AVX_INTRINSICS)
target_compile_definitions(mujoco PUBLIC mjUSEPLATFORMSIMD)
endif()
@@ -117,7 +117,7 @@ target_link_libraries(
lodepng
qhullstatic_r
tinyobjloader
- tinyxml2
+ tinyxml2::tinyxml2
)
set_target_properties(
diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake
index 4e3e2c8..f6143d9 100644
--- a/cmake/MujocoDependencies.cmake
+++ b/cmake/MujocoDependencies.cmake
@@ -90,153 +90,203 @@ set(BUILD_SHARED_LIBS
CACHE INTERNAL "Build SHARED libraries"
)
+
if(NOT TARGET lodepng)
- FetchContent_Declare(
+ fetchcontent_declare(
lodepng
- GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
- GIT_TAG ${MUJOCO_DEP_VERSION_lodepng}
)
+endif()
+
+if(NOT TARGET lodepng)
+ if(NOT MUJOCO_USE_SYSTEM_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})
+ 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()
+ else()
+ find_package(lodepng REQUIRED)
endif()
endif()
if(NOT TARGET marchingcubecpp)
- FetchContent_Declare(
+ fetchcontent_declare(
marchingcubecpp
- GIT_REPOSITORY https://github.com/aparis69/MarchingCubeCpp.git
- GIT_TAG ${MUJOCO_DEP_VERSION_MarchingCubeCpp}
)
- FetchContent_GetProperties(marchingcubecpp)
+ fetchcontent_getproperties(marchingcubecpp)
if(NOT marchingcubecpp_POPULATED)
- FetchContent_Populate(marchingcubecpp)
+ fetchcontent_populate(marchingcubecpp)
include_directories(${marchingcubecpp_SOURCE_DIR})
endif()
endif()
+option(MUJOCO_USE_SYSTEM_qhull "Use installed qhull version." OFF)
+mark_as_advanced(MUJOCO_USE_SYSTEM_qhull)
+
set(QHULL_ENABLE_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_qhull}
PACKAGE_NAME
- qhull
+ Qhull
LIBRARY_NAME
qhull
- GIT_REPO
- https://github.com/qhull/qhull.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_qhull}
TARGETS
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.
-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})
+
+if(NOT MUJOCO_USE_SYSTEM_qhull)
+ # 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})
+else()
+ if(NOT TARGET qhullstatic_r)
+ add_library(qhullstatic_r INTERFACE)
+ set_target_properties(qhullstatic_r PROPERTIES INTERFACE_LINK_LIBRARIES Qhull::qhull_r)
+
+ # Workaround as headers are installed in <prefix>/include/libqhull_r/something.h
+ # but mujoco include them as #include <something.h>
+ get_property(qhull_include_dirs TARGET Qhull::qhull_r PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ foreach(qhull_include_dir IN LISTS qhull_include_dirs)
+ target_include_directories(qhullstatic_r INTERFACE ${qhull_include_dirs}/libqhull_r)
+ endforeach()
+ target_include_directories(qhullstatic_r INTERFACE )
+ endif()
+endif()
+
+option(MUJOCO_USE_SYSTEM_tinyxml2 "Use installed tinyxml2 version." OFF)
+mark_as_advanced(MUJOCO_USE_SYSTEM_tinyxml2)
set(tinyxml2_BUILD_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_tinyxml2}
PACKAGE_NAME
tinyxml2
LIBRARY_NAME
tinyxml2
- GIT_REPO
- https://github.com/leethomason/tinyxml2.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_tinyxml2}
TARGETS
- tinyxml2
+ tinyxml2::tinyxml2
EXCLUDE_FROM_ALL
)
-target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+
+if(NOT MUJOCO_USE_SYSTEM_tinyxml2)
+ target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
+ target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+endif()
+
+option(MUJOCO_USE_SYSTEM_tinyobjloader "Use installed tinyobjloader version." OFF)
+mark_as_advanced(MUJOCO_USE_SYSTEM_tinyobjloader)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_tinyobjloader}
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
)
+if(MUJOCO_USE_SYSTEM_tinyobjloader)
+ # As of tinyobjloader v2.0.0rc10, the tinyobjloader target is named tinyobjloader in the build,
+ # but tinyobjloader::tinyobjloader when it is installed. To deal with this, if tinyobjloader is
+ # found in the system, we create an ALIAS
+ # The following is equivalent to add_library(tinyobjloader ALIAS tinyobjloader::tinyobjloader),
+ # but compatible with CMake 3.16 . Once the minimum CMake is bumped to CMake 3.18, we can use
+ # the simpler version
+ add_library(tinyobjloader INTERFACE IMPORTED)
+ set_target_properties(tinyobjloader PROPERTIES INTERFACE_LINK_LIBRARIES tinyobjloader::tinyobjloader)
+endif()
+
+option(MUJOCO_USE_SYSTEM_sdflib "Use installed sdflib version." OFF)
+mark_as_advanced(MUJOCO_USE_SYSTEM_sdflib)
+
option(SDFLIB_USE_ASSIMP OFF)
option(SDFLIB_USE_OPENMP OFF)
option(SDFLIB_USE_ENOKI OFF)
+
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_sdflib}
PACKAGE_NAME
- sdflib
+ SdfLib
LIBRARY_NAME
sdflib
- GIT_REPO
- https://github.com/UPC-ViRVIG/SdfLib.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_sdflib}
TARGETS
- SdfLib
+ SdfLib::SdfLib
EXCLUDE_FROM_ALL
)
-target_compile_options(SdfLib PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(SdfLib PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+
+if(NOT MUJOCO_USE_SYSTEM_sdflib)
+ target_compile_options(SdfLib PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
+ target_link_options(SdfLib PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+endif()
+
+option(MUJOCO_USE_SYSTEM_ccd "Use installed ccd version." OFF)
+mark_as_advanced(MUJOCO_USE_SYSTEM_ccd)
set(ENABLE_DOUBLE_PRECISION ON)
set(CCD_HIDE_ALL_SYMBOLS ON)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_ccd}
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})
-
-# 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(WIN32)
- if(MSVC)
- # C4005 is the MSVC equivalent of -Wmacro-redefined.
- target_compile_options(ccd PRIVATE /wd4005)
- else()
- target_compile_options(ccd PRIVATE -Wno-macro-redefined)
+
+if(NOT MUJOCO_USE_SYSTEM_ccd)
+ target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
+ target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+ # This is necessary to ensure that the any library that consumes the ccd
+ # compiled internally by MuJoCo (as static library) has CCD_EXPORT correctly
+ # defined as an empty string. For ccd itself, this is ensured by the variable
+ # CCD_HIDE_ALL_SYMBOLS set to ON before the call to findorfetch
+ # See https://github.com/danfis/libccd/pull/79
+ target_compile_definitions(ccd INTERFACE CCD_STATIC_DEFINE)
+
+ # 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(WIN32)
+ if(MSVC)
+ # C4005 is the MSVC equivalent of -Wmacro-redefined.
+ target_compile_options(ccd PRIVATE /wd4005)
+ else()
+ target_compile_options(ccd PRIVATE -Wno-macro-redefined)
+ endif()
endif()
endif()
if(MUJOCO_BUILD_TESTS)
+ option(MUJOCO_USE_SYSTEM_abseil "Use installed abseil version." OFF)
+ mark_as_advanced(MUJOCO_USE_SYSTEM_abseil)
+
set(ABSL_PROPAGATE_CXX_STD ON)
# This specific version of Abseil does not have the following variable. We need to work with BUILD_TESTING
@@ -249,15 +299,11 @@ if(MUJOCO_BUILD_TESTS)
set(ABSL_BUILD_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_abseil}
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
@@ -268,6 +314,9 @@ if(MUJOCO_BUILD_TESTS)
CACHE BOOL "Build tests." FORCE
)
+ option(MUJOCO_USE_SYSTEM_gtest "Use installed gtest version." OFF)
+ mark_as_advanced(MUJOCO_USE_SYSTEM_gtest)
+
# Avoid linking errors on Windows by dynamically linking to the C runtime.
set(gtest_force_shared_crt
ON
@@ -276,22 +325,20 @@ if(MUJOCO_BUILD_TESTS)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_gtest}
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
+ GTest::gmock
+ GTest::gtest_main
EXCLUDE_FROM_ALL
)
+ option(MUJOCO_USE_SYSTEM_benchmark "Use installed benchmark version." OFF)
+ mark_as_advanced(MUJOCO_USE_SYSTEM_benchmark)
+
set(BENCHMARK_EXTRA_FETCH_ARGS "")
if(WIN32 AND NOT MSVC)
set(BENCHMARK_EXTRA_FETCH_ARGS
@@ -310,15 +357,11 @@ if(MUJOCO_BUILD_TESTS)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ${MUJOCO_USE_SYSTEM_benchmark}
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
@@ -328,26 +371,42 @@ if(MUJOCO_BUILD_TESTS)
endif()
if(MUJOCO_TEST_PYTHON_UTIL)
+ option(MUJOCO_USE_SYSTEM_Eigen3 "Use installed Eigen3 version." OFF)
+ mark_as_advanced(MUJOCO_USE_SYSTEM_Eigen3)
+
add_compile_definitions(EIGEN_MPL2_ONLY)
- if(NOT TARGET eigen)
- # Support new IN_LIST if() operator.
- set(CMAKE_POLICY_DEFAULT_CMP0057 NEW)
+ if(NOT TARGET Eigen3::Eigen)
+ if(NOT MUJOCO_USE_SYSTEM_Eigen3)
+ # Support new IN_LIST if() operator.
+ set(CMAKE_POLICY_DEFAULT_CMP0057 NEW)
+ endif()
- FetchContent_Declare(
+ fetchcontent_declare(
Eigen3
- GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
- GIT_TAG ${MUJOCO_DEP_VERSION_Eigen3}
)
- FetchContent_GetProperties(Eigen3)
+ fetchcontent_getproperties(Eigen3)
if(NOT Eigen3_POPULATED)
- FetchContent_Populate(Eigen3)
+ 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}"
)
+
+ 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()
+ else()
+ find_package(Eigen3 REQUIRED)
endif()
endif()
endif()
diff --git a/plugin/sdf/CMakeLists.txt b/plugin/sdf/CMakeLists.txt
index 3e216fc..e7e3a1e 100644
--- a/plugin/sdf/CMakeLists.txt
+++ b/plugin/sdf/CMakeLists.txt
@@ -37,7 +37,7 @@ set(MUJOCO_SDF_SRCS
add_library(sdf SHARED)
target_sources(sdf PRIVATE ${MUJOCO_SDF_SRCS})
target_include_directories(sdf PRIVATE ${MUJOCO_SDF_INCLUDE})
-target_link_libraries(sdf PRIVATE mujoco SdfLib)
+target_link_libraries(sdf PRIVATE mujoco SdfLib::SdfLib)
target_compile_options(
sdf
PRIVATE ${AVX_COMPILE_OPTIONS}
diff --git a/python/mujoco/util/CMakeLists.txt b/python/mujoco/util/CMakeLists.txt
index 666a372..d89bb49 100644
--- a/python/mujoco/util/CMakeLists.txt
+++ b/python/mujoco/util/CMakeLists.txt
@@ -63,8 +63,8 @@ if(BUILD_TESTING)
target_link_libraries(
array_traits_test
array_traits
- gmock
- gtest_main
+ GTest::gmock
+ GTest::gtest_main
)
gtest_add_tests(TARGET array_traits_test SOURCES array_traits_test.cc)
@@ -72,8 +72,8 @@ if(BUILD_TESTING)
target_link_libraries(
func_traits_test
func_traits
- gmock
- gtest_main
+ GTest::gmock
+ GTest::gtest_main
)
gtest_add_tests(TARGET func_traits_test SOURCES func_traits_test.cc)
@@ -81,8 +81,8 @@ if(BUILD_TESTING)
target_link_libraries(
func_wrap_test
func_wrap
- gmock
- gtest_main
+ GTest::gmock
+ GTest::gtest_main
)
gtest_add_tests(TARGET func_wrap_test SOURCES func_wrap_test.cc)
@@ -90,8 +90,8 @@ if(BUILD_TESTING)
target_link_libraries(
tuple_tools_test
func_wrap
- gmock
- gtest_main
+ GTest::gmock
+ GTest::gtest_main
)
gtest_add_tests(TARGET tuple_tools_test SOURCES tuple_tools_test.cc)
endif()
diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake
index 5141406..75ff788 100644
--- a/simulate/cmake/SimulateDependencies.cmake
+++ b/simulate/cmake/SimulateDependencies.cmake
@@ -81,10 +81,6 @@ findorfetch(
glfw3
LIBRARY_NAME
glfw3
- GIT_REPO
- https://github.com/glfw/glfw.git
- GIT_TAG
- ${MUJOCO_DEP_VERSION_glfw3}
TARGETS
glfw
EXCLUDE_FROM_ALL
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6bec911..2a16c21 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -30,7 +30,7 @@ macro(mujoco_test name)
)
add_executable(${name} ${name}.cc)
- target_link_libraries(${name} gtest_main mujoco)
+ target_link_libraries(${name} GTest::gtest_main mujoco)
target_include_directories(${name} PRIVATE ${MUJOCO_TEST_INCLUDE})
set_target_properties(${name} PROPERTIES BUILD_RPATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
# gtest_discover_tests is recommended over gtest_add_tests, but has some issues in Windows.
@@ -59,20 +59,20 @@ target_link_libraries(
PUBLIC absl::core_headers
absl::strings
absl::synchronization
- gtest
- gmock
+ GTest::gtest
+ GTest::gmock
mujoco::mujoco
)
target_include_directories(fixture PRIVATE ${mujoco_SOURCE_DIR}/include gmock)
mujoco_test(fixture_test)
-target_link_libraries(fixture_test fixture gmock)
+target_link_libraries(fixture_test fixture GTest::gmock)
mujoco_test(header_test)
-target_link_libraries(header_test fixture gmock)
+target_link_libraries(header_test fixture GTest::gmock)
mujoco_test(pipeline_test)
-target_link_libraries(pipeline_test fixture gmock)
+target_link_libraries(pipeline_test fixture GTest::gmock)
add_subdirectory(benchmark)
add_subdirectory(engine)

View File

@ -0,0 +1,192 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 251c456..3d30231 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ option(SDFLIB_USE_SYSTEM_GLM "Use glm library via find_package instead of downlo
option(SDFLIB_USE_SYSTEM_SPDLOG "Use spdlog library via find_package instead of downloading it" OFF)
option(SDFLIB_USE_SYSTEM_CEREAL "Use cereal library via find_package instead of downloading it" OFF)
option(SDFLIB_USE_SYSTEM_ASSIMP "Use assimp library via find_package instead of downloading it" OFF)
-
+option(SDFLIB_USE_SYSTEM_TRIANGLEMESHDISTANCE "Use TriangleMeshDistance library via system includes instead of downloading it" OFF)
if(SDFLIB_DEBUG_INFO)
add_compile_definitions(SDFLIB_PRINT_STATISTICS)
@@ -55,13 +55,52 @@ file(GLOB UTILS_SOURCE_FILES src/utils/*.cpp)
file(GLOB UTILS_HEADER_FILES src/utils/*.h)
# Add libraries
-add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${HEADER_FILES} ${PUBLIC_HEADER_FILES}
- ${SDF_SOURCE_FILES} ${SDF_HEADER_FILES}
- ${UTILS_SOURCE_FILES} ${UTILS_HEADER_FILES})
-
-target_include_directories(${PROJECT_NAME} PUBLIC include/)
+add_library(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${PUBLIC_HEADER_FILES}
+ ${SDF_SOURCE_FILES} ${SDF_HEADER_FILES}
+ ${UTILS_SOURCE_FILES} ${UTILS_HEADER_FILES})
+add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
+if(BUILD_SHARED_LIBS AND WIN32)
+ set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
+endif()
+include(GNUInstallDirs)
+target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(${PROJECT_NAME} PRIVATE src/)
+# Install library and CMake config files
+install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME})
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/SdfLib
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+install(EXPORT ${PROJECT_NAME}
+ FILE ${PROJECT_NAME}Targets.cmake
+ DESTINATION lib/cmake/${PROJECT_NAME}
+ NAMESPACE ${PROJECT_NAME}::
+)
+
+include(CMakePackageConfigHelpers)
+set(PACKAGE_DEPENDENCIES "")
+if(SDFLIB_USE_SYSTEM_GLM)
+ string(APPEND PACKAGE_DEPENDENCIES "find_dependency(glm)\n")
+endif()
+if(SDFLIB_USE_SYSTEM_SPDLOG)
+ string(APPEND PACKAGE_DEPENDENCIES "find_dependency(spdlog)\n")
+endif()
+if(SDFLIB_USE_SYSTEM_CEREAL)
+ string(APPEND PACKAGE_DEPENDENCIES "find_dependency(cereal)\n")
+endif()
+if(SDFLIB_USE_ASSIMP AND SDFLIB_USE_SYSTEM_ASSIMP)
+ string(APPEND PACKAGE_DEPENDENCIES "find_dependency(assimp)\n")
+endif()
+
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ INSTALL_DESTINATION "lib/cmake/${PROJECT_NAME}"
+ NO_SET_AND_CHECK_MACRO
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
+ DESTINATION lib/cmake/${PROJECT_NAME})
+
# Add shaders
file(GLOB SHADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src/render_engine/shaders
src/render_engine/shaders/*.frag
@@ -69,7 +108,7 @@ file(GLOB SHADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src/render_engine/sh
src/render_engine/shaders/*.comp)
foreach(SHADER IN LISTS SHADER_FILES)
- add_custom_command(OUTPUT ${SHADER}
+add_custom_command(OUTPUT ${SHADER}
COMMAND cmake -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/src/render_engine/shaders/${SHADER} $<TARGET_FILE_DIR:${PROJECT_NAME}>/shaders/${SHADER}
DEPENDS src/render_engine/shaders/${SHADER}
)
@@ -112,7 +151,10 @@ endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${SDFLIB_GLM_TARGET})
target_link_libraries(${PROJECT_NAME} PUBLIC spdlog::spdlog)
target_link_libraries(${PROJECT_NAME} PUBLIC cereal::cereal)
-target_link_libraries(${PROJECT_NAME} PUBLIC icg)
+
+if(NOT SDFLIB_USE_SYSTEM_TRIANGLEMESHDISTANCE)
+ target_link_libraries(${PROJECT_NAME} PUBLIC TriangleMeshDistance)
+endif()
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
target_link_libraries(${PROJECT_NAME} PUBLIC -lstdc++fs)
diff --git a/SdfLibConfig.cmake.in b/SdfLibConfig.cmake.in
new file mode 100644
index 0000000..9b8265c
--- /dev/null
+++ b/SdfLibConfig.cmake.in
@@ -0,0 +1,7 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+@PACKAGE_DEPENDENCIES@
+
+include("${CMAKE_CURRENT_LIST_DIR}/SdfLibTargets.cmake")
diff --git a/include/SdfLib/TrianglesInfluence.h b/include/SdfLib/TrianglesInfluence.h
index fc2ca52..b276f23 100644
--- a/include/SdfLib/TrianglesInfluence.h
+++ b/include/SdfLib/TrianglesInfluence.h
@@ -11,7 +11,7 @@
#include "InterpolationMethods.h"
#include "utils/Timer.h"
#include "utils/GJK.h"
-#include <InteractiveComputerGraphics/TriangleMeshDistance.h>
+#include <tmd/TriangleMeshDistance.h>
#include <vector>
#include <array>
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
index 79f70c1..e2a4f10 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
@@ -137,9 +137,10 @@ if(SDFLIB_BUILD_APPS OR SDFLIB_BUILD_DEBUG_APPS)
target_include_directories(stb_image INTERFACE stb)
endif()
-# icg
-add_library(icg INTERFACE)
-target_include_directories(icg INTERFACE InteractiveComputerGraphics)
+if (NOT SDFLIB_USE_SYSTEM_TRIANGLEMESHDISTANCE)
+ add_library(TriangleMeshDistance INTERFACE)
+ target_include_directories(TriangleMeshDistance INTERFACE InteractiveComputerGraphics)
+endif()
if(SDFLIB_BUILD_APPS OR SDFLIB_BUILD_DEBUG_APPS)
# glfw
diff --git a/libs/InteractiveComputerGraphics/InteractiveComputerGraphics/TriangleMeshDistance.h b/libs/InteractiveComputerGraphics/tmd/TriangleMeshDistance.h
similarity index 100%
rename from libs/InteractiveComputerGraphics/InteractiveComputerGraphics/TriangleMeshDistance.h
rename to libs/InteractiveComputerGraphics/tmd/TriangleMeshDistance.h
diff --git a/src/tools/ImageQueryTime/main.cpp b/src/tools/ImageQueryTime/main.cpp
index 357a78b..f4fd9e7 100644
--- a/src/tools/ImageQueryTime/main.cpp
+++ b/src/tools/ImageQueryTime/main.cpp
@@ -17,7 +17,7 @@
#define TEST_METHODS
#ifdef TEST_METHODS
-#include <InteractiveComputerGraphics/TriangleMeshDistance.h>
+#include <tmd/TriangleMeshDistance.h>
// #include <CGAL/Simple_cartesian.h>
// #include <CGAL/AABB_tree.h>
// #include <CGAL/AABB_traits.h>
diff --git a/src/tools/SdfErrorCompare/main.cpp b/src/tools/SdfErrorCompare/main.cpp
index deef25f..9e402c4 100644
--- a/src/tools/SdfErrorCompare/main.cpp
+++ b/src/tools/SdfErrorCompare/main.cpp
@@ -23,7 +23,7 @@ using namespace sdflib;
// #define TEST_OPENVDB
#ifdef TEST_ICG
-#include <InteractiveComputerGraphics/TriangleMeshDistance.h>
+#include <tmd/TriangleMeshDistance.h>
#endif
#ifdef TEST_CGAL
#include <CGAL/Simple_cartesian.h>
diff --git a/src/tools/SdfLibUnity/SdfExportFunc.cpp b/src/tools/SdfLibUnity/SdfExportFunc.cpp
index ff4e017..7e06ada 100644
--- a/src/tools/SdfLibUnity/SdfExportFunc.cpp
+++ b/src/tools/SdfLibUnity/SdfExportFunc.cpp
@@ -1,7 +1,7 @@
#include "SdfExportFunc.h"
#include "spdlog/sinks/rotating_file_sink.h"
-#include <InteractiveComputerGraphics/TriangleMeshDistance.h>
+#include <tmd/TriangleMeshDistance.h>
using namespace sdflib;
diff --git a/src/tools/SdfOffsets/main.cpp b/src/tools/SdfOffsets/main.cpp
index b6769d7..07f137b 100644
--- a/src/tools/SdfOffsets/main.cpp
+++ b/src/tools/SdfOffsets/main.cpp
@@ -9,7 +9,7 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
-#include <InteractiveComputerGraphics/TriangleMeshDistance.h>
+#include <tmd/TriangleMeshDistance.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/Complex_2_in_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>

View File

@ -20,10 +20,8 @@ buildPythonPackage rec {
};
# Patch path to GLFW shared object
patches = [ ./search-path.patch ];
postPatch = ''
substituteInPlace glfw/library.py --replace "@GLFW@" '${glfw3}/lib'
substituteInPlace glfw/library.py --replace "_get_library_search_paths()," "[ '${glfw3}/lib' ],"
'';
propagatedBuildInputs = [

View File

@ -1,11 +0,0 @@
diff --git a/glfw/library.py b/glfw/library.py
index 20387e1..9bdd62a 100644
--- a/glfw/library.py
+++ b/glfw/library.py
@@ -189,5 +189,4 @@ elif sys.platform == 'win32':
except OSError:
pass
else:
- glfw = _load_library(['glfw', 'glfw3'], ['.so', '.dylib'],
- _get_library_search_paths(), _glfw_get_version)
+ glfw = _load_library(['glfw', 'glfw3'], ['.so', '.dylib'], ['@GLFW@'], _glfw_get_version)

View File

@ -0,0 +1,70 @@
{ buildPythonPackage
, cmake
, fetchPypi
, glfw
, lib
, mujoco
, numpy
, perl
, pkgs
, pybind11
, python
, setuptools
}:
buildPythonPackage rec {
pname = "mujoco";
version = "3.0.1";
pyproject = true;
# We do not fetch from the repository because the PyPi tarball is
# impurely build via
# <https://github.com/google-deepmind/mujoco/blob/main/python/make_sdist.sh>
# in the project's CI.
src = fetchPypi {
inherit pname version;
hash = "sha256-pftecOk4q19qKBHs9hBBVenI+SgJg9VT7vc6NKuiY0s=";
};
nativeBuildInputs = [ cmake setuptools ];
dontUseCmakeConfigure = true;
buildInputs = [ mujoco pybind11 ];
propagatedBuildInputs = [ glfw numpy ];
pythonImportsCheck = [ "${pname}" ];
env.MUJOCO_PATH = "${mujoco}";
env.MUJOCO_PLUGIN_PATH = "${mujoco}/lib";
env.MUJOCO_CMAKE_ARGS = "-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON";
preConfigure =
# Use system packages for pybind
''
${perl}/bin/perl -0777 -i -pe "s/(findorfetch\(.{3}USE_SYSTEM_PACKAGE.{3})(OFF)(.{3}PACKAGE_NAME.{3}pybind11.*\))/\1ON\3/gms" mujoco/CMakeLists.txt
'' +
# Use non-system eigen3, lodepng, abseil: Remove mirror info and prefill
# dependency directory. $build from setuptools.
(let
# E.g. 3.11.2 -> "311"
pythonVersionMajorMinor = with lib.versions;
"${major python.pythonVersion}${minor python.pythonVersion}";
in ''
${perl}/bin/perl -0777 -i -pe "s/GIT_REPO\n.*\n.*GIT_TAG\n.*\n//gm" mujoco/CMakeLists.txt
${perl}/bin/perl -0777 -i -pe "s/(FetchContent_Declare\(\n.*lodepng\n.*)(GIT_REPO.*\n.*GIT_TAG.*\n)(.*\))/\1\3/gm" mujoco/simulate/CMakeLists.txt
build="/build/${pname}-${version}/build/temp.linux-x86_64-cpython-${pythonVersionMajorMinor}/"
mkdir -p $build/_deps
ln -s ${mujoco.pin.lodepng} $build/_deps/lodepng-src
ln -s ${mujoco.pin.eigen3} $build/_deps/eigen-src
ln -s ${mujoco.pin.abseil-cpp} $build/_deps/abseil-cpp-src
'');
meta = with lib; {
description =
"Python bindings for MuJoCo: a general purpose physics simulator.";
homepage = "https://mujoco.org/";
license = licenses.asl20;
maintainers = with maintainers; [ tmplt ];
};
}

View File

@ -7210,6 +7210,10 @@ self: super: with self; {
mutf8 = callPackage ../development/python-modules/mutf8 { };
mujoco = callPackage ../development/python-modules/mujoco {
inherit (pkgs) mujoco;
};
mujson = callPackage ../development/python-modules/mujson { };
mwcli = callPackage ../development/python-modules/mwcli { };