Skip to content

Commit

Permalink
fix: respect PYTHON_VERSION if set in classic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Aug 19, 2020
1 parent 24dffe4 commit f3cfc0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/pybind11Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 10 additions & 3 deletions tools/pybind11Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ 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)
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()

Expand Down

0 comments on commit f3cfc0f

Please sign in to comment.