Skip to content

Add install info for CMake/Hunter #3938

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
38 changes: 38 additions & 0 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,44 @@ community contributors. If the version is out of date, please `create an issue
or pull request <https://github.com/Microsoft/vcpkg/>`_ on the vcpkg
repository.

Include with CMake/Hunter
==================
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few more = for style uniformity would be nice

If you are already using CMake you can include pybind11 using Hunter.
If you are not already using Hunter, download
`HunterGate <https://github.com/cpp-pm/gate/tree/master/cmake>`_ to a
directory in your repo (generally *cmake/HunterGate.cmake*). Then include it
in you CMakeLists file with:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in your
     ^


.. code-block:: cmake

include("cmake/HunterGate.cmake") #or whatever directory you put it in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after #? Also below (line 115)


Select a `hunter release <https://github.com/cpp-pm/hunter/releases>`_, example

.. code-block:: cmake

HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.24.2.tar.gz"
SHA1 "17fd3b9f0b8c271eac9b71e30a6aa1b9fecab299"
)

Make sure to include the above before your **project({project name})** declaration.

Now just add pybind11 with the following:

.. code-block:: cmake

hunter_add_package(pybind11)
find_package(pybind11 CONFIG REQUIRED)

add_executable(main main.cpp) #or add_library(...)
target_link_libraries(main
{other libs}
pybind11::pybind11
pybind11::embed
pybind11::module
)

Global install with brew
========================

Expand Down