-
Notifications
You must be signed in to change notification settings - Fork 18
/
python_interpreter.cmake
39 lines (37 loc) · 1.36 KB
/
python_interpreter.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
#.rst:
#
# Detects Python interpreter.
#
# Variables used::
#
# PYTHON_INTERPRETER - User-set path to the Python interpreter
#
# Variables defined::
#
# PYTHONINTERP_FOUND - Was the Python executable found
# PYTHON_EXECUTABLE - path to the Python interpreter
# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2
# PYTHON_VERSION_MAJOR - Python major version found e.g. 2
# PYTHON_VERSION_MINOR - Python minor version found e.g. 5
# PYTHON_VERSION_PATCH - Python patch version found e.g. 2
#
# autocmake.yml configuration::
#
# docopt: "--python=<PYTHON_INTERPRETER> The Python interpreter (development version) to use. [default: '']."
# define: "'-DPYTHON_INTERPRETER=\"{0}\"'.format(arguments['--python'])"
if("${PYTHON_INTERPRETER}" STREQUAL "")
find_package(PythonInterp REQUIRED)
else()
if(NOT EXISTS "${PYTHON_INTERPRETER}")
find_program(PYTHON_EXECUTABLE NAMES ${PYTHON_INTERPRETER})
if (NOT EXISTS "${PYTHON_EXECUTABLE}")
set(PYTHONINTERP_FOUND FALSE)
endif()
else()
set(PYTHONINTERP_FOUND TRUE)
set(PYTHON_EXECUTABLE "${PYTHON_INTERPRETER}")
endif()
endif()
find_package(PythonInterp REQUIRED)