Skip to content

Commit

Permalink
Use a specific python version if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
austinschneider committed Sep 15, 2023
1 parent e02e098 commit 71782f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
20 changes: 1 addition & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,8 @@ else()
endif()

# load python and pybind11
include(Python)
include(pybind11)
if(CMAKE_VERSION VERSION_LESS 3.12.0)
if(Python_ROOT_DIR)
MESSAGE(WARNING "Python_ROOT_DIR is set but will be ignored by this version of CMake; set PYTHON_EXECUTABLE instead")
endif()
find_package(PythonInterp)
find_package(PythonLibs)
set(PYTHON_FOUND PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
else()
if(PYTHON_EXECUTABLE)
MESSAGE(WARNING "PYTHON_EXECUTABLE is set but will be ignored by this version of CMake; set Python_ROOT_DIR instead")
endif()
find_package(Python COMPONENTS Interpreter Development)
set(PYTHON_FOUND Python_Interpreter_FOUND AND Python_Development_FOUND)
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}")
set(PYTHON_LIBRARIES "${Python_LIBRARIES}")
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
set(PYTHON_VERSION_MINOR "${Python_VERSION_MINOR}")
endif()

# load project dependencies
include(rk)
Expand Down
15 changes: 12 additions & 3 deletions cmake/Packages/Python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ IF(CMAKE_VERSION VERSION_LESS 3.12.0)
IF(Python_ROOT_DIR)
MESSAGE(WARNING "Python_ROOT_DIR is set but will be ignored by this version of CMake; set PYTHON_EXECUTABLE instead")
ENDIF(Python_ROOT_DIR)
find_package(PythonInterp)
find_package(PythonLibs)
IF(PYTHON_VERSION)
find_package(PythonInterp ${PYTHON_VERSION})
find_package(PythonLibs ${PYTHON_VERSION})
ELSE(PYTHON_VERSION)
find_package(PythonInterp)
find_package(PythonLibs)
ENDIF(PYTHON_VERSION)
set(PYTHON_FOUND PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
ELSE()
IF(PYTHON_EXECUTABLE)
MESSAGE(WARNING "PYTHON_EXECUTABLE is set but will be ignored by this version of CMake; set Python_ROOT_DIR instead")
ENDIF(PYTHON_EXECUTABLE)
FIND_PACKAGE(Python COMPONENTS Interpreter Development)
IF(PYTHON_VERSION)
FIND_PACKAGE(Python ${PYTHON_VERSION} COMPONENTS Interpreter Development)
ELSE(PYTHON_VERSION)
FIND_PACKAGE(Python COMPONENTS Interpreter Development)
ENDIF(PYTHON_VERSION)
SET(PYTHON_FOUND "${Python_FOUND}")
SET(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
SET(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}")
Expand Down

0 comments on commit 71782f0

Please sign in to comment.