Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pxrTargets.cmake relocatable (when built with TBB and OpenSubdiv) #3441

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,16 @@ 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)
set(PXR_FIND_TBB_IN_CONFIG ON)
else()
find_package(TBB REQUIRED COMPONENTS tbb)
set(PXR_FIND_TBB_IN_CONFIG OFF)
endif()

add_definitions(${TBB_DEFINITIONS})

# --math
Expand Down Expand Up @@ -251,7 +260,29 @@ 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)
# Found in CONFIG mode.
# First check the shared, then the static library, just like find_library() in FindOpenSubdiv.cmake.
foreach(postfix "" "_static")
if(NOT TARGET OpenSubdiv::osdCPU${postfix})
continue()
endif()
set(OPENSUBDIV_LIBRARIES OpenSubdiv::osdCPU${postfix})
if(OPENSUBDIV_USE_GPU)
list(APPEND OPENSUBDIV_LIBRARIES OpenSubdiv::osdGPU${postfix})
endif()
break()
endforeach()
endif()
if(OPENSUBDIV_LIBRARIES)
list(GET OPENSUBDIV_LIBRARIES 0 OPENSUBDIV_OSDCPU_LIBRARY)
set(PXR_FIND_OPENSUBDIV_IN_CONFIG ON)
else()
# Try again with the find-module.
find_package(OpenSubdiv 3 REQUIRED)
set(PXR_FIND_OPENSUBDIV_IN_CONFIG OFF)
endif()
# --Ptex
if (PXR_ENABLE_PTEX_SUPPORT)
find_package(PTex REQUIRED)
Expand Down
12 changes: 12 additions & 0 deletions pxr/pxrConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ if(@PXR_ENABLE_PYTHON_SUPPORT@)
endif()
endif()

include(CMakeFindDependencyMacro)

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

set(PXR_FIND_OPENSUBDIV_IN_CONFIG "@PXR_FIND_OPENSUBDIV_IN_CONFIG@")
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