Add separate build step for OpenUSD to third_party_deps.

This will fetch and call the build_usd.py build helper for OpenUSD and build within the MuJoCo _deps folder. Simplifying the build process for MuJoCo with USD. Users can still provide their own USD build, but must now do so via pxr_DIR.

PiperOrigin-RevId: 846735578
Change-Id: I0da7eb2da6465e2d518084340e762bf370adb6d5
This commit is contained in:
Sam Haves
2025-12-19 07:59:17 -08:00
committed by Copybara-Service
parent 76e0a78b32
commit 9e150fe82c
6 changed files with 178 additions and 109 deletions
+38
View File
@@ -0,0 +1,38 @@
# Copyright 2025 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Find OpenUSD package. The user can either provide pxr_DIR to use their own
# OpenUSD installation or they can build external_dependencies.
#
# We use QUIET here to provide a better error message when pxr is not found.
find_package(pxr
QUIET
HINTS "${CMAKE_BINARY_DIR}/_deps/openusd-build"
)
if(NOT pxr_FOUND)
message(FATAL_ERROR
"-----------------------------------------------------------\n"
"USD Configuration Error:\n${pxr_NOT_FOUND_MESSAGE}\n"
"If you have built USD yourself, provide -Dpxr_DIR=your_pxr_install_dir' \n"
"Otherwise you can build cmake/third_party_deps/openusd:\n"
"cd ~/mujoco\n"
"cmake -Bcmake/third_party_deps/openusd/build cmake/third_party_deps/openusd -DBUILD_USD=True\n"
"cmake --build cmake/third_party_deps/openusd/build\n"
"cmake -Bbuild -S. -DMUJOCO_WITH_USD=True\n"
"cmake --build build\n"
"cmake --install build"
"-----------------------------------------------------------"
)
endif()
@@ -0,0 +1,54 @@
# Copyright 2025 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION "3.16")
option(BUILD_USD OFF "Build OpenUSD")
project(openusd-dependency)
if (BUILD_USD)
include(ExternalProject)
set(DEPS_DIR ${CMAKE_BINARY_DIR}/../../../../build/_deps)
ExternalProject_Add(openusd
GIT_REPOSITORY https://github.com/PixarAnimationStudios/USD.git
GIT_TAG v25.11
PREFIX openusd
BUILD_IN_SOURCE 0
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
SOURCE_DIR ${DEPS_DIR}/openusd-src
BINARY_DIR ${DEPS_DIR}/openusd-build
INSTALL_DIR ${DEPS_DIR}/openusd-build
BUILD_COMMAND python3 ${DEPS_DIR}/openusd-src/build_scripts/build_usd.py
--build-shared
--no-examples
--no-tools
--no-ptex
--no-prman
--no-openimageio
--no-opencolorio
--no-alembic
--no-draco
--no-materialx
--no-tutorials
--no-tests
--no-docs
--no-imaging
--no-python
--no-usdValidation
<INSTALL_DIR>
)
endif()