Skip to content

Commit 07cbef4

Browse files
hio: Add CMake options to handled image file formats by plugins
1 parent 899c19e commit 07cbef4

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

cmake/defaults/Options.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,12 @@ if (${PXR_BUILD_PYTHON_DOCUMENTATION})
240240
set(PXR_BUILD_PYTHON_DOCUMENTATION "OFF" CACHE BOOL "" FORCE)
241241
endif()
242242
endif()
243+
244+
set(PXR_IMAGING_HIO_STB_PRECEDENCE "30" CACHE STRING "Hio plugin precedence for Hio_StbImage.")
245+
set(PXR_IMAGING_HIO_STB_FORMATS "bmp;jpg;jpeg;png;tga;hdr" CACHE STRING "Image file formats handled by Hio_StbImage Hio plugin.")
246+
247+
set(PXR_IMAGING_HIO_OPENEXR_PRECEDENCE "30" CACHE STRING "Hio plugin precedence for Hio_OpenEXRImage.")
248+
set(PXR_IMAGING_HIO_OPENEXR_FORMATS "exr" CACHE STRING "Image file formats handled by Hio_OpenEXRImage Hio plugin.")
249+
250+
set(PXR_IMAGING_HIO_OIIO_PRECEDENCE "10" CACHE STRING "Hio plugin precedence for HioOIIO_Image.")
251+
set(PXR_IMAGING_HIO_OIIO_FORMATS "tif;tiff;zfile;tx" CACHE STRING "Image file formats handled by HioOIIO_Image Hio plugin.")

pxr/imaging/hio/CMakeLists.txt

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
set(PXR_PREFIX pxr/imaging)
22
set(PXR_PACKAGE hio)
33

4+
set (optionalCppFiles)
5+
set (optionalPrivateHeaders)
6+
if (PXR_IMAGING_HIO_STB_FORMATS)
7+
list(APPEND optionalCppFiles
8+
stbImage.cpp
9+
)
10+
list(APPEND optionalPrivateHeaders
11+
stb/stb_image.h
12+
stb/stb_image_resize2.h
13+
stb/stb_image_write.h
14+
)
15+
endif()
16+
if (PXR_IMAGING_HIO_OPENEXR_FORMATS)
17+
list(APPEND optionalCppFiles
18+
OpenEXRImage.cpp
19+
OpenEXR/openexr-c.c
20+
)
21+
list(APPEND optionalPrivateHeaders
22+
OpenEXR/openexr-c.h
23+
)
24+
endif()
25+
26+
set(JSON_HIO_STB_FORMATS ${PXR_IMAGING_HIO_STB_FORMATS})
27+
list(TRANSFORM JSON_HIO_STB_FORMATS REPLACE "[a-zA-Z0-9]+" "\"\\0\"")
28+
list(JOIN JSON_HIO_STB_FORMATS ", " JSON_HIO_STB_FORMATS)
29+
30+
set(JSON_HIO_OPENEXR_FORMATS ${PXR_IMAGING_HIO_OPENEXR_FORMATS})
31+
list(TRANSFORM JSON_HIO_OPENEXR_FORMATS REPLACE "[a-zA-Z0-9]+" "\"\\0\"")
32+
list(JOIN JSON_HIO_OPENEXR_FORMATS ", " JSON_HIO_OPENEXR_FORMATS)
33+
34+
configure_file("${CMAKE_CURRENT_LIST_DIR}/plugInfo.json.in" "${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json" @ONLY)
35+
436
pxr_library(hio
537
LIBRARIES
638
arch
@@ -29,19 +61,14 @@ pxr_library(hio
2961
api.h
3062

3163
PRIVATE_HEADERS
32-
OpenEXR/openexr-c.h
3364
rankedTypeMap.h
34-
stb/stb_image.h
35-
stb/stb_image_resize2.h
36-
stb/stb_image_write.h
65+
${optionalPrivateHeaders}
3766

3867
CPPFILES
39-
OpenEXRImage.cpp
40-
OpenEXR/openexr-c.c
41-
stbImage.cpp
68+
${optionalCppFiles}
4269

4370
RESOURCE_FILES
44-
plugInfo.json
71+
"${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json"
4572

4673
DOXYGEN_FILES
4774
overview.dox

pxr/imaging/hio/plugInfo.json renamed to pxr/imaging/hio/plugInfo.json.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"Types": {
66
"Hio_OpenEXRImage" : {
77
"bases": ["HioImage"],
8-
"imageTypes": ["exr"],
9-
"precedence": 30
8+
"imageTypes": [@JSON_HIO_OPENEXR_FORMATS@],
9+
"precedence": @PXR_IMAGING_HIO_OPENEXR_PRECEDENCE@
1010
},
1111
"Hio_StbImage" : {
1212
"bases": ["HioImage"],
13-
"imageTypes": ["bmp", "jpg", "jpeg", "png", "tga", "hdr"],
14-
"precedence": 30
13+
"imageTypes": [@JSON_HIO_STB_FORMATS@],
14+
"precedence": @PXR_IMAGING_HIO_STB_PRECEDENCE@
1515
}
1616
}
1717
},

pxr/imaging/plugin/hioOiio/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ if (NOT ${PXR_BUILD_GPU_SUPPORT})
77
return()
88
endif()
99

10+
if (NOT PXR_IMAGING_HIO_OIIO_FORMATS)
11+
message(STATUS
12+
"Skipping ${PXR_PACKAGE} because PXR_IMAGING_HIO_OIIO_FORMATS is empty")
13+
return()
14+
endif()
15+
1016
# Use the import targets set by Imath's package config
1117
if (Imath_FOUND)
1218
set(__OIIO_IMATH_LIBS "Imath::Imath")
@@ -15,6 +21,12 @@ else()
1521
set(__OIIO_IMATH_LIBS ${OPENEXR_LIBRARIES})
1622
endif()
1723

24+
set(JSON_HIO_OIIO_FORMATS ${PXR_IMAGING_HIO_OIIO_FORMATS})
25+
list(TRANSFORM JSON_HIO_OIIO_FORMATS REPLACE "[a-zA-Z0-9]+" "\"\\0\"")
26+
list(JOIN JSON_HIO_OIIO_FORMATS ", " JSON_HIO_OIIO_FORMATS)
27+
28+
configure_file("${CMAKE_CURRENT_LIST_DIR}/plugInfo.json.in" "${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json" @ONLY)
29+
1830
pxr_plugin(hioOiio
1931
LIBRARIES
2032
ar
@@ -34,5 +46,5 @@ pxr_plugin(hioOiio
3446
metadata.cpp
3547

3648
RESOURCE_FILES
37-
plugInfo.json
49+
"${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json"
3850
)

pxr/imaging/plugin/hioOiio/plugInfo.json renamed to pxr/imaging/plugin/hioOiio/plugInfo.json.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Types": {
66
"HioOIIO_Image" : {
77
"bases": ["HioImage"],
8-
"imageTypes": ["tif", "tiff", "zfile", "tx"],
9-
"precedence": 10
8+
"imageTypes": [@JSON_HIO_OIIO_FORMATS@],
9+
"precedence": @PXR_IMAGING_HIO_OIIO_PRECEDENCE@
1010
}
1111
}
1212
},

0 commit comments

Comments
 (0)