Add JavaScript bindings and WASM support
Co-authored-by: Matija Kecman <matijak@google.com> Co-authored-by: Sebastian Noreña Rendón <sebas.norena@creativa77.com.ar> Co-authored-by: Kyle Bayes <kylebayes@google.com> PiperOrigin-RevId: 826479070 Change-Id: I25acf36e6c20b091d8492e10798d028ae66f6733
This commit is contained in:
committed by
Copybara-Service
parent
57f7145806
commit
4086261714
@@ -109,7 +109,11 @@ if(NOT TARGET lodepng)
|
||||
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})
|
||||
if(NOT EMSCRIPTEN)
|
||||
target_include_directories(lodepng PUBLIC ${lodepng_SOURCE_DIR})
|
||||
else()
|
||||
target_include_directories(lodepng PUBLIC $<BUILD_INTERFACE:${lodepng_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -128,6 +132,10 @@ if(NOT TARGET marchingcubecpp)
|
||||
endif()
|
||||
|
||||
set(QHULL_ENABLE_TESTING OFF)
|
||||
# Patch changes in https://github.com/qhull/qhull/pull/173.patch
|
||||
set(QHULL_PATCH_COMMAND
|
||||
git apply --reject --whitespace=fix ${mujoco_SOURCE_DIR}/cmake/qhull-support-emscripten.patch
|
||||
)
|
||||
|
||||
findorfetch(
|
||||
USE_SYSTEM_PACKAGE
|
||||
@@ -143,6 +151,7 @@ findorfetch(
|
||||
TARGETS
|
||||
qhull
|
||||
EXCLUDE_FROM_ALL
|
||||
PATCH_COMMAND ${QHULL_PATCH_COMMAND}
|
||||
)
|
||||
# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
|
||||
# Add it to the target.
|
||||
@@ -222,6 +231,12 @@ endif()
|
||||
|
||||
set(ENABLE_DOUBLE_PRECISION ON)
|
||||
set(CCD_HIDE_ALL_SYMBOLS ON)
|
||||
|
||||
# Patch changes in https://github.com/danfis/libccd/pull/83.patch
|
||||
set(CCD_PATCH_COMMAND
|
||||
git apply --reject --whitespace=fix ${mujoco_SOURCE_DIR}/cmake/ccd-support-emscripten.patch
|
||||
)
|
||||
|
||||
# update cmake_minimum_required version for compatibility with newer version of cmake
|
||||
if(NOT DEFINED CMAKE_POLICY_VERSION_MINIMUM)
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM ${MUJOCO_CMAKE_MIN_REQ})
|
||||
@@ -241,6 +256,7 @@ findorfetch(
|
||||
TARGETS
|
||||
ccd
|
||||
EXCLUDE_FROM_ALL
|
||||
PATCH_COMMAND ${CCD_PATCH_COMMAND}
|
||||
)
|
||||
if(CMAKE_POLICY_VERSION_MINIMUM_LOCALLY_DEFINED)
|
||||
unset(CMAKE_POLICY_VERSION_MINIMUM)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 1407080..b4dea44 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -49,9 +49,14 @@ target_include_directories(ccd PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
|
||||
if(NOT WIN32)
|
||||
- find_library(LIBM_LIBRARY NAMES m)
|
||||
- if(NOT LIBM_LIBRARY)
|
||||
- message(FATAL_ERROR "Could NOT find required library LibM")
|
||||
+ if (EMSCRIPTEN)
|
||||
+ set(LIBM_LIBRARY "-lm")
|
||||
+ message("Subtitute LibM with emscripten -lm")
|
||||
+ else()
|
||||
+ find_library(LIBM_LIBRARY NAMES m)
|
||||
+ if(NOT LIBM_LIBRARY)
|
||||
+ message(FATAL_ERROR "Could NOT find required library LibM")
|
||||
+ endif()
|
||||
endif()
|
||||
target_link_libraries(ccd "${LIBM_LIBRARY}")
|
||||
if(BUILD_SHARED_LIBS)
|
||||
@@ -0,0 +1,30 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 0423820..c5295c1 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -360,6 +360,7 @@ if (NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
endif ()
|
||||
|
||||
+if (NOT EMSCRIPTEN)
|
||||
add_library(${qhull_SHAREDR} SHARED
|
||||
${libqhullr_SOURCES}
|
||||
src/libqhull_r/qhull_r-exports.def)
|
||||
@@ -420,7 +421,7 @@ set_target_properties(${qhull_SHAREDP} PROPERTIES
|
||||
if(UNIX)
|
||||
target_link_libraries(${qhull_SHAREDP} m)
|
||||
endif(UNIX)
|
||||
-
|
||||
+endif (NOT EMSCRIPTEN)
|
||||
# ---------------------------------------
|
||||
# Define static libraries qhullstatic (non-reentrant) and qhullstatic_r (reentrant)
|
||||
# ---------------------------------------
|
||||
@@ -475,7 +476,7 @@ if(NOT ${BUILD_STATIC_LIBS})
|
||||
set_target_properties(${qhull_STATICR} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
set_target_properties(${qhull_CPP} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
endif()
|
||||
-if(NOT ${BUILD_SHARED_LIBS})
|
||||
+if(NOT ${BUILD_SHARED_LIBS} AND NOT EMSCRIPTEN)
|
||||
set_target_properties(${qhull_SHARED} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
set_target_properties(${qhull_SHAREDR} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
set_target_properties(${qhull_SHAREDP} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
Reference in New Issue
Block a user