Skip to content

Commit 3a635fa

Browse files
authored
Use installed pybind11 and other CMake fixes (#2009)
* Use installed pybind11 and other CMake fixes - Adds OTIO_FIND_PYBIND11 configuration option to tell CMake to look for a pre-installed pybind11 instead of using the vendored copy. Follows existing pattern for Imath and rapidjson dependencies. [Issue #2006](#2006). - A couple of bugfixes in src/deps/CMakeLists.txt - checking for empty submodule directories was broken - rapidjson subdmodule would not get built - Generated CMake files get installed in /usr/local/lib/cmake/opentime and opentimelineio instead of /usr/local/share/opentime and opentimelineio which is what the CMake documentation suggests. [Issue #2008](#2008). Signed-off-by: Jean-Francois Panisset <panisset@gmail.com> * Don't try to build rapidjson rapidjson as a submodule won't build in our environment due to old CMake version requirements, and since it's a header-only library, we only need the headers to be present to allow opentimelineio to build. Signed-off-by: Jean-Francois Panisset <panisset@gmail.com> --------- Signed-off-by: Jean-Francois Panisset <panisset@gmail.com>
1 parent 267fe4b commit 3a635fa

4 files changed

Lines changed: 42 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ option(OTIO_DEPENDENCIES_INSTALL "Install OTIO's C++ header dependencies (I
3838
option(OTIO_INSTALL_PYTHON_MODULES "Install OTIO pure Python modules/files" ON)
3939
option(OTIO_INSTALL_COMMANDLINE_TOOLS "Install the OTIO command line tools" ON)
4040
option(OTIO_FIND_IMATH "Find Imath using find_package" OFF)
41+
option(OTIO_FIND_PYBIND11 "Find pybind11 using find_package" OFF)
4142
option(OTIO_FIND_RAPIDJSON "Find RapidJSON using find_package" OFF)
4243
set(OTIO_PYTHON_INSTALL_DIR "" CACHE STRING "Python installation dir (such as the site-packages dir)")
4344

@@ -258,6 +259,16 @@ else()
258259
include_directories("${PROJECT_SOURCE_DIR}/src/deps/Imath/src")
259260
endif()
260261

262+
#----- pybind11
263+
if(OTIO_FIND_PYBIND11)
264+
find_package(pybind11 REQUIRED)
265+
if (pybind11_FOUND)
266+
message(STATUS "Found pybind11 at ${pybind11_CONFIG}")
267+
endif()
268+
else()
269+
message(STATUS "Using src/deps/pybind11 by default")
270+
endif()
271+
261272
#----- RapidJSON
262273

263274
if(OTIO_FIND_RAPIDJSON)

src/deps/CMakeLists.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
#----- Other dependencies
55

66
# detect if the submodules haven't been updated
7-
set(DEPS_SUBMODULES pybind11)
7+
if(NOT OTIO_FIND_PYBIND11 AND OTIO_PYTHON_INSTALL)
8+
# pybind11 only needed when building Python bindings
9+
set(DEPS_SUBMODULES ${DEPS_SUBMODULES} pybind11)
10+
endif()
11+
12+
if(NOT OTIO_FIND_IMATH)
13+
set(DEPS_SUBMODULES ${DEPS_SUBMODULES} Imath)
14+
endif()
815

916
if(NOT OTIO_FIND_RAPIDJSON)
1017
set(DEPS_SUBMODULES ${DEPS_SUBMODULES} rapidjson)
1118
endif()
1219

1320
foreach(submodule IN LISTS DEPS_SUBMODULES)
14-
file(GLOB SUBMOD_CONTENTS ${submodule})
21+
file(GLOB SUBMOD_CONTENTS "${submodule}/*")
1522
list(LENGTH SUBMOD_CONTENTS SUBMOD_CONTENT_LEN)
1623
if(SUBMOD_CONTENT_LEN EQUAL 0)
1724
message(
@@ -21,10 +28,25 @@ foreach(submodule IN LISTS DEPS_SUBMODULES)
2128
endif()
2229
endforeach()
2330

24-
if(OTIO_PYTHON_INSTALL)
31+
if(NOT OTIO_FIND_PYBIND11 AND OTIO_PYTHON_INSTALL)
32+
# pybind11 only needed when building Python bindings
2533
add_subdirectory(pybind11)
2634
endif()
2735

36+
# Calling add_subdirectory(rapidjson) will try to build subcomponents
37+
# such as example/CMakeLists.txt which has not been updated for CMake
38+
# 4.0 compatibility and will break our builds. rapidjson is a header
39+
# only library, code in src/opentimelineio/ only needs it to be present
40+
# to pick up the headers.
41+
# If building rapidjson ends up required, the CMake variables:
42+
#
43+
# RAPIDJSON_BUILD_DOC
44+
# RAPIDJSON_BUILD_EXAMPLES
45+
# RAPIDJSON_BUILD_TESTS
46+
#
47+
# coud be overriden from ON to OFF to avoid trying to build
48+
# subcomponents we don't need.
49+
2850
if(NOT OTIO_FIND_IMATH)
2951
# preserve BUILD_SHARED_LIBS options for this project, but set it off for Imath
3052
option(BUILD_SHARED_LIBS "Build shared libraries" ON)

src/opentime/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ if(OTIO_CXX_INSTALL)
6464
RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}")
6565

6666
install(EXPORT OpenTimeTargets
67-
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime"
67+
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/lib/cmake/opentime"
6868
NAMESPACE OTIO:: )
6969

7070
include(CMakePackageConfigHelpers)
7171
configure_package_config_file(
7272
${CMAKE_CURRENT_SOURCE_DIR}/OpenTimeConfig.cmake.in
7373
${CMAKE_CURRENT_BINARY_DIR}/OpenTimeConfig.cmake
7474
INSTALL_DESTINATION
75-
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime
75+
${OTIO_RESOLVED_CXX_INSTALL_DIR}/lib/cmake/opentime
7676
NO_SET_AND_CHECK_MACRO
7777
NO_CHECK_REQUIRED_COMPONENTS_MACRO
7878
)
@@ -87,7 +87,7 @@ if(OTIO_CXX_INSTALL)
8787
${CMAKE_CURRENT_BINARY_DIR}/OpenTimeConfig.cmake
8888
${CMAKE_CURRENT_BINARY_DIR}/OpenTimeConfigVersion.cmake
8989
DESTINATION
90-
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime
90+
${OTIO_RESOLVED_CXX_INSTALL_DIR}/lib/cmake/opentime
9191
)
9292
endif()
9393

src/opentimelineio/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ if(OTIO_CXX_INSTALL)
142142
RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}")
143143

144144
install(EXPORT OpenTimelineIOTargets
145-
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio"
145+
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/lib/cmake/opentimelineio"
146146
NAMESPACE OTIO:: )
147147

148148
include(CMakePackageConfigHelpers)
149149
configure_package_config_file(
150150
${CMAKE_CURRENT_SOURCE_DIR}/OpenTimelineIOConfig.cmake.in
151151
${CMAKE_CURRENT_BINARY_DIR}/OpenTimelineIOConfig.cmake
152152
INSTALL_DESTINATION
153-
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio
153+
${OTIO_RESOLVED_CXX_INSTALL_DIR}/lib/cmake/opentimelineio
154154
NO_SET_AND_CHECK_MACRO
155155
NO_CHECK_REQUIRED_COMPONENTS_MACRO
156156
)
@@ -165,6 +165,6 @@ if(OTIO_CXX_INSTALL)
165165
${CMAKE_CURRENT_BINARY_DIR}/OpenTimelineIOConfig.cmake
166166
${CMAKE_CURRENT_BINARY_DIR}/OpenTimelineIOConfigVersion.cmake
167167
DESTINATION
168-
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio
168+
${OTIO_RESOLVED_CXX_INSTALL_DIR}/lib/cmake/opentimelineio
169169
)
170170
endif()

0 commit comments

Comments
 (0)