feat(cmake): opt-in precompiled pybind11 static library, starting with pytypes.h
Split the out-of-line pytypes.h definitions into pytypes-inl.h (fmtlib/
CLI11 style): inline by default, compiled once into a per-project static
library when PYBIND11_PRECOMPILED is defined. Infrastructure:
- pybind11_precompile() creates the lazy pybind11::precompiled STATIC
library from the installed or in-tree src/ sources; PRECOMPILE /
NO_PRECOMPILE keywords on pybind11_add_module and a global
PYBIND11_PRECOMPILE switch select it per target.
- A link-time guard symbol encodes PYBIND11_INTERNALS_VERSION,
Py_GIL_DISABLED, PYBIND11_SIMPLE_GIL_MANAGEMENT, and
PYBIND11_DETAILED_ERROR_MESSAGES, so a configuration mismatch is one
readable undefined symbol.
- src/ is installed to share/pybind11/src (wheel stays pure);
src/pybind11_combined.cpp is a single-TU build for non-CMake use.
- Tests: PYBIND11_TEST_PRECOMPILE builds the whole suite against the
library, two new test_cmake_build cases, packaging file lists, tidy
preset, and a 3-platform CI job.
Assisted-by: ClaudeCode:claude-fable-5
21 files changed