Skip to content

Commit

Permalink
Refine MaterialX render module build configuration (#1970)
Browse files Browse the repository at this point in the history
Add more refined control over building MaterialX render modules. Specifically USD only needs the core render module in some build configurations (iOS).

Also add a guard to ensure that MaterialXGenGlsl is built if MaterialXGenMsl is built, because of the dependency in the data library.  USD uses `MaterialX::GlslShaderGenerator::TARGET` to locate those resources.
  • Loading branch information
ld-kerley authored Dec 20, 2024
1 parent af74b61 commit 1d6f148
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ option(MATERIALX_BUILD_GEN_OSL "Build the OSL shader generator back-end." ON)
option(MATERIALX_BUILD_GEN_MDL "Build the MDL shader generator back-end." ON)
option(MATERIALX_BUILD_GEN_MSL "Build the MSL shader generator back-end." ON)
option(MATERIALX_BUILD_RENDER "Build the MaterialX Render modules." ON)
option(MATERIALX_BUILD_RENDER_PLATFORMS "Build platform-specific render modules for each shader generator." ON)
option(MATERIALX_BUILD_OIIO "Build OpenImageIO support for MaterialXRender." OFF)
option(MATERIALX_BUILD_TESTS "Build unit tests." OFF)
option(MATERIALX_BUILD_BENCHMARK_TESTS "Build benchmark tests." OFF)
Expand Down Expand Up @@ -104,6 +105,11 @@ if (MATERIALX_BUILD_JS)
set(MATERIALX_BUILD_TESTS OFF)
endif()

if(MATERIALX_BUILD_GEN_MSL)
# All hardware shading languages currently depend on the GLSL shader generator.
set(MATERIALX_BUILD_GEN_GLSL ON)
endif()

set(MATERIALX_PYTHON_VERSION "" CACHE STRING
"Python version to be used in building the MaterialX Python package (e.g. '3.9').")
set(MATERIALX_PYTHON_EXECUTABLE "" CACHE FILEPATH
Expand Down Expand Up @@ -160,6 +166,7 @@ mark_as_advanced(MATERIALX_BUILD_GEN_OSL)
mark_as_advanced(MATERIALX_BUILD_GEN_MDL)
mark_as_advanced(MATERIALX_BUILD_GEN_MSL)
mark_as_advanced(MATERIALX_BUILD_RENDER)
mark_as_advanced(MATERIALX_BUILD_RENDER_PLATFORMS)
mark_as_advanced(MATERIALX_BUILD_OIIO)
mark_as_advanced(MATERIALX_BUILD_BENCHMARK_TESTS)
mark_as_advanced(MATERIALX_BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -465,15 +472,22 @@ endif()
# Add rendering and viewer subdirectories
if(MATERIALX_BUILD_RENDER)
add_subdirectory(source/MaterialXRender)
add_subdirectory(source/MaterialXRenderHw)
if (MATERIALX_BUILD_GEN_GLSL)
add_subdirectory(source/MaterialXRenderGlsl)
endif()
if (APPLE AND MATERIALX_BUILD_GEN_MSL)
add_subdirectory(source/MaterialXRenderMsl)
endif()
if (MATERIALX_BUILD_GEN_OSL)
add_subdirectory(source/MaterialXRenderOsl)
if(MATERIALX_BUILD_RENDER_PLATFORMS)
set(MATERIALX_BUILD_RENDER_HW OFF)
if(MATERIALX_BUILD_GEN_GLSL AND NOT MATERIALX_BUILD_APPLE_EMBEDDED)
set(MATERIALX_BUILD_RENDER_HW ON)
add_subdirectory(source/MaterialXRenderGlsl)
endif()
if(MATERIALX_BUILD_GEN_MSL AND APPLE)
set(MATERIALX_BUILD_RENDER_HW ON)
add_subdirectory(source/MaterialXRenderMsl)
endif()
if(MATERIALX_BUILD_RENDER_HW)
add_subdirectory(source/MaterialXRenderHw)
endif()
if(MATERIALX_BUILD_GEN_OSL)
add_subdirectory(source/MaterialXRenderOsl)
endif()
endif()
if(MATERIALX_BUILD_VIEWER)
add_subdirectory(source/MaterialXView)
Expand Down

0 comments on commit 1d6f148

Please sign in to comment.