Make Python version selection in CMake more convenient (#589)

This way a non-CACHE variable can also be used. For example:
```
set(PYBIND11_PYTHON_VERSION <value>)
add_subdirectory(...)
```
This commit is contained in:
Dean Moldovan 2017-01-06 23:38:00 +01:00 committed by Wenzel Jakob
parent a9730be73c
commit 5b5e3de369

View File

@ -8,7 +8,9 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
# Add a CMake parameter for choosing a desired Python version # Add a CMake parameter for choosing a desired Python version
if(NOT PYBIND11_PYTHON_VERSION)
set(PYBIND11_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling modules") set(PYBIND11_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling modules")
endif()
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4) set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4)
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED) find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)