~neon/project-neon/printer-applet

« back to all changes in this revision

Viewing changes to cmake-modules/FindPythonLibrary.cmake

  • Committer: Jonathan Riddell
  • Date: 2008-03-24 00:53:35 UTC
  • Revision ID: git-v1:1a8383f25060c9c9682766319f2e68a7621e5768
add printer-applet, a replacement for kjobviewer.  a Python app.  please test.

svn path=/trunk/kdereview/printer-applet/; revision=789361

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Find Python
 
2
# ~~~~~~~~~~~
 
3
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
 
4
# Redistribution and use is allowed according to the terms of the BSD license.
 
5
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
6
#
 
7
# Find the Python interpreter and related Python directories.
 
8
#
 
9
# This file defines the following variables:
 
10
 
11
# PYTHON_EXECUTABLE - The path and filename of the Python interpreter.
 
12
#
 
13
# PYTHON_SHORT_VERSION - The version of the Python interpreter found,
 
14
#     excluding the patch version number. (e.g. 2.5 and not 2.5.1))
 
15
 
16
# PYTHON_LONG_VERSION - The version of the Python interpreter found as a human
 
17
#     readable string.
 
18
#
 
19
# PYTHON_SITE_PACKAGES_DIR - Location of the Python site-packages directory.
 
20
#
 
21
# PYTHON_INCLUDE_PATH - Directory holding the python.h include file.
 
22
#
 
23
# PYTHON_LIBRARY, PYTHON_LIBRARIES- Location of the Python library.
 
24
 
 
25
IF(PYTHON_LIBRARY)
 
26
   # Already in cache, be silent
 
27
   SET(PYTHONLIBRARY_FOUND TRUE)
 
28
ELSE(PYTHON_LIBRARY)
 
29
 
 
30
  FIND_PACKAGE(PythonInterp REQUIRED)
 
31
  GET_FILENAME_COMPONENT(_cmake_module_path ${CMAKE_CURRENT_LIST_FILE}  PATH)
 
32
 
 
33
  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE}  ${_cmake_module_path}/FindLibPython.py OUTPUT_VARIABLE python_config)
 
34
  IF(python_config)
 
35
    STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config})
 
36
    STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config})
 
37
    STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config})
 
38
    STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config})
 
39
    STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config})
 
40
    FIND_LIBRARY(PYTHON_LIBRARY NAMES python${PYTHON_SHORT_VERSION} PATHS ${PYTHON_PREFIX}/lib NO_DEFAULT_PATH)
 
41
    SET(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
 
42
    SET(PYTHONLIBRARY_FOUND TRUE)
 
43
  ENDIF(python_config)
 
44
 
 
45
  IF(PYTHONLIBRARY_FOUND)
 
46
    IF(NOT PYTHONLIBRARY_FIND_QUIETLY)
 
47
      MESSAGE(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")
 
48
      MESSAGE(STATUS "Found Python version: ${PYTHON_LONG_VERSION}")
 
49
      MESSAGE(STATUS "Found Python library: ${PYTHON_LIBRARY}")
 
50
    ENDIF(NOT PYTHONLIBRARY_FIND_QUIETLY)
 
51
  ELSE(PYTHONLIBRARY_FOUND)
 
52
    IF(PYTHONLIBRARY_FIND_REQUIRED)
 
53
      MESSAGE(FATAL_ERROR "Could not find Python")
 
54
    ENDIF(PYTHONLIBRARY_FIND_REQUIRED)
 
55
  ENDIF(PYTHONLIBRARY_FOUND)
 
56
 
 
57
ENDIF (PYTHON_LIBRARY)