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

hio: Add CMake options to handled image file formats by plugins #3373

Open
wants to merge 1 commit 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
9 changes: 9 additions & 0 deletions cmake/defaults/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,12 @@ if (${PXR_BUILD_PYTHON_DOCUMENTATION})
set(PXR_BUILD_PYTHON_DOCUMENTATION "OFF" CACHE BOOL "" FORCE)
endif()
endif()

set(PXR_IMAGING_HIO_STB_PRECEDENCE "30" CACHE STRING "Hio plugin precedence for Hio_StbImage.")
set(PXR_IMAGING_HIO_STB_FORMATS "bmp;jpg;jpeg;png;tga;hdr" CACHE STRING "Image file formats handled by Hio_StbImage Hio plugin.")

set(PXR_IMAGING_HIO_OPENEXR_PRECEDENCE "30" CACHE STRING "Hio plugin precedence for Hio_OpenEXRImage.")
set(PXR_IMAGING_HIO_OPENEXR_FORMATS "exr" CACHE STRING "Image file formats handled by Hio_OpenEXRImage Hio plugin.")

set(PXR_IMAGING_HIO_OIIO_PRECEDENCE "10" CACHE STRING "Hio plugin precedence for HioOIIO_Image.")
set(PXR_IMAGING_HIO_OIIO_FORMATS "tif;tiff;zfile;tx" CACHE STRING "Image file formats handled by HioOIIO_Image Hio plugin.")
41 changes: 34 additions & 7 deletions pxr/imaging/hio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE hio)

set (optionalCppFiles)
set (optionalPrivateHeaders)
if (PXR_IMAGING_HIO_STB_FORMATS)
list(APPEND optionalCppFiles
stbImage.cpp
)
list(APPEND optionalPrivateHeaders
stb/stb_image.h
stb/stb_image_resize2.h
stb/stb_image_write.h
)
endif()
if (PXR_IMAGING_HIO_OPENEXR_FORMATS)
list(APPEND optionalCppFiles
OpenEXRImage.cpp
OpenEXR/openexr-c.c
)
list(APPEND optionalPrivateHeaders
OpenEXR/openexr-c.h
)
endif()

set(JSON_HIO_STB_FORMATS ${PXR_IMAGING_HIO_STB_FORMATS})
list(TRANSFORM JSON_HIO_STB_FORMATS REPLACE "[a-zA-Z0-9]+" "\"\\0\"")
list(JOIN JSON_HIO_STB_FORMATS ", " JSON_HIO_STB_FORMATS)

set(JSON_HIO_OPENEXR_FORMATS ${PXR_IMAGING_HIO_OPENEXR_FORMATS})
list(TRANSFORM JSON_HIO_OPENEXR_FORMATS REPLACE "[a-zA-Z0-9]+" "\"\\0\"")
list(JOIN JSON_HIO_OPENEXR_FORMATS ", " JSON_HIO_OPENEXR_FORMATS)

configure_file("${CMAKE_CURRENT_LIST_DIR}/plugInfo.json.in" "${CMAKE_CURRENT_LIST_DIR}/plugInfo.json" @ONLY)

pxr_library(hio
LIBRARIES
arch
Expand Down Expand Up @@ -29,16 +61,11 @@ pxr_library(hio
api.h

PRIVATE_HEADERS
OpenEXR/openexr-c.h
rankedTypeMap.h
stb/stb_image.h
stb/stb_image_resize2.h
stb/stb_image_write.h
${optionalPrivateHeaders}

CPPFILES
OpenEXRImage.cpp
OpenEXR/openexr-c.c
stbImage.cpp
${optionalCppFiles}

RESOURCE_FILES
plugInfo.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"Types": {
"Hio_OpenEXRImage" : {
"bases": ["HioImage"],
"imageTypes": ["exr"],
"precedence": 30
"imageTypes": [@JSON_HIO_OPENEXR_FORMATS@],
"precedence": @PXR_IMAGING_HIO_OPENEXR_PRECEDENCE@
},
"Hio_StbImage" : {
"bases": ["HioImage"],
"imageTypes": ["bmp", "jpg", "jpeg", "png", "tga", "hdr"],
"precedence": 30
"imageTypes": [@JSON_HIO_STB_FORMATS@],
"precedence": @PXR_IMAGING_HIO_STB_PRECEDENCE@
}
}
},
Expand Down
12 changes: 12 additions & 0 deletions pxr/imaging/plugin/hioOiio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ if (NOT ${PXR_BUILD_GPU_SUPPORT})
return()
endif()

if (NOT PXR_IMAGING_HIO_OIIO_FORMATS)
message(STATUS
"Skipping ${PXR_PACKAGE} because PXR_IMAGING_HIO_OIIO_FORMATS is empty")
return()
endif()

# Use the import targets set by Imath's package config
if (Imath_FOUND)
set(__OIIO_IMATH_LIBS "Imath::Imath")
Expand All @@ -15,6 +21,12 @@ else()
set(__OIIO_IMATH_LIBS ${OPENEXR_LIBRARIES})
endif()

set(JSON_HIO_OIIO_FORMATS ${PXR_IMAGING_HIO_OIIO_FORMATS})
list(TRANSFORM JSON_HIO_OIIO_FORMATS REPLACE "[a-zA-Z0-9]+" "\"\\0\"")
list(JOIN JSON_HIO_OIIO_FORMATS ", " JSON_HIO_OIIO_FORMATS)

configure_file("${CMAKE_CURRENT_LIST_DIR}/plugInfo.json.in" "${CMAKE_CURRENT_LIST_DIR}/plugInfo.json" @ONLY)

pxr_plugin(hioOiio
LIBRARIES
ar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"Types": {
"HioOIIO_Image" : {
"bases": ["HioImage"],
"imageTypes": ["tif", "tiff", "zfile", "tx"],
"precedence": 10
"imageTypes": [@JSON_HIO_OIIO_FORMATS@],
"precedence": @PXR_IMAGING_HIO_OIIO_PRECEDENCE@
}
}
},
Expand Down