pybind / cmake_example

Example pybind11 module built with a CMake-based build system
Other
616 stars 218 forks source link

Access to PYTHON_VERSION_MAJOR/MINOR #13

Closed ax3l closed 6 years ago

ax3l commented 6 years ago

When including pybind11 directly via add_subdirectory, the selected python interpreter would be useful to be queried, e.g. for install paths.

With find_package(pybind11) the variables PYTHON_VERSION_MAJOR and ..._MINOR leak into the caller's scope and can be queried, but add_subdirectory does proper encapsulation.

Can we maybe add PYTHON_VERSION_MAJOR and PYTHON_VERSION_MINOR as CMake target properties to the pybind11::pybind11 target? With that we could query it from a calling project (or maybe you have an alternative idea as well).

ax3l commented 6 years ago

Ah, found a solution. We can handle it just as PYTHON_INCLUDE_DIRS

ax3l commented 6 years ago

Fix proposed in https://github.com/pybind/pybind11/pull/1434