Skip to content

Commit e28a06c

Browse files
authored
Port from main to RB-2.1 - Backport improved "OpenImageIO" dependency management. (#1610)
* Backport ec50ccb from @hodoulp Signed-off-by: Thomas Mansencal <[email protected]> * Implement code review changes Signed-off-by: Thomas Mansencal <[email protected]>
1 parent 9af47cb commit e28a06c

File tree

6 files changed

+54
-30
lines changed

6 files changed

+54
-30
lines changed

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ option(OCIO_USE_WINDOWS_UNICODE "On Windows only, compile with Unicode support"
147147

148148
option(OCIO_USE_SSE "Specify whether to enable SSE CPU performance optimizations" ON)
149149
option(OCIO_USE_OPENEXR_HALF "Specify whether to use an OpenEXR/IlmBase install of the Half library (<=v2.5) instead of the newer Imath library (>=v3.0)" OFF)
150+
option(OCIO_USE_OIIO_CMAKE_CONFIG "Specify whether to look for OIIO using the generated CMake Config script instead of the custom FindOpenImageIO.cmake script" OFF)
150151

151152

152153
###############################################################################
@@ -261,13 +262,6 @@ include(FindExtPackages)
261262
###############################################################################
262263
# Progress to other sources
263264

264-
# The presence of OpenImageIO allows additional ocio apps and the OSL translation unit tests
265-
# to be built.
266-
267-
# OpenImageIO
268-
# https://github.com/OpenImageIO/oiio
269-
find_package(OpenImageIO 2.1.9)
270-
271265
add_subdirectory(vendor)
272266
if(OCIO_BUILD_DOCS)
273267
add_subdirectory(docs)

share/cmake/modules/FindExtPackages.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,39 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS)
103103
find_package(pybind11 2.6.1 REQUIRED)
104104
endif()
105105
endif()
106+
107+
# The presence of OpenImageIO allows additional OCIO apps and the OSL
108+
# translation unit tests to be built.
109+
110+
if(OCIO_BUILD_APPS OR OCIO_BUILD_TESTS)
111+
# OpenImageIO
112+
# https://github.com/OpenImageIO/oiio
113+
114+
set(OIIO_VERSION "2.1.9")
115+
116+
if(OCIO_USE_OIIO_CMAKE_CONFIG)
117+
find_package(OpenImageIO ${OIIO_VERSION} CONFIG)
118+
else()
119+
find_package(OpenImageIO ${OIIO_VERSION})
120+
endif()
121+
endif()
122+
123+
# Check dependencies for OSL unit test framework (i.e. OpenImageIO and Imath) before looking
124+
# for the Open Shading Language library.
125+
126+
if(OCIO_BUILD_TESTS)
127+
if(TARGET OpenImageIO::OpenImageIO)
128+
if(TARGET Imath::Imath)
129+
# OpenShadingLanguage
130+
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
131+
find_package(OpenShadingLanguage 1.11)
132+
if(NOT OSL_FOUND)
133+
message(WARNING "Could NOT find OpenShadingLanguage. Skipping build of the OSL unit tests.")
134+
endif()
135+
else()
136+
message(WARNING "Could NOT find Imath. Skipping build of the OSL unit tests.")
137+
endif()
138+
else()
139+
message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests.")
140+
endif()
141+
endif()

share/cmake/utils/CheckSupportGL.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
include(PackageUtils)
99

10-
if(OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_APPS)
10+
if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS)
1111
set(OCIO_GL_ENABLED ON)
1212
set(OCIO_USE_GLVND OFF)
1313
set(OCIO_EGL_HEADLESS OFF)

src/apps/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if(OCIO_BUILD_APPS)
1414
add_subdirectory(ociodisplay)
1515
add_subdirectory(ocioperf)
1616
else()
17-
message(WARNING "Could NOT find OpenImageIO. Skipping build for ociolutimage, ocioconvert, ociodisplay and ocioperf")
17+
message(WARNING "Could NOT find OpenImageIO. Skipping build for ociolutimage, ocioconvert, ociodisplay and ocioperf.")
1818
endif()
19-
endif()
19+
else()
20+
message(WARNING "Skipping build of all apps.")
21+
endif()

tests/CMakeLists.txt

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright Contributors to the OpenColorIO Project.
33

4-
if(OCIO_BUILD_TESTS OR OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_PYTHON)
4+
if(OCIO_BUILD_TESTS OR OCIO_BUILD_PYTHON)
55
# Copy test files if used.
66
add_subdirectory(data)
77
endif()
@@ -12,27 +12,16 @@ if(OCIO_BUILD_TESTS)
1212
add_subdirectory(utils)
1313
add_subdirectory(cpu)
1414
add_subdirectory(cmake-consumer)
15-
endif()
1615

17-
if(OCIO_BUILD_GPU_TESTS)
18-
add_subdirectory(gpu)
19-
endif()
16+
if(OCIO_BUILD_GPU_TESTS)
17+
add_subdirectory(gpu)
18+
endif()
2019

21-
if(OpenImageIO_FOUND AND TARGET OpenImageIO::OpenImageIO)
22-
if(TARGET Imath::Imath)
23-
# OpenShadingLanguage
24-
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
25-
find_package(OpenShadingLanguage 1.11)
26-
if(OSL_FOUND)
27-
add_subdirectory(osl)
28-
else()
29-
message(WARNING "Could NOT find OpenShadingLanguage. Skipping build of the OSL unit tests")
30-
endif()
31-
else()
32-
message(WARNING "Could NOT find Imath. Skipping build of the OSL unit tests")
20+
if(OSL_FOUND)
21+
add_subdirectory(osl)
3322
endif()
3423
else()
35-
message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests")
24+
message(WARNING "Skipping the library unit tests.")
3625
endif()
3726

3827
if(OCIO_BUILD_JAVA)
@@ -41,4 +30,4 @@ endif()
4130

4231
if(OCIO_BUILD_PYTHON)
4332
add_subdirectory(python)
44-
endif()
33+
endif()

tests/osl/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ endif(OCIO_USE_SSE)
3535
set_target_properties(test_osl_exec PROPERTIES
3636
COMPILE_FLAGS "${PLATFORM_COMPILE_FLAGS}")
3737

38+
# Because some OpenImageIO types are present in the OSL public API that dependency is mandatory;
39+
# however, the unit test framework itself does not have any OpenImageIO dependency.
40+
3841
target_link_libraries(test_osl_exec
3942
PRIVATE
4043
OpenColorIO
@@ -63,4 +66,4 @@ if(MSVC AND BUILD_SHARED_LIBS)
6366

6467
set_tests_properties(test_osl PROPERTIES ENVIRONMENT PATH=${NEW_PATH})
6568

66-
endif()
69+
endif()

0 commit comments

Comments
 (0)