~ubuntu-branches/ubuntu/saucy/kvirc/saucy

« back to all changes in this revision

Viewing changes to cmake/modules/FindPython.cmake

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2013-05-18 19:36:33 UTC
  • mfrom: (22.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20130518193633-kuhzryg7jstqvxpr
Tags: 4:4.2.0-2
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
5
 
#
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.
10
 
#
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.
15
 
#
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/>.
18
 
#
19
 
 
20
 
# - Find Python
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:
24
 
#
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
28
 
 
29
 
IF(PYTHON_FOUND)
30
 
        # Already in cache, be silent
31
 
        SET(PYTHON_FIND_QUIETLY TRUE)
32
 
ENDIF()
33
 
 
34
 
FIND_PACKAGE(PythonInterp)
35
 
IF(PYTHONINTERP_FOUND)
36
 
        FIND_PACKAGE(PythonLibs)
37
 
 
38
 
        EXECUTE_PROCESS(
39
 
                COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('LINKFORSHARED')"
40
 
                OUTPUT_VARIABLE PYTHON_LFLAGS
41
 
        )
42
 
  
43
 
        # remove the new lines from the output by replacing them with empty strings
44
 
        STRING(REPLACE "\n" "" PYTHON_LFLAGS "${PYTHON_LFLAGS}")
45
 
 
46
 
        # Gets the version of the interpreter
47
 
        EXECUTE_PROCESS(
48
 
                COMMAND ${PYTHON_EXECUTABLE} -c "import platform; print platform.python_version()"
49
 
                OUTPUT_VARIABLE PYTHON_VERSION
50
 
        )
51
 
 
52
 
        # remove the new lines from the output by replacing them with empty strings
53
 
        STRING(REPLACE "\n" "" PYTHON_VERSION "${PYTHON_VERSION}")
54
 
 
55
 
        ADD_DEFINITIONS(-DPYTHON_VERSION=${PYTHON_VERSION})
56
 
        MESSAGE(STATUS "Found Python ${PYTHON_VERSION}")
57
 
 
58
 
        IF(PYTHONLIBS_FOUND)  
59
 
                SET(PYTHON_LIBRARY ${PYTHON_LIBRARIES})
60
 
        ENDIF()
61
 
 
62
 
        IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH)
63
 
                SET(PYTHON_FOUND TRUE)
64
 
        ENDIF()
65
 
  
66
 
        MARK_AS_ADVANCED(
67
 
                PYTHON_INCLUDE_PATH
68
 
                PYTHON_LIBRARY
69
 
                PYTHON_LFLAGS
70
 
        )
71
 
ENDIF()