diff --git a/cmake/defaults/Options.cmake b/cmake/defaults/Options.cmake index 74cee361fd..e2b7315417 100644 --- a/cmake/defaults/Options.cmake +++ b/cmake/defaults/Options.cmake @@ -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.") diff --git a/pxr/imaging/hio/CMakeLists.txt b/pxr/imaging/hio/CMakeLists.txt index 75e1e62989..d79edd6210 100644 --- a/pxr/imaging/hio/CMakeLists.txt +++ b/pxr/imaging/hio/CMakeLists.txt @@ -1,6 +1,43 @@ 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) + +file(READ "${CMAKE_CURRENT_LIST_DIR}/plugInfo.json.in" content) +string(REPLACE "" "${JSON_HIO_OPENEXR_FORMATS}" content "${content}") +string(REPLACE "" "${PXR_IMAGING_HIO_OPENEXR_PRECEDENCE}" content "${content}") +string(REPLACE "" "${JSON_HIO_STB_FORMATS}" content "${content}") +string(REPLACE "" "${PXR_IMAGING_HIO_STB_PRECEDENCE}" content "${content}") +file(WRITE "${CMAKE_CURRENT_LIST_DIR}/plugInfo.json" "${content}") + pxr_library(hio LIBRARIES arch @@ -29,16 +66,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 diff --git a/pxr/imaging/hio/plugInfo.json b/pxr/imaging/hio/plugInfo.json.in similarity index 64% rename from pxr/imaging/hio/plugInfo.json rename to pxr/imaging/hio/plugInfo.json.in index 70e5fb8d9c..17dfbb6cce 100644 --- a/pxr/imaging/hio/plugInfo.json +++ b/pxr/imaging/hio/plugInfo.json.in @@ -5,13 +5,12 @@ "Types": { "Hio_OpenEXRImage" : { "bases": ["HioImage"], - "imageTypes": ["exr"], - "precedence": 30 + "imageTypes": [], + "precedence": }, "Hio_StbImage" : { - "bases": ["HioImage"], - "imageTypes": ["bmp", "jpg", "jpeg", "png", "tga", "hdr"], - "precedence": 30 + "imageTypes": [], + "precedence": } } }, diff --git a/pxr/imaging/plugin/hioOiio/CMakeLists.txt b/pxr/imaging/plugin/hioOiio/CMakeLists.txt index 0a055b711d..9842db59cb 100644 --- a/pxr/imaging/plugin/hioOiio/CMakeLists.txt +++ b/pxr/imaging/plugin/hioOiio/CMakeLists.txt @@ -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") @@ -15,6 +21,15 @@ 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) + +file(READ "${CMAKE_CURRENT_LIST_DIR}/plugInfo.json.in" content) +string(REPLACE "" "${JSON_HIO_OIIO_FORMATS}" content "${content}") +string(REPLACE "" "${PXR_IMAGING_HIO_OIIO_PRECEDENCE}" content "${content}") +file(WRITE "${CMAKE_CURRENT_LIST_DIR}/plugInfo.json" "${content}") + pxr_plugin(hioOiio LIBRARIES ar diff --git a/pxr/imaging/plugin/hioOiio/plugInfo.json b/pxr/imaging/plugin/hioOiio/plugInfo.json.in similarity index 75% rename from pxr/imaging/plugin/hioOiio/plugInfo.json rename to pxr/imaging/plugin/hioOiio/plugInfo.json.in index 6a89df32d5..34e214b551 100644 --- a/pxr/imaging/plugin/hioOiio/plugInfo.json +++ b/pxr/imaging/plugin/hioOiio/plugInfo.json.in @@ -5,8 +5,8 @@ "Types": { "HioOIIO_Image" : { "bases": ["HioImage"], - "imageTypes": ["tif", "tiff", "zfile", "tx"], - "precedence": 10 + "imageTypes": [], + "precedence": } } },