Skip to content

Commit 97b20e5

Browse files
ax3lwjakob
authored andcommitted
CMake: Remember Python Version (pybind#1434)
It is useful not only to remember the python libs and includes but also the interpreter version in cache. If users call pybind11 throught `add_subdirectories` they will otherwise have no access to the selected interpreter version. The interpreter version is useful for downstream projects, e.g. to select default `lib/pythonX.Y/site-packages/` install paths.
1 parent e3cb2a6 commit 97b20e5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "")
3838
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} CACHE INTERNAL "")
3939
set(PYTHON_MODULE_PREFIX ${PYTHON_MODULE_PREFIX} CACHE INTERNAL "")
4040
set(PYTHON_MODULE_EXTENSION ${PYTHON_MODULE_EXTENSION} CACHE INTERNAL "")
41+
set(PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR} CACHE INTERNAL "")
42+
set(PYTHON_VERSION_MINOR ${PYTHON_VERSION_MINOR} CACHE INTERNAL "")
4143

4244
# NB: when adding a header don't forget to also add it to setup.py
4345
set(PYBIND11_HEADERS

0 commit comments

Comments
 (0)