Skip to content

Commit

Permalink
Update USD CMake to work with imath 3 where possible, while falling b…
Browse files Browse the repository at this point in the history
…ack to the old behaviour when not
  • Loading branch information
dgovil committed Aug 22, 2022
1 parent 48460d1 commit e27d004
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
29 changes: 29 additions & 0 deletions cmake/modules/FindOpenEXR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ DOC
"OpenEXR headers path"
)

find_path(IMATH_INCLUDE_DIR
Imath/half.h
HINTS
"${IMATH_LOCATION}"
"$ENV{IMATH_LOCATION}"
"${Imath_ROOT}"
PATH_SUFFIXES
include/
DOC
"Imath headers path"
)

if(OPENEXR_INCLUDE_DIR)
set(openexr_config_file "${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h")
if(EXISTS ${openexr_config_file})
Expand Down Expand Up @@ -86,9 +98,26 @@ foreach(OPENEXR_LIB
endif()
endforeach(OPENEXR_LIB)

find_library(IMATH_LIBRARY
NAMES
Imath-${IMATH_MAJOR_VERSION}_${IMATH_MINOR_VERSION}
Imath
HINTS
"${IMATH_LOCATION}"
"$ENV{IMATH_LOCATION}"
"${Imath_ROOT}"
PATH_SUFFIXES
lib/
DOC
"Imath library path"
)
list(APPEND IMATH_LIBRARIES ${IMATH_LIBRARY})

# So #include <half.h> works
list(APPEND OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR})
list(APPEND OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR}/OpenEXR)
list(APPEND IMATH_INCLUDE_DIRS ${IMATH_INCLUDE_DIR})
list(APPEND IMATH_INCLUDE_DIRS ${IMATH_INCLUDE_DIR}/Imath)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenEXR
Expand Down
8 changes: 7 additions & 1 deletion pxr/imaging/hioOpenVDB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ if (WIN32)
add_definitions(-D_USE_MATH_DEFINES)
endif()

if (IMATH_LIBRARY)
LIST(APPEND __VDB_IMATH_LIBS ${IMATH_LIBRARY})
else()
LIST(APPEND __VDB_IMATH_LIBS ${OPENEXR_Half_LIBRARY})
endif()

pxr_library(hioOpenVDB
LIBRARIES
ar
gf
hio
tf
usd
${OPENEXR_Half_LIBRARY}
${__VDB_IMATH_LIBS}
${OPENVDB_LIBRARY}

INCLUDE_DIRS
Expand Down
12 changes: 10 additions & 2 deletions pxr/imaging/plugin/hioOiio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ if (NOT ${PXR_BUILD_GPU_SUPPORT})
return()
endif()

if (IMATH_LIBRARY)
set(__OIIO_IMATH_INCLUDE ${IMATH_INCLUDE_DIR})
set(__OIIO_IMATH_LIBS ${IMATH_LIBRARIES})
else()
set(__OIIO_IMATH_INCLUDE ${OPENEXR_INCLUDE_DIRS})
set(__OIIO_IMATH_LIBS ${OPENEXR_LIBRARIES})
endif()

pxr_plugin(hioOiio
LIBRARIES
ar
Expand All @@ -15,11 +23,11 @@ pxr_plugin(hioOiio
hio
tf
${OIIO_LIBRARIES}
${OPENEXR_LIBRARIES}
${__OIIO_IMATH_LIBS}

INCLUDE_DIRS
${OIIO_INCLUDE_DIRS}
${OPENEXR_INCLUDE_DIRS}
${__OIIO_IMATH_INCLUDE}

CPPFILES
oiioImage.cpp
Expand Down
19 changes: 14 additions & 5 deletions pxr/usd/plugin/usdAbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ if (PXR_ENABLE_HDF5_SUPPORT)
list(APPEND optionalIncludeDirs ${HDF5_INCLUDE_DIRS})
endif()

if (IMATH_LIBRARY)
set(__ALEMBIC_IMATH_INCLUDES ${IMATH_INCLUDE_DIRS})
set(__ALEMBIC_IMATH_LIBS ${IMATH_LIBRARIES})
else()
set(__ALEMBIC_IMATH_INCLUDES ${OPENEXR_INCLUDE_DIRS})
LIST(APPEND __ALEMBIC_IMATH_LIBS ${OPENEXR_Half_LIBRARY})
LIST(APPEND __ALEMBIC_IMATH_LIBS ${OPENEXR_Imath_LIBRARY})
LIST(APPEND __ALEMBIC_IMATH_LIBS ${OPENEXR_Iex_LIBRARY})
LIST(APPEND __ALEMBIC_IMATH_LIBS ${OPENEXR_IexMath_LIBRARY})
endif()


pxr_plugin(usdAbc
LIBRARIES
tf
Expand All @@ -23,15 +35,12 @@ pxr_plugin(usdAbc
usd
usdGeom
${ALEMBIC_LIBRARIES}
${OPENEXR_Half_LIBRARY}
${OPENEXR_Imath_LIBRARY}
${OPENEXR_Iex_LIBRARY}
${OPENEXR_IexMath_LIBRARY}
${__ALEMBIC_IMATH_LIBS}
${optionalLibs}

INCLUDE_DIRS
${ALEMBIC_INCLUDE_DIR}
${OPENEXR_INCLUDE_DIRS}
${__ALEMBIC_IMATH_INCLUDES}
${optionalIncludeDirs}

PRIVATE_CLASSES
Expand Down

0 comments on commit e27d004

Please sign in to comment.