From 81f9e9b4e4d9d32946e1755ee86bb148dde5b011 Mon Sep 17 00:00:00 2001 From: indigo Date: Thu, 18 Jun 2026 23:22:52 +0800 Subject: [PATCH] CMake: add hdArnold plugin detection and deployment Adds HDARNOLD_ROOT and ARNOLD_LOCATION cache variables to detect and deploy the arnold-usd Hydra render delegate (hdArnold.dll, ndrArnold.dll) built from arnold-usd Arnold-7.4.0.0 against MtoA 5.5.0. DLLs land in usd/ alongside their plugInfo metadata dirs so LibraryPath ../hdArnold.dll resolves correctly. ai.dll is copied to the exe root for Windows DLL search resolution. Co-Authored-By: Claude Sonnet 4.6 --- CMakeLists.txt | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34e67cd..2bf86f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,28 @@ else() message(STATUS "hdEmbree: NOT found — set HDEMBREE_USD_ROOT to a USD build with PXR_ENABLE_EMBREE_PLUGIN=ON") endif() +# ── hdArnold detection ─────────────────────────────────────────────────────── +# HDARNOLD_ROOT: CMAKE_INSTALL_PREFIX used when building arnold-usd +set(HDARNOLD_ROOT "" CACHE PATH "arnold-usd install directory (the one containing plugin/hdArnold.dll)") +# ARNOLD_LOCATION: Arnold SDK root (MtoA dir) — needed to deploy ai.dll +set(ARNOLD_LOCATION "" CACHE PATH "Arnold SDK root (e.g. C:/Autodesk/mtoa/5.5.0/2026) for ai.dll deployment") + +if(HDARNOLD_ROOT AND EXISTS "${HDARNOLD_ROOT}/plugin/hdArnold.dll") + set(OPENUSD_HAS_ARNOLD TRUE) + set(HDARNOLD_DLL "${HDARNOLD_ROOT}/plugin/hdArnold.dll") + set(NDRARNOLD_DLL "${HDARNOLD_ROOT}/plugin/ndrArnold.dll") + set(HDARNOLD_PLUGIN_DIR "${HDARNOLD_ROOT}/plugin/hdArnold") + set(NDRARNOLD_PLUGIN_DIR "${HDARNOLD_ROOT}/plugin/ndrArnold") + if(ARNOLD_LOCATION AND EXISTS "${ARNOLD_LOCATION}/bin/ai.dll") + set(ARNOLD_AI_DLL "${ARNOLD_LOCATION}/bin/ai.dll") + else() + set(ARNOLD_AI_DLL "") + endif() +else() + set(OPENUSD_HAS_ARNOLD FALSE) + message(STATUS "hdArnold: NOT found — set HDARNOLD_ROOT to the arnold-usd install dir and ARNOLD_LOCATION to the MtoA root") +endif() + # Collect source files file(GLOB_RECURSE CORE_SOURCES "src/core/*.cpp") file(GLOB_RECURSE UI_SOURCES "src/ui/*.cpp") @@ -131,6 +153,33 @@ if(WIN32) ) endif() endif() + + if(OPENUSD_HAS_ARNOLD) + add_custom_command(TARGET UsdLayerManager POST_BUILD + # DLLs go in usd/ alongside their metadata dirs (LibraryPath "../hdArnold.dll") + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${HDARNOLD_DLL}" + "$/usd/hdArnold.dll" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${NDRARNOLD_DLL}" + "$/usd/ndrArnold.dll" + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${HDARNOLD_PLUGIN_DIR}" + "$/usd/hdArnold" + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${NDRARNOLD_PLUGIN_DIR}" + "$/usd/ndrArnold" + COMMENT "Copying hdArnold plugin..." + ) + if(ARNOLD_AI_DLL) + add_custom_command(TARGET UsdLayerManager POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${ARNOLD_AI_DLL}" + "$" + COMMENT "Copying Arnold runtime ai.dll..." + ) + endif() + endif() endif() # Compiler warnings @@ -189,6 +238,27 @@ if(OPENUSD_HAS_EMBREE) endif() endif() +if(OPENUSD_HAS_ARNOLD) + install(FILES "${HDARNOLD_DLL}" "${NDRARNOLD_DLL}" + DESTINATION bin/usd + OPTIONAL + ) + install(DIRECTORY "${HDARNOLD_PLUGIN_DIR}" + DESTINATION bin/usd + OPTIONAL + ) + install(DIRECTORY "${NDRARNOLD_PLUGIN_DIR}" + DESTINATION bin/usd + OPTIONAL + ) + if(ARNOLD_AI_DLL) + install(FILES "${ARNOLD_AI_DLL}" + DESTINATION bin + OPTIONAL + ) + endif() +endif() + # Install Python runtime DLLs required by OpenUSD. install(FILES "$ENV{LOCALAPPDATA}/Programs/Python/Python312/python312.dll" @@ -245,6 +315,14 @@ if(OPENUSD_HAS_EMBREE AND EMBREE_DLLS) elseif(OPENUSD_HAS_EMBREE) message(WARNING "hdEmbree found but no Embree DLLs detected — set EMBREE_LOCATION to the Embree SDK bin/ dir or check HDEMBREE_USD_ROOT/bin") endif() +message(STATUS "hdArnold support: ${OPENUSD_HAS_ARNOLD}") +if(OPENUSD_HAS_ARNOLD) + message(STATUS "hdArnold DLL: ${HDARNOLD_DLL}") + message(STATUS "Arnold ai.dll: ${ARNOLD_AI_DLL}") + if(NOT ARNOLD_AI_DLL) + message(WARNING "hdArnold found but ai.dll not located — set ARNOLD_LOCATION to the MtoA root (e.g. C:/Autodesk/mtoa/5.5.0/2026)") + endif() +endif() message(STATUS "=======================================") message(STATUS "")