File: FindPythonInterp.cmake

package info (click to toggle)
cmake 2.8.2%2Bdfsg.1-0%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 33,480 kB
  • ctags: 24,561
  • sloc: cpp: 132,113; ansic: 118,916; yacc: 3,246; xml: 2,420; sh: 2,206; lex: 1,023; awk: 731; makefile: 509; python: 228; lisp: 204; f90: 105; perl: 99; fortran: 72; tcl: 55; asm: 28; php: 25; ruby: 22; java: 20
file content (58 lines) | stat: -rw-r--r-- 2,309 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# - Find python interpreter
# This module finds if Python interpreter is installed and determines where the
# executables are. This code sets the following variables:
#
#  PYTHONINTERP_FOUND - Was the Python executable found
#  PYTHON_EXECUTABLE  - path to the Python interpreter
#

#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
#  License text for the above reference.)

# The following was added for Debian by Kai Wasserbäch
# <debian@carbon-project.org> in 2010 and based on suggestions and patches by
# Didier Raboud <didier@raboud.com> and Jakub Wilk <jwilk@debian.org> to fix the
# following bugs: #569321 and #580503.
# For further information please see the Debian.NEWS file for cmake-data.
IF(CMAKE_USE_PYTHON_VERSION)
  SET(CMAKE_PYTHON_VERSIONS ${CMAKE_USE_PYTHON_VERSION})
ELSE(CMAKE_USE_PYTHON_VERSION)
  SET(CMAKE_PYTHON_VERSIONS 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)

  FIND_PROGRAM(PYVERSIONS_EXE
    NAMES pyversions
    )
  IF(PYVERSIONS_EXE)
    EXECUTE_PROCESS(COMMAND pyversions -dv
      OUTPUT_VARIABLE _CMAKE_PYTHON_VERSIONS
      OUTPUT_STRIP_TRAILING_WHITESPACE)
    LIST(INSERT CMAKE_PYTHON_VERSIONS 0 ${_CMAKE_PYTHON_VERSIONS})
    LIST(REMOVE_DUPLICATES CMAKE_PYTHON_VERSIONS)
  ENDIF(PYVERSIONS_EXE)
ENDIF(CMAKE_USE_PYTHON_VERSION)

FOREACH(_CURRENT_VERSION ${CMAKE_PYTHON_VERSIONS})
  FIND_PROGRAM(PYTHON_EXECUTABLE
    NAMES python${_CURRENT_VERSION}
    PATHS
      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]
    )
ENDFOREACH(_CURRENT_VERSION)

# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE)

MARK_AS_ADVANCED(PYTHON_EXECUTABLE)