Skip to content

Autodesk: Set Default Path of TBB and OpenSubdiv in pxrConfig.cmake.in #3606

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

erikaharrison-adsk
Copy link
Contributor

Description of Change(s)

Similar to MaterialX exported targets, adding these default paths makes pxrConfig.cmake easy to use, especially when TBB and OpenSubdiv are passed to USD cmake step. And user doesn't need to specify TBB_DIR and OpenSubdiv_DIR when using pxr exported targets.

Link to proposal (if applicable)

  • N/A

Fixes Issue(s)

  • N/A

Checklist

@pmolodo
Copy link
Contributor

pmolodo commented Apr 21, 2025

I tested this with build_usd.py, and with the default values (ie, --no-onetbb), I got a pxrConfig.cmake with:

if (NOT DEFINED PXR_FIND_TBB_IN_CONFIG)
    set(PXR_FIND_TBB_IN_CONFIG "OFF")
endif()
if (PXR_FIND_TBB_IN_CONFIG)
    # Set TBB_DIR to where the TBBConfig.cmake file was located.
    # This can be overridden by specifying a different TBB_DIR when running cmake.
    if (NOT DEFINED TBB_DIR)
        if (NOT [[TBB_DIR-NOTFOUND]] STREQUAL "")
            set(TBB_DIR [[TBB_DIR-NOTFOUND]])
        endif()
    endif()
    find_dependency(TBB 2020.3 CONFIG)
endif()

I'm unsure of Cmake's behavior if ${TBB_DIR} STREQUAL "TBB_DIR-NOTFOUND" - if this causes an immedate fail of find_package(TBB), this could create problems for downstream deps that want to use OneTBB (even though USD didn't use it).
(If find_package(TBB) still checks all the "standard places," even if ${TBB_DIR} STREQUAL "TBB_DIR-NOTFOUND", though, then this should be harmless.)

If I built with build_usd.py --onetbb, I got:

if (NOT DEFINED PXR_FIND_TBB_IN_CONFIG)
    set(PXR_FIND_TBB_IN_CONFIG "ON")
endif()
if (PXR_FIND_TBB_IN_CONFIG)
    # Set TBB_DIR to where the TBBConfig.cmake file was located.
    # This can be overridden by specifying a different TBB_DIR when running cmake.
    if (NOT DEFINED TBB_DIR)
        if (NOT [[/src/USD/usd_build/USD/_build/Release/usd0.25.05/py3.10/install/lib/cmake/TBB]] STREQUAL "")
            set(TBB_DIR [[/src/USD/usd_build/USD/_build/Release/usd0.25.05/py3.10/install/lib/cmake/TBB]])
        endif()
    endif()
    find_dependency(TBB 2021.9.0 CONFIG)
endif()

...which means we've ended up with a non-portable pxrConfig.cmake file. Is there a way we can check to see if TBB_DIR is underneath the install directory, and if so, set it to, ie, `${_IMPORT_PREFIX}/lib/cmake/TBB"?

I'm actually a bit surprised that, if building with TBBConfig.cmake, cmake's automatic XXXConfig.cmake generation doesn't handle this more gracefully. Is there a way to "tell" cmake that a dependency will be packaged along with the package being built? Or a more standard / cmake-ish way to get portable XXXConfig.cmake files?

@pmolodo
Copy link
Contributor

pmolodo commented Apr 21, 2025

To be fair this PR - this same issue is also happening with other parts of pxrConfig.cmake, like MaterialX_DIR... and this PR was presumably just following the already established pattern. Unfortunately, this established pattern seems somewhat problematic...

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10931

(This is an automated message. See here for more information.)

@jesschimein
Copy link
Collaborator

/AzurePipelines run

3 similar comments
@tallytalwar
Copy link
Contributor

/AzurePipelines run

@tallytalwar
Copy link
Contributor

/AzurePipelines run

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants