Include obj and stl decoder plugins as sources in CMake builds.
This removes the need to load these decoders via mj_loadAllPluginLibraries when using MuJoCo built with CMake. Other plugins are unchanged. PiperOrigin-RevId: 897114719 Change-Id: Iee914cc5e05798186f384a67901f1cf86bc2f887
This commit is contained in:
committed by
Copybara-Service
parent
81720071b8
commit
a744b366fb
@@ -107,8 +107,6 @@ copy_plugins_posix() {
|
||||
mkdir -p ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp lib/libactuator.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp lib/libelasticity.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp lib/libobj_decoder.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp lib/libstl_decoder.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp lib/libsensor.* ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp lib/libsdf_plugin.* ${TMPDIR}/mujoco_install/mujoco_plugin
|
||||
}
|
||||
@@ -119,8 +117,6 @@ copy_plugins_window() {
|
||||
mkdir -p ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp bin/Release/actuator.dll ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp bin/Release/elasticity.dll ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp bin/Release/obj_decoder.dll ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp bin/Release/stl_decoder.dll ${TMPDIR}/mujoco_install/mujoco_plugin &&
|
||||
cp bin/Release/sensor.dll ${TMPDIR}/mujoco_install/mujoco_plugin
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ if(NOT EMSCRIPTEN)
|
||||
endif()
|
||||
add_subdirectory(plugin/obj_decoder)
|
||||
add_subdirectory(plugin/stl_decoder)
|
||||
|
||||
add_subdirectory(src/engine)
|
||||
add_subdirectory(src/user)
|
||||
add_subdirectory(src/xml)
|
||||
|
||||
@@ -38,7 +38,6 @@ function(add_mujoco_shell_test TEST_NAME TARGET_BINARY)
|
||||
"CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}"
|
||||
"TARGET_BINARY=$<TARGET_FILE:${TARGET_BINARY}>"
|
||||
"TEST_TMPDIR=${TEST_TMPDIR}"
|
||||
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
|
||||
)
|
||||
if(WIN32)
|
||||
# Define the directory containing the mujoco DLL library so that it can be added to the PATH.
|
||||
|
||||
@@ -40,6 +40,8 @@ General
|
||||
(previously the scalar), and subsequent elements are the higher-order :ref:`polynomial<gePolynomial>` coefficients.
|
||||
|
||||
**Migration:** Replace assignments like ``joint.stiffness = val`` with ``joint.stiffness[0] = val``.
|
||||
- ``.obj`` and ``.stl`` decoders are now included as source when building MuJoCo with CMake. This fixes the
|
||||
behaviour from the previous release where it required downstream code to load these plugins explicitly.
|
||||
|
||||
- The ``vertcollide`` field in :ref:`mjsFlex` has been removed. It is no longer required since
|
||||
:doc:`MuJoCo Warp <mjwarp/index>` supports native flex collisions.
|
||||
|
||||
@@ -12,48 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
add_library(obj_decoder OBJECT obj_decoder.cc)
|
||||
else()
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
add_library(obj_decoder SHARED obj_decoder.cc)
|
||||
endif()
|
||||
|
||||
target_include_directories(obj_decoder PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
target_compile_definitions(mujoco PRIVATE TINYOBJLOADER_IMPLEMENTATION)
|
||||
target_sources(mujoco PRIVATE
|
||||
obj_decoder.cc
|
||||
)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
target_link_libraries(obj_decoder PRIVATE
|
||||
tinyobjloader
|
||||
)
|
||||
else()
|
||||
target_link_libraries(obj_decoder PRIVATE
|
||||
mujoco
|
||||
tinyobjloader
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(obj_decoder PRIVATE TINYOBJLOADER_IMPLEMENTATION)
|
||||
|
||||
target_compile_options(obj_decoder PRIVATE
|
||||
${AVX_COMPILE_OPTIONS}
|
||||
${MUJOCO_MACOS_COMPILE_OPTIONS}
|
||||
${EXTRA_COMPILE_OPTIONS}
|
||||
${MUJOCO_CXX_FLAGS}
|
||||
)
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
target_link_options(obj_decoder PRIVATE
|
||||
${MUJOCO_MACOS_LINK_OPTIONS}
|
||||
${EXTRA_LINK_OPTIONS}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS obj_decoder
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}/mujoco_plugin"
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(mujoco PRIVATE tinyobjloader)
|
||||
|
||||
@@ -12,43 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
add_library(stl_decoder OBJECT stl_decoder.cc)
|
||||
else()
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
add_library(stl_decoder SHARED stl_decoder.cc)
|
||||
endif()
|
||||
|
||||
target_include_directories(stl_decoder PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
target_sources(mujoco PRIVATE
|
||||
stl_decoder.cc
|
||||
)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
target_link_libraries(stl_decoder PRIVATE)
|
||||
else()
|
||||
target_link_libraries(stl_decoder PRIVATE
|
||||
mujoco
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_options(stl_decoder PRIVATE
|
||||
${AVX_COMPILE_OPTIONS}
|
||||
${MUJOCO_MACOS_COMPILE_OPTIONS}
|
||||
${EXTRA_COMPILE_OPTIONS}
|
||||
${MUJOCO_CXX_FLAGS}
|
||||
)
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
target_link_options(stl_decoder PRIVATE
|
||||
${MUJOCO_MACOS_LINK_OPTIONS}
|
||||
${EXTRA_LINK_OPTIONS}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS stl_decoder
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}/mujoco_plugin"
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -187,12 +187,6 @@ int main(int argc, char** argv) {
|
||||
nthread = mjMAX(1, mjMIN(maxthread, nthread));
|
||||
npoolthread = mjMAX(1, mjMIN(maxthread, npoolthread));
|
||||
|
||||
// load plugins from MUJOCO_PLUGIN_DIR if set
|
||||
const char* plugin_dir = std::getenv("MUJOCO_PLUGIN_DIR");
|
||||
if (plugin_dir) {
|
||||
mj_loadAllPluginLibraries(plugin_dir, nullptr);
|
||||
}
|
||||
|
||||
// get filename, determine file type
|
||||
std::string filename(argv[1]);
|
||||
bool binary = (filename.find(".mjb") != std::string::npos); // NOLINT
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
|
||||
mujoco_test(
|
||||
user_model_test
|
||||
PROPERTIES
|
||||
ENVIRONMENT
|
||||
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
|
||||
ADDITIONAL_LINK_LIBRARIES absl::str_format
|
||||
)
|
||||
|
||||
@@ -31,16 +28,10 @@ mujoco_test(
|
||||
|
||||
mujoco_test(
|
||||
user_flex_test
|
||||
PROPERTIES
|
||||
ENVIRONMENT
|
||||
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
|
||||
)
|
||||
|
||||
mujoco_test(
|
||||
user_mesh_test
|
||||
PROPERTIES
|
||||
ENVIRONMENT
|
||||
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
|
||||
ADDITIONAL_LINK_LIBRARIES absl::str_format
|
||||
)
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@ mujoco_test(xml_api_test)
|
||||
|
||||
mujoco_test(
|
||||
xml_native_reader_test
|
||||
PROPERTIES
|
||||
ENVIRONMENT
|
||||
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
|
||||
)
|
||||
|
||||
mujoco_test(xml_utils_test)
|
||||
|
||||
+6
-1
@@ -67,6 +67,11 @@ set_target_properties(mujoco_wasm PROPERTIES
|
||||
OUTPUT_NAME "mujoco"
|
||||
)
|
||||
|
||||
target_link_libraries(mujoco_wasm ccd lodepng mujoco tinyxml2 qhullstatic_r obj_decoder stl_decoder)
|
||||
# Link the mujoco library as a whole archive to avoid losing plugin
|
||||
# registration such as obj_decoder and stl_decoder.
|
||||
target_link_libraries(mujoco_wasm PRIVATE
|
||||
-Wl,--whole-archive mujoco -Wl,--no-whole-archive
|
||||
ccd lodepng tinyxml2 qhullstatic_r
|
||||
)
|
||||
|
||||
install(TARGETS mujoco_wasm DESTINATION ${DIVISIBLE_INSTALL_BIN_DIR})
|
||||
|
||||
@@ -53,6 +53,11 @@ add_executable(mujoco_wasm_benchmark ${MUJOCO_WASM_FILES})
|
||||
|
||||
set_target_properties(mujoco_wasm_benchmark PROPERTIES LINK_FLAGS "${EMCC_LINKER_FLAGS_STR}")
|
||||
|
||||
target_link_libraries(mujoco_wasm_benchmark ccd lodepng mujoco tinyxml2 qhullstatic_r obj_decoder stl_decoder)
|
||||
# Link the mujoco library as a whole archive to avoid losing plugin
|
||||
# registration such as obj_decoder and stl_decoder.
|
||||
target_link_libraries(mujoco_wasm_benchmark PRIVATE
|
||||
-Wl,--whole-archive mujoco -Wl,--no-whole-archive
|
||||
ccd lodepng tinyxml2 qhullstatic_r
|
||||
)
|
||||
|
||||
install(TARGETS mujoco_wasm_benchmark DESTINATION ${DIVISIBLE_INSTALL_BIN_DIR})
|
||||
|
||||
Reference in New Issue
Block a user