~ubuntu-branches/ubuntu/trusty/weechat/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/add_python27_support/cmake/FindPython.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Emmanuel Bouthenot
  • Date: 2010-12-27 23:29:46 UTC
  • mfrom: (0.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20101227232946-ctzdhvwj2i20wn2v
Tags: 0.3.3-3
* Upload to unstable.
* Downgrade tcl-dev dependency to 8.4 until tcl 8.5 hit unstable.
* Add a patch to make cmake aware of python 2.7 (Closes: #606989).
  Thanks to Matthias Klose.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright (C) 2003-2010 Sebastien Helleu <flashcode@flashtux.org>
 
3
# Copyright (C) 2009 Julien Louis <ptitlouis@sysif.net>
 
4
#
 
5
# This file is part of WeeChat, the extensible chat client.
 
6
#
 
7
# WeeChat is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 3 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# WeeChat is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with WeeChat.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
 
 
21
# - Find Python
 
22
# This module finds if Python is installed and determines where the include files
 
23
# and libraries are. It also determines what the name of the library is. This
 
24
# code sets the following variables:
 
25
#
 
26
#  PYTHON_EXECUTABLE   = full path to the python binary
 
27
#  PYTHON_INCLUDE_PATH = path to where python.h can be found
 
28
#  PYTHON_LIBRARY = path to where libpython.so* can be found
 
29
#  PYTHON_LFLAGS = python compiler options for linking
 
30
 
 
31
IF(PYTHON_FOUND)
 
32
   # Already in cache, be silent
 
33
   SET(PYTHON_FIND_QUIETLY TRUE)
 
34
ENDIF(PYTHON_FOUND)
 
35
 
 
36
FIND_PROGRAM(PYTHON_EXECUTABLE
 
37
  NAMES python python2.6 python2.5 python2.4 python2.3 python2.2
 
38
  PATHS /usr/bin /usr/local/bin /usr/pkg/bin
 
39
  )
 
40
 
 
41
IF(PYTHON_EXECUTABLE)
 
42
  EXECUTE_PROCESS(
 
43
    COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('CONFINCLUDEPY')"
 
44
    OUTPUT_VARIABLE PYTHON_INC_DIR
 
45
    )
 
46
  
 
47
  EXECUTE_PROCESS(
 
48
    COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('LIBPL')"
 
49
    OUTPUT_VARIABLE PYTHON_POSSIBLE_LIB_PATH
 
50
    )
 
51
  
 
52
  EXECUTE_PROCESS(
 
53
    COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('LINKFORSHARED')"
 
54
    OUTPUT_VARIABLE PYTHON_LFLAGS
 
55
    )
 
56
  
 
57
  # remove the new lines from the output by replacing them with empty strings
 
58
  STRING(REPLACE "\n" "" PYTHON_INC_DIR "${PYTHON_INC_DIR}")
 
59
  STRING(REPLACE "\n" "" PYTHON_POSSIBLE_LIB_PATH "${PYTHON_POSSIBLE_LIB_PATH}")
 
60
  STRING(REPLACE "\n" "" PYTHON_LFLAGS "${PYTHON_LFLAGS}")
 
61
  
 
62
  FIND_PATH(PYTHON_INCLUDE_PATH
 
63
    NAMES Python.h
 
64
    PATHS ${PYTHON_INC_DIR}
 
65
    )
 
66
  
 
67
  FIND_LIBRARY(PYTHON_LIBRARY
 
68
    NAMES python python2.6 python2.5 python2.4 python2.3 python2.2
 
69
    PATHS ${PYTHON_POSSIBLE_LIB_PATH}
 
70
    )
 
71
 
 
72
  IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH)
 
73
    SET(PYTHON_FOUND TRUE)
 
74
  ENDIF(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH)
 
75
  
 
76
  MARK_AS_ADVANCED(
 
77
    PYTHON_EXECUTABLE
 
78
    PYTHON_INCLUDE_PATH
 
79
    PYTHON_LIBRARY
 
80
    PYTHON_LFLAGS
 
81
    )
 
82
  
 
83
ENDIF(PYTHON_EXECUTABLE)