mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
fix: respect PYTHON_VERSION if set in classic mode (#2414)
* fix: respect PYTHON_VERSION if set in classic mode * fix: add warning when using PYTHON_VERSION
This commit is contained in:
parent
03b3d59d10
commit
9b8cb02030
@ -147,7 +147,7 @@ if(PYBIND11_CPP_STANDARD)
|
||||
else()
|
||||
set(supported_standards 11 14 17 20)
|
||||
if("${VAL}" IN_LIST supported_standards)
|
||||
message(WARNING "USE -DCMAKE_CXX_STANDARD=${VAL} instead of PYBIND11_PYTHON_VERSION")
|
||||
message(WARNING "USE -DCMAKE_CXX_STANDARD=${VAL} instead of PYBIND11_CPP_STANDARD")
|
||||
set(CMAKE_CXX_STANDARD
|
||||
${VAL}
|
||||
CACHE STRING "From PYBIND11_CPP_STANDARD")
|
||||
|
@ -12,10 +12,20 @@ if(pybind11_FIND_QUIETLY)
|
||||
set(_pybind11_quiet QUIET)
|
||||
endif()
|
||||
|
||||
# Add a CMake parameter for choosing a desired Python version
|
||||
if(NOT PYBIND11_PYTHON_VERSION)
|
||||
# If this is the first run, PYTHON_VERSION can stand in for PYBIND11_PYTHON_VERSION
|
||||
if(NOT DEFINED PYBIND11_PYTHON_VERSION AND DEFINED PYTHON_VERSION)
|
||||
message(WARNING "Set PYBIND11_PYTHON_VERSION to search for a specific version, not "
|
||||
"PYTHON_VERSION (which is an output). Assuming that is what you "
|
||||
"meant to do and continuing anyway.")
|
||||
set(PYBIND11_PYTHON_VERSION
|
||||
""
|
||||
"${PYTHON_VERSION}"
|
||||
CACHE STRING "Python version to use for compiling modules")
|
||||
unset(PYTHON_VERSION)
|
||||
unset(PYTHON_VERSION CACHE)
|
||||
else()
|
||||
# If this is set as a normal variable, promote it, otherwise, make an empty cache variable.
|
||||
set(PYBIND11_PYTHON_VERSION
|
||||
"${PYBIND11_PYTHON_VERSION}"
|
||||
CACHE STRING "Python version to use for compiling modules")
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user