Skip to content

Commit 3a4d1e6

Browse files
committed
Adapt Python detection to older cmake versions
With cmake < 3.12, the FindPython module does not exist yet. Use FindPythonInterp and FindPythonLibs instead.
1 parent bec7025 commit 3a4d1e6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

wrappers/python/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ if (NOT BUILD_PYTHON_BINDINGS)
77
message(WARNING "Python Bindings being built despite unset option because they are required for python documentation")
88
endif()
99

10-
find_package(Python REQUIRED COMPONENTS Interpreter Development)
11-
12-
set(PYTHON_INSTALL_DIR "${Python_SITEARCH}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
13-
set(CMAKECONFIG_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/pyrealsense2")
10+
if (CMAKE_VERSION VERSION_LESS 3.12)
11+
find_package(PythonInterp REQUIRED)
12+
find_package(PythonLibs REQUIRED)
13+
set(PYTHON_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
14+
set(CMAKECONFIG_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/pyrealsense2")
15+
else()
16+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
17+
set(PYTHON_INSTALL_DIR "${Python_SITEARCH}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
18+
set(CMAKECONFIG_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/pyrealsense2")
19+
endif()
1420

1521
set(DEPENDENCIES realsense2)
1622

0 commit comments

Comments
 (0)