1
# Copyright (c) 2003-2007 FlashCode <flashcode@flashtux.org>
2
# Copyright (c) 2009 Fabio Bas <ctrlaltca@libero.it>
3
# Copyright (c) 2009 Kai Wasserbäch <debian@carbon-project>
4
# Copyright (c) 2009 Elvio Basello <hell@hellvis69.netsons.org>
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
# This module finds if Python is installed and determines where the include files
22
# and libraries are. It also determines what the name of the library is. This
23
# code sets the following variables:
25
# PYTHON_INCLUDE_PATH = path to where python.h can be found
26
# PYTHON_LIBRARY = path to where libpython.so* can be found
27
# PYTHON_LFLAGS = python compiler options for linking
30
# Already in cache, be silent
31
SET(PYTHON_FIND_QUIETLY TRUE)
34
FIND_PACKAGE(PythonInterp)
35
IF(PYTHONINTERP_FOUND)
36
FIND_PACKAGE(PythonLibs)
39
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('LINKFORSHARED')"
40
OUTPUT_VARIABLE PYTHON_LFLAGS
43
# remove the new lines from the output by replacing them with empty strings
44
STRING(REPLACE "\n" "" PYTHON_LFLAGS "${PYTHON_LFLAGS}")
46
# Gets the version of the interpreter
48
COMMAND ${PYTHON_EXECUTABLE} -c "import platform; print platform.python_version()"
49
OUTPUT_VARIABLE PYTHON_VERSION
52
# remove the new lines from the output by replacing them with empty strings
53
STRING(REPLACE "\n" "" PYTHON_VERSION "${PYTHON_VERSION}")
55
ADD_DEFINITIONS(-DPYTHON_VERSION=${PYTHON_VERSION})
56
MESSAGE(STATUS "Found Python ${PYTHON_VERSION}")
59
SET(PYTHON_LIBRARY ${PYTHON_LIBRARIES})
62
IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH)
63
SET(PYTHON_FOUND TRUE)