Skip to content

Commit 7c46f28

Browse files
meshulanporcino-pixar
authored andcommitted
Fix for external Imath, must set USE_DEPS_IMATH OFF (#1273)
* Make the Imath detection logic much easier to understand and use Co-authored-by: Nick Porcino <nporcino@pixar.com>
1 parent 4774c44 commit 7c46f28

File tree

3 files changed

+70
-56
lines changed

3 files changed

+70
-56
lines changed

CMakeLists.txt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ option(OTIO_DEPENDENCIES_INSTALL "Install OTIO's C++ header dependencies (a
3131
option(OTIO_INSTALL_PYTHON_MODULES "Install OTIO pure Python modules/files" ON)
3232
option(OTIO_INSTALL_COMMANDLINE_TOOLS "Install the OTIO command line tools" ON)
3333
option(OTIO_INSTALL_CONTRIB "Install the opentimelineio_contrib Python package" ON)
34-
option(OTIO_FIND_IMATH "Find Imath in the environment" OFF)
34+
set(OTIO_IMATH_LIBS "" CACHE STRING "Imath library overrides to use instead of src/deps or find_package")
35+
option(OTIO_FIND_IMATH "Find Imath using find_package, ignored if OTIO_IMATH_LIBS is set" OFF)
3536
set(OTIO_PYTHON_INSTALL_DIR "" CACHE STRING "Python installation dir (such as the site-packages dir)")
3637

3738
# Build options
@@ -231,23 +232,30 @@ set(CTEST_OUTPUT_ON_FAILURE ON)
231232
# Build the dependencies and components
232233

233234
#----- Imath
234-
# prefer an installed Imath 3.
235-
if (OTIO_FIND_IMATH)
235+
set(OTIO_RESOLVED_IMATH_LIBRARIES "")
236+
if (NOT "${OTIO_IMATH_LIBS}" STREQUAL "")
237+
message(STATUS "Using Imath from OTIO_MATH_LIBS: ${OTIO_IMATH_LIBS}")
238+
set(OTIO_RESOLVED_IMATH_LIBRARIES "${OTIO_IMATH_LIBS}")
239+
set(USE_DEPS_IMATH OFF)
240+
elseif(OTIO_FIND_IMATH)
236241
find_package(Imath QUIET)
237-
if (NOT Imath_FOUND)
238-
# check if there is an installed IlmBase
242+
if (Imath_FOUND)
243+
message(STATUS "Found Imath 3 at ${Imath_CONFIG}")
244+
set(USE_DEPS_IMATH OFF)
245+
else()
239246
find_package(IlmBase QUIET)
240-
if (NOT IlmBase_FOUND)
241-
message(STATUS "Using Imath in OpenTimelineIO/src/deps")
242-
set(USE_DEPS_IMATH ON)
247+
if (IlmBase_FOUND)
248+
message(STATUS "Imath 3 not found, found Imath 2 at ${IlmBase_CONFIG}")
249+
message(STATUS "You may need to point to the Imath headers by setting IMATH_INCLUDES")
250+
set(USE_DEPS_IMATH_OFF)
251+
set(OTIO_RESOLVED_IMATH_LIBRARIES "${IlmBase_LIBRARIES")
243252
else()
244-
message(STATUS "Using IlmBase::Imath specifed by ${IlmBase_CONFIG}")
253+
message(STATUS "Imath 3 and 2 were not found, using src/deps/Imath")
254+
set(USE_DEPS_IMATH ON)
245255
endif()
246-
else()
247-
message(STATUS "Using Imath::Imath specified by ${Imath_CONFIG}")
248256
endif()
249257
else()
250-
message(STATUS "Using Imath in OpenTimelineIO/src/deps")
258+
message(STATUS "Using src/deps/Imath by default")
251259
set(USE_DEPS_IMATH ON)
252260
endif()
253261

src/opentimelineio/CMakeLists.txt

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,50 +40,52 @@ set(OPENTIMELINEIO_HEADER_FILES
4040
version.h)
4141

4242
add_library(opentimelineio ${OTIO_SHARED_OR_STATIC_LIB}
43-
clip.cpp
44-
composable.cpp
45-
composition.cpp
46-
deserialization.cpp
47-
effect.cpp
48-
errorStatus.cpp
49-
externalReference.cpp
50-
freezeFrame.cpp
51-
gap.cpp
52-
generatorReference.cpp
53-
imageSequenceReference.cpp
54-
item.cpp
55-
linearTimeWarp.cpp
56-
marker.cpp
57-
mediaReference.cpp
58-
missingReference.cpp
59-
safely_typed_any.cpp
60-
serializableCollection.cpp
61-
serializableObject.cpp
62-
serializableObjectWithMetadata.cpp
63-
serialization.cpp
64-
stack.cpp
65-
stackAlgorithm.cpp
66-
stringUtils.cpp
67-
stringUtils.h # stringUtils.h is a private header
68-
timeEffect.cpp
69-
timeline.cpp
70-
track.cpp
71-
trackAlgorithm.cpp
72-
transition.cpp
73-
typeRegistry.cpp
74-
unknownSchema.cpp
75-
${OPENTIMELINEIO_HEADER_FILES})
43+
clip.cpp
44+
composable.cpp
45+
composition.cpp
46+
deserialization.cpp
47+
effect.cpp
48+
errorStatus.cpp
49+
externalReference.cpp
50+
freezeFrame.cpp
51+
gap.cpp
52+
generatorReference.cpp
53+
imageSequenceReference.cpp
54+
item.cpp
55+
linearTimeWarp.cpp
56+
marker.cpp
57+
mediaReference.cpp
58+
missingReference.cpp
59+
safely_typed_any.cpp
60+
serializableCollection.cpp
61+
serializableObject.cpp
62+
serializableObjectWithMetadata.cpp
63+
serialization.cpp
64+
stack.cpp
65+
stackAlgorithm.cpp
66+
stringUtils.cpp
67+
stringUtils.h # stringUtils.h is a private header
68+
timeEffect.cpp
69+
timeline.cpp
70+
track.cpp
71+
trackAlgorithm.cpp
72+
transition.cpp
73+
typeRegistry.cpp
74+
unknownSchema.cpp
75+
${OPENTIMELINEIO_HEADER_FILES})
7676

7777
add_library(OTIO::opentimelineio ALIAS opentimelineio)
7878

79-
target_include_directories(opentimelineio PRIVATE
80-
"${IMATH_INCLUDES}"
81-
"${PROJECT_SOURCE_DIR}/src"
82-
"${PROJECT_SOURCE_DIR}/src/deps"
83-
"${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include"
84-
"${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include")
79+
target_include_directories(opentimelineio
80+
PRIVATE "${IMATH_INCLUDES}"
81+
"${PROJECT_SOURCE_DIR}/src"
82+
"${PROJECT_SOURCE_DIR}/src/deps"
83+
"${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include"
84+
"${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include"
85+
"${IMATH_INCLUDES}")
8586

86-
target_link_libraries(opentimelineio PUBLIC opentime ${OTIO_IMATH_TARGETS})
87+
target_link_libraries(opentimelineio
88+
PUBLIC opentime ${OTIO_IMATH_TARGETS})
8789

8890
set_target_properties(opentimelineio PROPERTIES
8991
DEBUG_POSTFIX "${OTIO_DEBUG_POSTFIX}"

tests/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ endforeach()
1717

1818
list(APPEND tests_opentimelineio test_clip)
1919
foreach(test ${tests_opentimelineio})
20-
add_executable(${test} utils.h utils.cpp ${test}.cpp)
21-
target_link_libraries(${test} opentimelineio)
22-
set_target_properties(${test} PROPERTIES FOLDER tests)
23-
add_test(NAME ${test}
20+
add_executable(${test} utils.h utils.cpp ${test}.cpp)
21+
22+
target_link_libraries(${test} opentimelineio)
23+
if (NOT "${IMATH_INCLUDES}" STREQUAL "")
24+
target_include_directories(${test} "${IMATH_INCLUDES}")
25+
endif()
26+
set_target_properties(${test} PROPERTIES FOLDER tests)
27+
add_test(NAME ${test}
2428
COMMAND ${test}
2529
# Set the pwd to the source directory so we can load the samples
2630
# like the python tests do

0 commit comments

Comments
 (0)