Skip to content

Commit

Permalink
[pybind11] Partially revert the assumption of an automated finder.
Browse files Browse the repository at this point in the history
It seems pybind11 has its own python find module. The current upstream
head allows using CMake's new FindPython module with the definition
`-DPYBIND11_FINDPYTHON`, but there has been no upstream release with
this feature. In the meantime, we correctly find the vcpkg python3
interpreter and libraries.
  • Loading branch information
Hoikas committed Sep 25, 2020
1 parent 46f09bf commit cad9b66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ports/pybind11/CONTROL
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Version: 2.5.0
Port-Version: 1
Homepage: https://github.com/pybind/pybind11
Description: pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code.
Build-Depends: python3 (windows)
Build-Depends: python3
17 changes: 17 additions & 0 deletions ports/pybind11/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@ vcpkg_from_github(
HEAD_REF master
)

# pybind master allows opting into the builtin cmake find module with -DPYBIND11_FINDPYTHON-ON.
# When the upstream port is updated, remove all of this and change the options to just:
# -DPYBIND11_TEST=OFF -DPYBIND11_FINDPYTHON=ON
find_program(PYTHON_EXECUTABLE NAMES python python3.8 PATHS "${CURRENT_INSTALLED_DIR}/tools/python3" NO_DEFAULT_PATH)
find_library(PYTHON_LIBRARY_DEBUG NAMES python38_d python3.8_d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(PYTHON_LIBRARY_RELEASE NAMES python38 python3.8 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DPYBIND11_TEST=OFF
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHONLIBS_FOUND=ON
-DPYTHON_INCLUDE_DIRS=${CURRENT_INSTALLED_DIR}/include
-DPYTHON_MODULE_EXTENSION=.dll
OPTIONS_RELEASE
-DPYTHON_IS_DEBUG=OFF
-DPYTHON_LIBRARIES=${PYTHON_LIBRARY_DEBUG}
OPTIONS_DEBUG
-DPYTHON_IS_DEBUG=ON
-DPYTHON_LIBRARIES=${PYTHON_LIBRARY_RELEASE}
)

vcpkg_install_cmake()
Expand Down

0 comments on commit cad9b66

Please sign in to comment.