Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: python: use system pybind11 if installed #5092

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
# Adding PyBind11 to the build is the recommended way of integrating with CMake.
# See: https://pybind11.readthedocs.io/en/stable/compiling.html

# Keep the version in sync with requirements.txt and the Ubuntu 20.04 LTS package (python3-pybind11)
include(FetchContent)
FetchContent_Declare(pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_TAG v2.4.3)

# Configure pybind11 to use the same interpreter version as was detected above.
message(STATUS "Directing pybind11 to Python3 executable ${Python3_EXECUTABLE}")
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})

# Import PyBind11
FetchContent_MakeAvailable(pybind11)
# Keep the version in sync with requirements.txt and the Ubuntu 20.04 LTS package (python3-pybind11)
set(PYBIND11_VER 2.4.3)
find_package(pybind11 ${PYBIND11_VER} QUIET)
if (NOT pybind11_FOUND)
include(FetchContent)
FetchContent_Declare(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v${PYBIND11_VER})
FetchContent_MakeAvailable(pybind11)
endif ()

##
# Add our sources to this sub-tree.
Expand Down