Files
pybind11/tests/test_cmake_build/main.cpp
T
Henry Schreiner a49c4dbfa4 chore(cmake): carry option-driven defines on pybind11_headers INTERFACE (#6130)
* chore(cmake): carry option-driven defines on pybind11_headers INTERFACE

PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION and
PYBIND11_SIMPLE_GIL_MANAGEMENT were directory-scoped
add_compile_definitions, which only reached the master-project test
build. On the pybind11_headers INTERFACE (like
PYBIND11_INTERNALS_VERSION) they also apply in add_subdirectory mode
and in the exported/installed targets.

Assisted-by: ClaudeCode:claude-fable-5

* test(cmake): verify option-driven defines reach consumer targets

Extend subdirectory_target and installed_target to check that
PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION and
PYBIND11_SIMPLE_GIL_MANAGEMENT propagate through the pybind11_headers
usage requirements. Fails without the parent commit.

Assisted-by: ClaudeCode:claude-fable-5
2026-08-17 00:50:31 -04:00

19 lines
600 B
C++

#include <pybind11/pybind11.h>
#ifdef EXPECT_PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION
# ifndef PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION
# error "PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION did not propagate"
# endif
#endif
#ifdef EXPECT_PYBIND11_SIMPLE_GIL_MANAGEMENT
# ifndef PYBIND11_SIMPLE_GIL_MANAGEMENT
# error "PYBIND11_SIMPLE_GIL_MANAGEMENT did not propagate"
# endif
#endif
namespace py = pybind11;
PYBIND11_MODULE(test_cmake_build, m, py::mod_gil_not_used()) {
m.def("add", [](int i, int j) { return i + j; });
}