PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.92k stars 1.17k forks source link

OSL Support Does Not Build with Imath (Fix included) #2977

Open jonahjnewton opened 6 months ago

jonahjnewton commented 6 months ago

Description of Issue

Commit https://github.com/PixarAnimationStudios/OpenUSD/commit/2818017dfcedf169319830677d83dfe3a0171b22 brought up from pull https://github.com/PixarAnimationStudios/OpenUSD/pull/1829 from 2022 fixed USD's dependency on OpenEXR 2.x's Imath libraries to allow building with Imath & OpenEXR 3. The sdrOsl CMakeLists file, however, was not fixed to reflect this.

I've added the fixes myself and thought I would share. Here is the fixed script:

#pxr/usd/plugin/sdrOsl/CMakeLists.txt

set(PXR_PREFIX pxr/usd)
set(PXR_PACKAGE sdrOsl)

if(NOT PXR_ENABLE_OSL_SUPPORT)
    return()
endif()

if (Imath_FOUND)
    set(__OSL_IMATH_LIBS "Imath::Imath")
else()
    set(__OSL_IMATH_INCLUDE ${OPENEXR_INCLUDE_DIRS})
endif()

pxr_plugin(sdrOsl
    LIBRARIES
        gf
        tf
        vt
        ar
        ndr
        sdr
        ${OSL_QUERY_LIBRARY}
        ${OIIO_LIBRARIES}
        ${__OSL_IMATH_LIBS}

    INCLUDE_DIRS
        ${__OSL_IMATH_INCLUDE}
        ${OSL_INCLUDE_DIR}
        ${OIIO_INCLUDE_DIRS}

    PUBLIC_CLASSES
        oslParser

    PRIVATE_HEADERS
        api.h

    PYTHON_CPPFILES
        moduleDeps.cpp

    PYMODULE_CPPFILES
        module.cpp
        wrapOslParser.cpp

    PYMODULE_FILES
        __init__.py

    RESOURCE_FILES
        plugInfo.json
)

pxr_test_scripts(
    testenv/testOslParser.py
)

pxr_install_test_dir(
    SRC testenv/testOslParser.testenv
    DEST testOslParser
)

pxr_register_test(testOslParser
    PYTHON
    COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testOslParser"
    EXPECTED_RETURN_CODE 0
)

Steps to Reproduce

  1. Set PXR_ENABLE_OSL_SUPPORT to ON
  2. Build USD with CMake and Imath 3 independently of OpenEXR

System Information (OS, Hardware)

Linux CentOS 7

Package Versions

GCC-9.3.1 CMake-3.16 USD-23.08 Imath-3.1.9 OpenEXR-3.1.11 OpenShadingLanguage-1.12.13.0

Build Flags

PXR_ENABLE_OSL_SUPPORT=ON

jesschimein commented 6 months ago

Filed as internal issue #USD-9376