Merge pull request #3252 from devshahofficial:devshahofficial/studio-filament-source-build
PiperOrigin-RevId: 958356099 Change-Id: If4e68babdc6c68d7dd05ced7197a1869db4a0625
This commit is contained in:
@@ -13,61 +13,65 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_library(dear_imgui STATIC)
|
add_library(dear_imgui STATIC)
|
||||||
|
set(MUJOCO_DEAR_IMGUI_SOURCE_DIR "${dear_imgui_SOURCE_DIR}" CACHE INTERNAL "")
|
||||||
target_include_directories(dear_imgui
|
target_include_directories(dear_imgui
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
target_sources(dear_imgui
|
target_sources(dear_imgui
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}/imgui.h
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui.h
|
||||||
${dear_imgui_SOURCE_DIR}/imgui.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui.cpp
|
||||||
${dear_imgui_SOURCE_DIR}/imgui_internal.h
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_internal.h
|
||||||
${dear_imgui_SOURCE_DIR}/imgui_draw.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_draw.cpp
|
||||||
${dear_imgui_SOURCE_DIR}/imgui_tables.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_tables.cpp
|
||||||
${dear_imgui_SOURCE_DIR}/imgui_widgets.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_widgets.cpp
|
||||||
${dear_imgui_SOURCE_DIR}/imgui_demo.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_demo.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# SDL2 backend
|
function(mujoco_add_dear_imgui_sdl2_backend)
|
||||||
# TODO: I don't know how to correctly check for dependencies in cmake. This
|
if(TARGET dear_imgui_SDL2 OR NOT TARGET SDL2::SDL2-static)
|
||||||
# assumes that SDL2 is pulled in _before_ dear_imgui, but that seems fragile.
|
return()
|
||||||
# For now, we'll just assume SDL2 is available as dear_imgui is only being used
|
endif()
|
||||||
# in contexts which depend on SDL2.
|
|
||||||
#if(TARGET SDL2)
|
|
||||||
add_library(dear_imgui_SDL2 STATIC)
|
add_library(dear_imgui_SDL2 STATIC)
|
||||||
target_include_directories(dear_imgui_SDL2
|
target_include_directories(dear_imgui_SDL2
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
target_sources(dear_imgui_SDL2
|
target_sources(dear_imgui_SDL2
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(dear_imgui_SDL2
|
target_link_libraries(dear_imgui_SDL2
|
||||||
SDL2::SDL2-static
|
SDL2::SDL2-static
|
||||||
)
|
)
|
||||||
#endif()
|
endfunction()
|
||||||
|
|
||||||
|
# SDL2 backend. Filament uses base dear_imgui without SDL2; platform calls this
|
||||||
|
# helper again after SDL2 is pulled in.
|
||||||
|
mujoco_add_dear_imgui_sdl2_backend()
|
||||||
|
|
||||||
# OpenGL3 backend
|
# OpenGL3 backend
|
||||||
add_library(dear_imgui_OpenGL3 STATIC)
|
add_library(dear_imgui_OpenGL3 STATIC)
|
||||||
target_include_directories(dear_imgui_OpenGL3
|
target_include_directories(dear_imgui_OpenGL3
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
target_sources(dear_imgui_OpenGL3
|
target_sources(dear_imgui_OpenGL3
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.h
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.h
|
||||||
${dear_imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# stdlib
|
# stdlib
|
||||||
add_library(dear_imgui_stdlib STATIC)
|
add_library(dear_imgui_stdlib STATIC)
|
||||||
target_include_directories(dear_imgui_stdlib
|
target_include_directories(dear_imgui_stdlib
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
target_sources(dear_imgui_stdlib
|
target_sources(dear_imgui_stdlib
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${dear_imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.h
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/misc/cpp/imgui_stdlib.h
|
||||||
${dear_imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
|
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -52,6 +52,18 @@ set(FILAMENT_PATCH_COMMAND
|
|||||||
git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/filament-allow-clang-windows.patch
|
git --git-dir=. -c core.autocrlf=false -c core.whitespace=cr-at-eol apply --verbose --whitespace=fix --ignore-space-change ${mujoco_SOURCE_DIR}/cmake/filament-allow-clang-windows.patch
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# MuJoCo fetches Abseil before Filament is configured. Filament's
|
||||||
|
# FILAMENT_USE_EXTERNAL_ABSL path calls find_package(absl), which can otherwise
|
||||||
|
# discover an unrelated package-manager Abseil config and collide with the
|
||||||
|
# targets already created by MuJoCo's fetched Abseil.
|
||||||
|
if(DEFINED CMAKE_DISABLE_FIND_PACKAGE_absl)
|
||||||
|
set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED TRUE)
|
||||||
|
set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD "${CMAKE_DISABLE_FIND_PACKAGE_absl}")
|
||||||
|
else()
|
||||||
|
set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED FALSE)
|
||||||
|
endif()
|
||||||
|
set(CMAKE_DISABLE_FIND_PACKAGE_absl TRUE)
|
||||||
|
|
||||||
fetchpackage(
|
fetchpackage(
|
||||||
PACKAGE_NAME filament
|
PACKAGE_NAME filament
|
||||||
GIT_REPO https://github.com/google/filament.git
|
GIT_REPO https://github.com/google/filament.git
|
||||||
@@ -59,5 +71,13 @@ fetchpackage(
|
|||||||
PATCH_COMMAND ${FILAMENT_PATCH_COMMAND}
|
PATCH_COMMAND ${FILAMENT_PATCH_COMMAND}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED)
|
||||||
|
set(CMAKE_DISABLE_FIND_PACKAGE_absl "${MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD}")
|
||||||
|
else()
|
||||||
|
unset(CMAKE_DISABLE_FIND_PACKAGE_absl)
|
||||||
|
endif()
|
||||||
|
unset(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED)
|
||||||
|
unset(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD)
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD})
|
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD})
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}")
|
||||||
|
|||||||
@@ -98,9 +98,10 @@ target_include_directories(${MUJOCO_PLATFORM_TARGET_NAME}
|
|||||||
${PROJECT_SOURCE_DIR}/src
|
${PROJECT_SOURCE_DIR}/src
|
||||||
)
|
)
|
||||||
|
|
||||||
include(third_party_deps/dear_imgui)
|
|
||||||
include(third_party_deps/implot)
|
|
||||||
include(third_party_deps/sdl2)
|
include(third_party_deps/sdl2)
|
||||||
|
include(third_party_deps/dear_imgui)
|
||||||
|
mujoco_add_dear_imgui_sdl2_backend()
|
||||||
|
include(third_party_deps/implot)
|
||||||
include(third_party_deps/libwebp)
|
include(third_party_deps/libwebp)
|
||||||
|
|
||||||
target_link_libraries(${MUJOCO_PLATFORM_TARGET_NAME}
|
target_link_libraries(${MUJOCO_PLATFORM_TARGET_NAME}
|
||||||
|
|||||||
@@ -17,6 +17,47 @@ bash build.sh
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> For now [`build.sh`](build.sh) script works on windows in a git bash shell.
|
> For now [`build.sh`](build.sh) script works on windows in a git bash shell.
|
||||||
|
|
||||||
|
To keep Studio build artifacts separate from other MuJoCo builds, you can also
|
||||||
|
configure an isolated build directory manually:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -B build-studio \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DUSE_STATIC_LIBCXX=OFF \
|
||||||
|
-DBUILD_SHARED_LIB=OFF \
|
||||||
|
-DMUJOCO_USE_FILAMENT=ON \
|
||||||
|
-DMUJOCO_BUILD_EXAMPLES=OFF \
|
||||||
|
-DMUJOCO_BUILD_SIMULATE=OFF \
|
||||||
|
-DMUJOCO_BUILD_TESTS=OFF \
|
||||||
|
-DMUJOCO_TEST_PYTHON_UTIL=OFF \
|
||||||
|
-DMUJOCO_WITH_USD=OFF \
|
||||||
|
-DMUJOCO_BUILD_STUDIO=ON \
|
||||||
|
-DFILAMENT_SKIP_SAMPLES=ON \
|
||||||
|
-DCMAKE_CXX_FLAGS=-Wno-error=deprecated-declarations \
|
||||||
|
-DFILAMENT_SHORTEN_MSVC_COMPILATION=OFF
|
||||||
|
cmake --build build-studio --config Release --target mujoco_studio --parallel
|
||||||
|
```
|
||||||
|
|
||||||
|
Run `mujoco_studio` from the build output directory so it can find the copied
|
||||||
|
font and Filament assets:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd build-studio/bin
|
||||||
|
./mujoco_studio --gfx=opengl
|
||||||
|
```
|
||||||
|
|
||||||
|
On macOS, Studio defaults to Filament OpenGL. The OpenGL implementation may be
|
||||||
|
provided by Apple's Metal-backed OpenGL layer, so runtime logs can mention both
|
||||||
|
OpenGL and Metal/Apple GPU details.
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
If configure fails while resolving Filament dependencies, check whether CMake is
|
||||||
|
finding package-manager CMake configs from environments such as Anaconda. In
|
||||||
|
particular, an unrelated `abslConfig.cmake` can conflict with MuJoCo's fetched
|
||||||
|
Abseil targets. Remove that prefix from `CMAKE_PREFIX_PATH`, or configure with
|
||||||
|
`CMAKE_IGNORE_PREFIX_PATH` pointing at the conflicting environment prefix.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
The [`build.sh`](build.sh) script is intended to get you up and running quickly.
|
The [`build.sh`](build.sh) script is intended to get you up and running quickly.
|
||||||
|
|||||||
Reference in New Issue
Block a user