Skip to content

fix: respect PYTHON_VERSION if set in classic mode #2414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 13 additions & 3 deletions tools/pybind11Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down