source: calamares/trunk/fuentes/CMakeModules/FindPythonQt.cmake @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 5.1 KB
Line 
1# Find PythonQt
2#
3# Sets PYTHONQT_FOUND, PYTHONQT_INCLUDE_DIR, PYTHONQT_LIBRARY, PYTHONQT_LIBRARIES
4#
5
6# Python is required
7find_package(PythonLibs)
8if(NOT PYTHONLIBS_FOUND)
9  message(FATAL_ERROR "error: Python is required to build PythonQt")
10endif()
11
12# Cut X.Y[.Z] down to just X.Y
13string(REGEX REPLACE
14    "^([0-9][0-9]*)\.([0-9][0-9]*)"
15    "\\1.\\2@"
16    _PYTHONLIBS_MAJMIN
17    ${PYTHONLIBS_VERSION_STRING}
18)
19string(REGEX REPLACE
20    "@.*"
21    ""
22    PYTHONLIBS_MAJMIN
23    ${_PYTHONLIBS_MAJMIN}
24)
25
26if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}")
27  find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.")
28endif()
29# XXX Since PythonQt 3.0 is not yet cmakeified, depending
30#     on how PythonQt is built, headers will not always be
31#     installed in "include/PythonQt". That is why "src"
32#     is added as an option. See [1] for more details.
33#     [1] https://github.com/commontk/CTK/pull/538#issuecomment-86106367
34find_path(PYTHONQT_INCLUDE_DIR PythonQt.h
35  PATHS "${PYTHONQT_INSTALL_DIR}/include/PythonQt"
36        "${PYTHONQT_INSTALL_DIR}/src"
37  DOC "Path to the PythonQt include directory")
38
39if ( NOT PythonQt_FIND_QUIETLY )
40    message( STATUS "Searching for PythonQt (PythonLibs ${PYTHONLIBS_MAJMIN}) .." )
41    if ( PYTHONQT_INCLUDE_DIR )
42        message( STATUS "  .. found include ${PYTHONQT_INCLUDE_DIR}" )
43    endif()
44endif()
45
46# Minimum v3.1 is needed
47find_library(PYTHONQT_LIBRARY_RELEASE
48    NAMES
49        PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}
50        PythonQt-Qt5-Python3
51        PythonQt
52    PATHS "${PYTHONQT_INSTALL_DIR}/lib"
53    DOC "The PythonQt library."
54)
55find_library(PYTHONQT_LIBRARY_DEBUG
56    NAMES
57        PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}JMIN${CTK_CMAKE_DEBUG_POSTFIX}
58        PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX}
59        PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}
60        PythonQt-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX}
61        PythonQt-Qt5-Python3${CMAKE_DEBUG_POSTFIX}
62        PythonQt-Qt5-Python3
63        PythonQt${CTK_CMAKE_DEBUG_POSTFIX}
64        PythonQt${CMAKE_DEBUG_POSTFIX}
65        PythonQt
66    PATHS "${PYTHONQT_INSTALL_DIR}/lib"
67    DOC "The PythonQt library (debug build)."
68)
69find_library(PYTHONQT_QTALL_LIBRARY_RELEASE
70    NAMES
71        PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}
72        PythonQt_QtAll-Qt5-Python3
73        PythonQt_QtAll
74    PATHS "${PYTHONQT_INSTALL_DIR}/lib"
75    DOC "Full Qt bindings for the PythonQt library."
76)
77find_library(PYTHONQT_QTALL_LIBRARY_DEBUG
78    NAMES
79        PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CTK_CMAKE_DEBUG_POSTFIX}
80        PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX}
81        PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}
82        PythonQt_QtAll-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX}
83        PythonQt_QtAll-Qt5-Python3${CMAKE_DEBUG_POSTFIX}
84        PythonQt_QtAll-Qt5-Python3
85        PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX}
86        PythonQt_QtAll${CMAKE_DEBUG_POSTFIX}
87        PythonQt_QtAll
88    PATHS "${PYTHONQT_INSTALL_DIR}/lib"
89    DOC "Full Qt bindings for the PythonQt library (debug build)."
90)
91
92set(PYTHONQT_LIBRARY)
93if(PYTHONQT_LIBRARY_RELEASE)
94  list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
95endif()
96if(PYTHONQT_LIBRARY_DEBUG)
97  list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
98endif()
99
100set(PYTHONQT_QTALL_LIBRARY)
101if(PYTHONQT_QTALL_LIBRARY_RELEASE)
102  list(APPEND PYTHONQT_QTALL_LIBRARY optimized ${PYTHONQT_QTALL_LIBRARY_RELEASE})
103endif()
104if(PYTHONQT_QTALL_LIBRARY_DEBUG)
105  list(APPEND PYTHONQT_QTALL_LIBRARY debug ${PYTHONQT_QTALL_LIBRARY_DEBUG})
106endif()
107
108if ( NOT PythonQt_FIND_QUIETLY )
109    if ( PYTHONQT_LIBRARY )
110        message( STATUS "  .. found library ${PYTHONQT_LIBRARY}" )
111    endif()
112    if ( PYTHONQT_QTALL_LIBRARY )
113        message( STATUS "  .. found qtall   ${PYTHONQT_QTALL_LIBRARY}" )
114    endif()
115endif()
116
117
118mark_as_advanced(PYTHONQT_INSTALL_DIR)
119mark_as_advanced(PYTHONQT_INCLUDE_DIR)
120mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)
121mark_as_advanced(PYTHONQT_LIBRARY_DEBUG)
122mark_as_advanced(PYTHONQT_QTALL_LIBRARY_RELEASE)
123mark_as_advanced(PYTHONQT_QTALL_LIBRARY_DEBUG)
124
125# On linux, also find libutil
126if(UNIX AND NOT APPLE)
127  find_library(PYTHONQT_LIBUTIL util)
128  mark_as_advanced(PYTHONQT_LIBUTIL)
129endif()
130
131# All upper case _FOUND variable is maintained for backwards compatibility.
132set(PYTHONQT_FOUND 0)
133set(PythonQt_FOUND 0)
134
135if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY AND PYTHONQT_QTALL_LIBRARY)
136  # Currently CMake'ified PythonQt only supports building against a python Release build.
137  # This applies independently of CTK build type (Release, Debug, ...)
138  add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
139  set(PYTHONQT_FOUND 1)
140  set(PythonQt_FOUND ${PYTHONQT_FOUND})
141  set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL} ${PYTHONQT_QTALL_LIBRARY})
142elseif(NOT PythonQt_FIND_QUIETLY)
143  set(_missing "")
144  if (NOT PYTHONQT_INCLUDE_DIR)
145    list(APPEND _missing "includes")
146  endif()
147  if (NOT PYTHONQT_LIBRARY)
148    list(APPEND _missing "library")
149  endif()
150  if (NOT PYTHONQT_QTALL_LIBRARY)
151    list(APPEND _missing "qtall")
152  endif()
153  message(STATUS "PythonQt not found, missing components ${_missing}")
154endif()
Note: See TracBrowser for help on using the repository browser.