Skip to content

Commit

Permalink
Adsk Contrib - Better manage the OIIO dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Hodoul <Patrick.Hodoul@autodesk.com>
  • Loading branch information
hodoulp committed Dec 16, 2021
1 parent 4bdbf65 commit ec50ccb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 27 deletions.
39 changes: 32 additions & 7 deletions share/cmake/modules/FindExtPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,38 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS)
endif()
endif()

# The presence of OpenImageIO allows additional ocio apps and the OSL
# The presence of OpenImageIO allows additional OCIO apps and the OSL
# translation unit tests to be built.

# OpenImageIO
# https://github.com/OpenImageIO/oiio
if(OCIO_USE_OIIO_CMAKE_CONFIG)
find_package(OpenImageIO 2.1.9 CONFIG)
else()
find_package(OpenImageIO 2.1.9)
if(OCIO_BUILD_APPS OR OCIO_BUILD_TESTS)
# OpenImageIO
# https://github.com/OpenImageIO/oiio

set(OIIO_VERSION "2.1.9")

if(OCIO_USE_OIIO_CMAKE_CONFIG)
find_package(OpenImageIO ${OIIO_VERSION} CONFIG)
else()
find_package(OpenImageIO ${OIIO_VERSION})
endif()
endif()

# Check dependencies for OSL unit test framework (i.e. OpenImageIO and Imath) before looking
# for the Open Shading Language library.

if(OCIO_BUILD_TESTS)
if(TARGET OpenImageIO::OpenImageIO)
if(TARGET Imath::Imath)
# OpenShadingLanguage
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
find_package(OpenShadingLanguage 1.11)
if(NOT OSL_FOUND)
message(WARNING "Could NOT find OpenShadingLanguage. Skipping build of the OSL unit tests.")
endif()
else()
message(WARNING "Could NOT find Imath. Skipping build of the OSL unit tests.")
endif()
else()
message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests.")
endif()
endif()
2 changes: 1 addition & 1 deletion share/cmake/utils/CheckSupportGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

include(PackageUtils)

if(OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_APPS)
if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS)
set(OCIO_GL_ENABLED ON)
set(OCIO_USE_GLVND OFF)
set(OCIO_EGL_HEADLESS OFF)
Expand Down
4 changes: 3 additions & 1 deletion src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ if(OCIO_BUILD_APPS)
add_subdirectory(ocioconvert)
add_subdirectory(ociodisplay)
else()
message(WARNING "Could NOT find OpenImageIO. Skipping build for ociolutimage, ocioconvert and ociodisplay")
message(WARNING "Could NOT find OpenImageIO. Skipping build for ociolutimage, ocioconvert and ociodisplay.")
endif()
else()
message(WARNING "Skipping build of all apps.")
endif()
25 changes: 7 additions & 18 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

if(OCIO_BUILD_TESTS OR OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_PYTHON)
if(OCIO_BUILD_TESTS OR OCIO_BUILD_PYTHON)
# Copy test files if used.
add_subdirectory(data)
endif()
Expand All @@ -12,27 +12,16 @@ if(OCIO_BUILD_TESTS)
add_subdirectory(utils)
add_subdirectory(cpu)
add_subdirectory(cmake-consumer)
endif()

if(OCIO_BUILD_GPU_TESTS)
add_subdirectory(gpu)
endif()
if(OCIO_BUILD_GPU_TESTS)
add_subdirectory(gpu)
endif()

if(OpenImageIO_FOUND AND TARGET OpenImageIO::OpenImageIO)
if(TARGET Imath::Imath)
# OpenShadingLanguage
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
find_package(OpenShadingLanguage 1.11)
if(OSL_FOUND)
add_subdirectory(osl)
else()
message(WARNING "Could NOT find OpenShadingLanguage. Skipping build of the OSL unit tests")
endif()
else()
message(WARNING "Could NOT find Imath. Skipping build of the OSL unit tests")
if(OSL_FOUND)
add_subdirectory(osl)
endif()
else()
message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests")
message(WARNING "Skipping the library unit tests.")
endif()

if(OCIO_BUILD_JAVA)
Expand Down
3 changes: 3 additions & 0 deletions tests/osl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ endif(OCIO_USE_SSE)
set_target_properties(test_osl_exec PROPERTIES
COMPILE_FLAGS "${PLATFORM_COMPILE_FLAGS}")

# Because some OpenImageIO types are present in the OSL public API that dependency is mandatory;
# however, the unit test framework itself does not have any OpenImageIO dependency.

target_link_libraries(test_osl_exec
PRIVATE
OpenColorIO
Expand Down

0 comments on commit ec50ccb

Please sign in to comment.