Skip to content

Building with a pre-installed pybind11 #2006

@jfpanisset

Description

@jfpanisset

In the top-level CMakeLists.txt there are currently CMake variables to use find_package() and skip using the vendored copies of imath and rapidjson:

option(OTIO_FIND_IMATH                "Find Imath using find_package" OFF)
option(OTIO_FIND_RAPIDJSON            "Find RapidJSON using find_package" OFF)

As part of creating a Conan recipe for the aswf-docker project,
I would also like to skip the vendored copy of pybind11 and let CMake find the one I provide.

The following patch against 0.18.1 seems to do the trick, but since I am very new to building OTIO (and I'm not an end user), I may be missing
some context to evaluate whether this is correct. If it is, I'm happy to submit the patch as a PR.

diff --git CMakeLists.txt CMakeLists.txt
index d99dd79ac..bfda2778a 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -32,6 +32,7 @@
 option(OTIO_INSTALL_PYTHON_MODULES    "Install OTIO pure Python modules/files" ON)
 option(OTIO_INSTALL_COMMANDLINE_TOOLS "Install the OTIO command line tools" ON)
 option(OTIO_FIND_IMATH                "Find Imath using find_package" OFF)
+option(OTIO_FIND_PYBIND11             "Find pybind11 usnig find_package" OFF)
 option(OTIO_FIND_RAPIDJSON            "Find RapidJSON using find_package" OFF)
 set(OTIO_PYTHON_INSTALL_DIR "" CACHE STRING "Python installation dir (such as the site-packages dir)")

@@ -252,6 +253,17 @@
     include_directories("${PROJECT_SOURCE_DIR}/src/deps/Imath/src")
 endif()

+#----- pybind11
+if(OTIO_FIND_PYBIND11)
+    find_package(pybind11 REQUIRED)
+    if (pybind11_FOUND)
+        message(STATUS "Found pybind11 at ${pybind11_CONFIG}")
+    endif()
+else()
+    message(STATUS "Using src/deps/pybind11 by default")
+endif()
+
+
 #----- RapidJSON

 if(OTIO_FIND_RAPIDJSON)
diff --git src/deps/CMakeLists.txt src/deps/CMakeLists.txt
index d99dd79ac..bfda2778a 100644
--- src/deps/CMakeLists.txt
+++ src/deps/CMakeLists.txt
@@ -4,7 +4,10 @@
 #----- Other dependencies

 # detect if the submodules haven't been updated
-set(DEPS_SUBMODULES pybind11)
+if(NOT OTIO_FIND_PYBIND11 AND OTIO_PYTHON_INSTALL)
+    set(DEPS_SUBMODULES ${DEPS_SUBMODULES} pybind11)
+    add_subdirectory(pybind11)
+endif()

 if(NOT OTIO_FIND_RAPIDJSON)
     set(DEPS_SUBMODULES ${DEPS_SUBMODULES} rapidjson)
@@ -21,10 +24,6 @@
     endif()
 endforeach()

-if(OTIO_PYTHON_INSTALL)
-    add_subdirectory(pybind11)
-endif()
-
 if(NOT OTIO_FIND_IMATH)
     # preserve BUILD_SHARED_LIBS options for this project, but set it off for Imath
     option(BUILD_SHARED_LIBS "Build shared libraries" ON)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions