Skip to content

Commit

Permalink
Make TBB and OpenSubdiv dependencies relocatable
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaskenezlego committed Nov 30, 2024
1 parent 20acbba commit 7d09fed
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ endif()


# --TBB
find_package(TBB REQUIRED COMPONENTS tbb)
find_package(TBB CONFIG)
if(TBB_DIR)
# Found in CONFIG mode.
set(TBB_tbb_LIBRARY TBB::tbb)
else()
find_package(TBB REQUIRED COMPONENTS tbb)
endif()

add_definitions(${TBB_DEFINITIONS})

# --math
Expand Down Expand Up @@ -251,7 +258,13 @@ if (PXR_BUILD_IMAGING)
endif()
# --Opensubdiv
set(OPENSUBDIV_USE_GPU ${PXR_BUILD_GPU_SUPPORT})
find_package(OpenSubdiv 3 REQUIRED)
find_package(OpenSubdiv 3 CONFIG)
if(OpenSubdiv_DIR)
set(OPENSUBDIV_LIBRARIES OpenSubdiv::osdCPU OpenSubdiv::osdGPU)
set(OPENSUBDIV_OSDCPU_LIBRARY OpenSubdiv::osdCPU)
else()
find_package(OpenSubdiv 3 REQUIRED)
endif()
# --Ptex
if (PXR_ENABLE_PTEX_SUPPORT)
find_package(PTex REQUIRED)
Expand Down
7 changes: 7 additions & 0 deletions pxr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ pxr_core_epilogue()

export(PACKAGE pxr)

if(TBB_DIR)
set(PXR_FIND_TBB_IN_CONFIG ON)
endif()
if(OpenSubdiv_DIR)
set(PXR_FIND_OPENSUBDIV_IN_CONFIG ON)
endif()

configure_file(pxrConfig.cmake.in
"${PROJECT_BINARY_DIR}/pxrConfig.cmake" @ONLY)
install(FILES
Expand Down
10 changes: 10 additions & 0 deletions pxr/pxrConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ if(@PXR_ENABLE_PYTHON_SUPPORT@)
endif()
endif()

include(CMakeFindDependencyMacro)

if(@PXR_FIND_TBB_IN_CONFIG@)
find_dependency(TBB @TBB_VERSION@ CONFIG)
endif()

if(@PXR_FIND_OPENSUBDIV_IN_CONFIG@)
find_dependency(OpenSubdiv @OpenSubdiv_VERSION@ CONFIG)
endif()

# If MaterialX support was enabled for this USD build, try to find the
# associated import targets by invoking the same FindMaterialX.cmake
# module that was used for that build. This can be overridden by
Expand Down

0 comments on commit 7d09fed

Please sign in to comment.