Skip to content

Add a CMake option to use system-provided pybind11#6516

Merged
nihui merged 1 commit into
Tencent:masterfrom
Integral-Tech:cmake-system-pybind11
Jan 17, 2026
Merged

Add a CMake option to use system-provided pybind11#6516
nihui merged 1 commit into
Tencent:masterfrom
Integral-Tech:cmake-system-pybind11

Conversation

@Integral-Tech
Copy link
Copy Markdown
Contributor

This option enables the use of the pybind11 package available in the official repositories of Linux distributions.

@tencent-adm
Copy link
Copy Markdown
Member

tencent-adm commented Jan 16, 2026

CLA assistant check
All committers have signed the CLA.

@nihui nihui requested a review from Copilot January 17, 2026 06:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a CMake option NCNN_SYSTEM_PYBIND11 to enable the use of system-provided pybind11 packages instead of the bundled submodule version, allowing users to leverage pybind11 from their Linux distribution's official repositories.

Changes:

  • Added NCNN_SYSTEM_PYBIND11 CMake option in python/CMakeLists.txt
  • Implemented conditional logic to use system pybind11 via find_package() when enabled, otherwise fall back to bundled version
  • Added documentation in python/README.md explaining how to use the new option

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/README.md Added documentation section explaining the new NCNN_SYSTEM_PYBIND11 option with a usage example
python/CMakeLists.txt Added option definition and conditional logic to choose between system and bundled pybind11

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/CMakeLists.txt
This option enables the use of the pybind11 package available in
the official repositories of Linux distributions.
@Integral-Tech
Copy link
Copy Markdown
Contributor Author

Integral-Tech commented Jan 17, 2026

@nihui IMO, the suggestion from Copilot, which uses the REQUIRED keyword in the find_package() call, is not optimal. It would be better to fallback to the submodule if the pybind11 package is not found, similar to how the glslang finding works.

I have just pushed a new commit to include the latest changes :)

@nihui nihui merged commit d72e9dd into Tencent:master Jan 17, 2026
11 checks passed
@nihui
Copy link
Copy Markdown
Member

nihui commented Jan 17, 2026

Thanks for your contribution !

@Integral-Tech Integral-Tech deleted the cmake-system-pybind11 branch January 17, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants