Add initial support for python bindings
[alexxy/gromacs.git] / src / pygromacs / cmake / modules / FindSIP.cmake
1 # Find SIP
2 # ~~~~~~~~
3 #
4 # SIP website: http://www.riverbankcomputing.co.uk/sip/index.php
5 #
6 # Find the installed version of SIP. FindSIP should be called after Python
7 # has been found.
8 #
9 # This file defines the following variables:
10 #
11 # SIP_VERSION - The version of SIP found expressed as a 6 digit hex number
12 #     suitable for comparison as a string.
13 #
14 # SIP_VERSION_STR - The version of SIP found as a human readable string.
15 #
16 # SIP_EXECUTABLE - Path and filename of the SIP command line executable.
17 #
18 # SIP_INCLUDE_DIR - Directory holding the SIP C++ header file.
19 #
20 # SIP_DEFAULT_SIP_DIR - Default directory where .sip files should be installed
21 #     into.
22
23 # Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
24 # Redistribution and use is allowed according to the terms of the BSD license.
25 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
26
27
28
29 IF(SIP_VERSION)
30   # Already in cache, be silent
31   SET(SIP_FOUND TRUE)
32 ELSE(SIP_VERSION)
33
34   FIND_FILE(_find_sip_py FindSIP.py PATHS ${CMAKE_MODULE_PATH})
35
36   EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
37   IF(sip_config)
38     STRING(REGEX REPLACE "^sip_version:([^\n]+).*$" "\\1" SIP_VERSION ${sip_config})
39     STRING(REGEX REPLACE ".*\nsip_version_str:([^\n]+).*$" "\\1" SIP_VERSION_STR ${sip_config})
40     STRING(REGEX REPLACE ".*\nsip_bin:([^\n]+).*$" "\\1" SIP_EXECUTABLE ${sip_config})
41     IF(NOT SIP_DEFAULT_SIP_DIR)
42         STRING(REGEX REPLACE ".*\ndefault_sip_dir:([^\n]+).*$" "\\1" SIP_DEFAULT_SIP_DIR ${sip_config})
43     ENDIF(NOT SIP_DEFAULT_SIP_DIR)
44     STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
45     FILE(TO_CMAKE_PATH ${SIP_DEFAULT_SIP_DIR} SIP_DEFAULT_SIP_DIR)
46     FILE(TO_CMAKE_PATH ${SIP_INCLUDE_DIR} SIP_INCLUDE_DIR)
47     IF(EXISTS ${SIP_EXECUTABLE})
48       SET(SIP_FOUND TRUE)
49     ELSE()
50       MESSAGE(STATUS "Found SIP configuration but the sip executable could not be found.")
51     ENDIF()
52   ENDIF(sip_config)
53
54   IF(SIP_FOUND)
55     IF(NOT SIP_FIND_QUIETLY)
56       MESSAGE(STATUS "Found SIP version: ${SIP_VERSION_STR}")
57     ENDIF(NOT SIP_FIND_QUIETLY)
58   ELSE(SIP_FOUND)
59     IF(SIP_FIND_REQUIRED)
60       MESSAGE(FATAL_ERROR "Could not find SIP")
61     ENDIF(SIP_FIND_REQUIRED)
62   ENDIF(SIP_FOUND)
63
64 ENDIF(SIP_VERSION)
65