diff --git a/CMakeLists.txt b/CMakeLists.txt index 1106d5b..747404a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,26 @@ find_package(OpenUSD REQUIRED) find_package(Imgui REQUIRED) find_package(Glad REQUIRED) +# User-supplied Embree SDK bin/ dir if Embree DLLs are not bundled inside USD lib/. +set(EMBREE_LOCATION "" CACHE PATH "Embree SDK bin/ directory (leave empty if bundled in USD lib/)") + +# ── hdEmbree detection ─────────────────────────────────────────────────────── +set(HDEMBREE_PLUGIN_DIR "${OpenUSD_ROOT_DIR}/plugin/usd/hdEmbree") +if(EXISTS "${HDEMBREE_PLUGIN_DIR}") + set(OPENUSD_HAS_EMBREE TRUE) + if(EMBREE_LOCATION AND EXISTS "${EMBREE_LOCATION}") + set(_embree_dll_dir "${EMBREE_LOCATION}") + else() + set(_embree_dll_dir "${OpenUSD_ROOT_DIR}/lib") + endif() + file(GLOB EMBREE_DLLS + "${_embree_dll_dir}/embree*.dll" + "${_embree_dll_dir}/tbb12.dll") +else() + set(OPENUSD_HAS_EMBREE FALSE) + message(STATUS "hdEmbree: NOT found — rebuild USD with PXR_ENABLE_EMBREE_PLUGIN=ON to enable") +endif() + # Collect source files file(GLOB_RECURSE CORE_SOURCES "src/core/*.cpp") file(GLOB_RECURSE UI_SOURCES "src/ui/*.cpp") @@ -78,6 +98,15 @@ if(WIN32) "$" COMMENT "Copying runtime DLLs and USD plugins..." ) + + if(OPENUSD_HAS_EMBREE AND EMBREE_DLLS) + add_custom_command(TARGET UsdLayerManager POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${EMBREE_DLLS} + "$" + COMMENT "Copying Embree runtime DLLs..." + ) + endif() endif() # Compiler warnings @@ -118,6 +147,19 @@ install(FILES ${OpenUSD_ROOT_DIR}/plugin/usd/hdStorm.dll DESTINATION bin ) +if(OPENUSD_HAS_EMBREE) + install(FILES "${HDEMBREE_PLUGIN_DIR}/hdEmbree.dll" + DESTINATION bin + OPTIONAL + ) + if(EMBREE_DLLS) + install(FILES ${EMBREE_DLLS} + DESTINATION bin + OPTIONAL + ) + endif() +endif() + # Install Python runtime DLLs required by OpenUSD. install(FILES "$ENV{LOCALAPPDATA}/Programs/Python/Python312/python312.dll" @@ -168,6 +210,12 @@ message(STATUS "ImGui found: ${Imgui_FOUND}") message(STATUS "OpenGL found: ${OPENGL_FOUND}") message(STATUS "Glad found: ${Glad_FOUND}") message(STATUS "Build tests: ${BUILD_TESTS}") +message(STATUS "hdEmbree support: ${OPENUSD_HAS_EMBREE}") +if(OPENUSD_HAS_EMBREE AND EMBREE_DLLS) + message(STATUS "Embree DLLs: ${EMBREE_DLLS}") +elseif(OPENUSD_HAS_EMBREE) + message(WARNING "hdEmbree found but no Embree DLLs detected — set EMBREE_LOCATION to the Embree SDK bin/ dir") +endif() message(STATUS "=======================================") message(STATUS "")