1 # Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Sets the following variables:
22 # SIP_VERSION - version of SIP
23 # SIP_MODULE_EXECUTABLE - path to the sip-module executable (sip >= 5)
24 # SIP_EXECUTABLE - path to the sip executable
25 # SIP_INCLUDE_DIR - path to the sip headers (sip < 5)
26 # SIP_PYTHONPATH - path to the sip Python packages
28 # The header sip.h is looked for.
29 # The binary 'sip' is looked for.
32 IF(NOT SIP_FIND_QUIETLY)
33 MESSAGE(STATUS "Looking for SIP ...")
37 FIND_PROGRAM(SIP_EXECUTABLE
39 HINTS $ENV{SIP_ROOT_DIR}
40 PATH_SUFFIXES bin Scripts)
43 # Set path to sip's Python module
44 GET_FILENAME_COMPONENT(SIP_PYTHONPATH "${SIP_EXECUTABLE}" PATH) # <root>/bin/sip -> <root>/bin
45 GET_FILENAME_COMPONENT(SIP_PYTHONPATH "${SIP_PYTHONPATH}" PATH) # <root>/bin -> <root>
47 SET(SIP_PYTHONPATH "${SIP_PYTHONPATH}/lib/site-packages")
49 SET(SIP_PYTHONPATH "${SIP_PYTHONPATH}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
53 EXECUTE_PROCESS(COMMAND ${SIP_EXECUTABLE} "-V"
54 OUTPUT_VARIABLE SIP_VERSION
55 OUTPUT_STRIP_TRAILING_WHITESPACE
59 # Find sip-module executable (only for version >= 5)
60 IF(SIP_VERSION AND SIP_VERSION VERSION_GREATER_EQUAL "5")
61 FIND_PROGRAM(SIP_MODULE_EXECUTABLE
63 HINTS $ENV{SIP_ROOT_DIR}
64 PATH_SUFFIXES bin Scripts)
67 # Find header file (only for version < 5)
68 IF(NOT SIP_VERSION OR SIP_VERSION VERSION_LESS "5")
69 FIND_PATH(SIP_INCLUDE_DIR
71 HINTS $ENV{SIP_ROOT_DIR}
72 PATH_SUFFIXES include python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m)
75 INCLUDE(FindPackageHandleStandardArgs)
76 IF(SIP_VERSION AND SIP_VERSION VERSION_GREATER_EQUAL "5")
77 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIP REQUIRED_VARS SIP_EXECUTABLE SIP_MODULE_EXECUTABLE SIP_PYTHONPATH)
79 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIP REQUIRED_VARS SIP_INCLUDE_DIR SIP_EXECUTABLE SIP_PYTHONPATH)