5
5
# If you are not a CMake expert, you should better use the provided qmake profiles.
6
6
#-----------------------------------------------------------------------------
7
7
8
- cmake_minimum_required (VERSION 2.8 )
8
+ cmake_minimum_required (VERSION 3.5 )
9
9
10
- #-----------------------------------------------------------------------------
11
10
project (PythonQt )
12
- #-----------------------------------------------------------------------------
13
11
14
12
#----------------------------------------------------------------------------
15
13
# Qt version
16
14
17
- # Sanity checks
18
- if (DEFINED Qt5_DIR AND DEFINED QT_QMAKE_EXECUTABLE )
19
- message (FATAL_ERROR
20
- "${PROJECT_NAME} shoult NOT be configured setting both Qt5_DIR and QT_QMAKE_EXECUTABLE options.
21
- To build with Qt4, specify QT_QMAKE_EXECUTABLE. To build with Qt5, specify Qt5_DIR." )
22
- endif ()
23
-
24
15
# Set PythonQt_QT_VERSION
25
- if (DEFINED Qt5_DIR )
26
- message (STATUS "${PROJECT_NAME} : Setting PythonQt_QT_VERSION to 5 because Qt5_DIR is defined." )
27
- set (PythonQt_QT_VERSION 5 )
28
- elseif (DEFINED QT_QMAKE_EXECUTABLE )
29
- message (STATUS "${PROJECT_NAME} : Setting PythonQt_QT_VERSION to 4 because QT_QMAKE_EXECUTABLE is defined." )
30
- set (PythonQt_QT_VERSION 4 )
31
- else ()
32
- set (PythonQt_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 4 or 5" )
33
- # Set the possible values of Qt version for cmake-gui
34
- set_property (CACHE PythonQt_QT_VERSION PROPERTY STRINGS "4" "5" )
35
- endif ()
16
+ set (PythonQt_QT_VERSION 5 )
36
17
37
18
# Requirements
38
19
set (minimum_required_qt5_version "5.3.0" )
39
- set (minimum_required_qt4_version "4.6.2" )
40
20
set (minimum_required_qt_version ${minimum_required_qt${PythonQt_QT_VERSION}_version} )
41
21
22
+ find_package (Qt5 ${minimum_required_qt_version} QUIET )
23
+ set (QT_VERSION_MAJOR ${Qt5_VERSION_MAJOR} )
24
+ set (QT_VERSION_MINOR ${Qt5_VERSION_MINOR} )
25
+
26
+ #----------------------------------------------------------------------------
42
27
# Qt components
43
- set (qt5libs Core Widgets Network OpenGL Sql Svg UiTools WebKitWidgets Xml XmlPatterns )
44
- set (qt4libs core gui network opengl sql svg uitools webkit xml xmlpatterns )
45
- set (qtlibs ${qt${PythonQt_QT_VERSION}libs} )
28
+ set (qtlibs
29
+ Core
30
+ Widgets
31
+ Network
32
+ OpenGL
33
+ Sql
34
+ Svg
35
+ UiTools
36
+ Xml
37
+ XmlPatterns
38
+ )
39
+ # Webkit has been removed in Qt >= 5.6
40
+ if ("${QT_VERSION_MAJOR} .${QT_VERSION_MINOR} " VERSION_LESS "5.7" )
41
+ list (APPEND qtlibs
42
+ WebKitWidgets
43
+ )
44
+ endif ()
45
+ if ("${QT_VERSION_MAJOR} .${QT_VERSION_MINOR} " VERSION_GREATER "5.5" )
46
+ list (APPEND qtlibs
47
+ Qml
48
+ Quick
49
+ )
50
+ endif ()
46
51
47
52
#-----------------------------------------------------------------------------
48
53
# Python libraries
@@ -73,25 +78,14 @@ if(NOT DEFINED PythonQt_INSTALL_INCLUDE_DIR)
73
78
set (PythonQt_INSTALL_INCLUDE_DIR include /PythonQt )
74
79
endif ()
75
80
76
- # Since the Qt bindings sources used for both Qt4 and Qt5 are
77
- # grouped using Qt4 naming convention, qt_wrapped_libs variables are the
78
- # same for the two Qt versions.
79
- set (qt4_wrapped_libs ${qt4libs} )
80
- set (qt5_wrapped_libs ${qt4libs} )
81
- set (qt_wrapped_libs ${qt${PythonQt_QT_VERSION}_wrapped_libs} )
82
-
83
81
set (qt5_wrapped_lib_depends_gui Multimedia )
84
82
83
+ #-----------------------------------------------------------------------------
84
+ # Set qtlib_to_wraplib_* variables
85
+
85
86
set (qtlib_to_wraplib_Widgets gui )
86
87
set (qtlib_to_wraplib_WebKitWidgets webkit )
87
88
88
- # Define PythonQt_Wrap_Qt* options
89
- option (PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF )
90
- foreach (qtlib ${qt_wrapped_libs} )
91
- OPTION (PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF )
92
- endforeach ()
93
-
94
- # Set qtlib_to_wraplib_* variables
95
89
foreach (qtlib ${qtlibs} )
96
90
string (TOLOWER ${qtlib} qtlib_lowercase )
97
91
if (DEFINED qtlib_to_wraplib_${qtlib} )
@@ -100,17 +94,25 @@ foreach(qtlib ${qtlibs})
100
94
set (qtlib_to_wraplib_${qtlib} ${qtlib_lowercase} )
101
95
endforeach ()
102
96
97
+ #-----------------------------------------------------------------------------
98
+ # Define PythonQt_Wrap_Qt* options
99
+ option (PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF )
100
+ foreach (qtlib ${qtlibs} )
101
+ OPTION (PythonQt_Wrap_Qt${qtlib_to_wraplib_${qtlib}} "Make all of Qt${qtlib} available in python" OFF )
102
+ endforeach ()
103
+
104
+ #-----------------------------------------------------------------------------
103
105
# Force option if it applies
104
106
if (PythonQt_Wrap_QtAll )
105
- set ( _qt_wrapped_libs ${qt_wrapped_libs } )
106
-
107
- # XXX xmlpatterns wrapper does *NOT* build at all :(
108
- list ( REMOVE_ITEM _qt_wrapped_libs xmlpatterns )
109
-
110
- foreach ( qtlib ${_qt_wrapped_libs } )
111
- if (NOT ${PythonQt_Wrap_Qt${qtlib }} )
112
- set (PythonQt_Wrap_Qt${qtlib } ON CACHE BOOL "Make all of Qt${qtlib } available in python" FORCE )
113
- message (STATUS "Enabling [PythonQt_Wrap_Qt${qtlib } ] because of [PythonQt_Wrap_QtAll] evaluates to True" )
107
+ foreach ( qtlib ${qtlibs } )
108
+ # XXX xmlpatterns wrapper does *NOT* build at all :(
109
+ if ( ${qtlib} STREQUAL "XmlPatterns" )
110
+ continue ( )
111
+ endif ()
112
+ set ( qt_wrapped_lib ${qtlib_to_wraplib_${qtlib} } )
113
+ if (NOT ${PythonQt_Wrap_Qt${qt_wrapped_lib }} )
114
+ set (PythonQt_Wrap_Qt${qt_wrapped_lib } ON CACHE BOOL "Make all of Qt${qt_wrapped_lib } available in python" FORCE )
115
+ message (STATUS "Enabling [PythonQt_Wrap_Qt${qt_wrapped_lib } ] because of [PythonQt_Wrap_QtAll] evaluates to True" )
114
116
endif ()
115
117
endforeach ()
116
118
endif ()
@@ -125,91 +127,56 @@ endif()
125
127
#-----------------------------------------------------------------------------
126
128
# Setup Qt
127
129
128
- if (PythonQt_QT_VERSION VERSION_GREATER "4" )
129
-
130
- # Required components
131
- set (qt_required_components Core Widgets )
132
- foreach (qtlib ${qtlibs} )
133
- set (qt_wrapped_lib ${qtlib_to_wraplib_${qtlib}} )
134
- if (${PythonQt_Wrap_Qt${qt_wrapped_lib}} )
135
- list (APPEND qt_required_components ${qtlib} ${qt${PythonQt_QT_VERSION}_wrapped_lib_depends_${qt_wrapped_lib}} )
136
- endif ()
137
- endforeach ()
138
- if (BUILD_TESTING )
139
- list (APPEND qt_required_components Test )
130
+ # Required components
131
+ set (qt_required_components Core Widgets )
132
+ foreach (qtlib ${qtlibs} )
133
+ set (qt_wrapped_lib ${qtlib_to_wraplib_${qtlib}} )
134
+ if (${PythonQt_Wrap_Qt${qt_wrapped_lib}} )
135
+ list (APPEND qt_required_components ${qtlib} ${qt${PythonQt_QT_VERSION}_wrapped_lib_depends_${qt_wrapped_lib}} )
140
136
endif ()
141
- list (REMOVE_DUPLICATES qt_required_components )
142
-
143
- message (STATUS "${PROJECT_NAME} : Required Qt components [${qt_required_components} ]" )
144
- find_package (Qt5 ${minimum_required_qt_version} COMPONENTS ${qt_required_components} REQUIRED )
145
-
146
- set (QT_LIBRARIES )
147
- foreach (qtlib ${qt_required_components} )
148
- include_directories (${Qt5${qtlib}_INCLUDE_DIRS} )
149
- add_definitions (${Qt5${qtlib}_DEFINITIONS} )
150
- list (APPEND QT_LIBRARIES ${Qt5${qtlib}_LIBRARIES} )
151
- endforeach ()
152
-
153
- set (QT_VERSION_MAJOR ${Qt5Core_VERSION_MAJOR} )
154
- set (QT_VERSION_MINOR ${Qt5Core_VERSION_MINOR} )
155
-
156
- macro (pythonqt_wrap_cpp )
157
- qt5_wrap_cpp (${ARGV} )
158
- endmacro ()
159
-
160
- else ()
161
-
162
- find_package (Qt4 )
163
-
164
- if (QT4_FOUND )
165
-
166
- set (found_qt_version ${QT_VERSION_MAJOR} .${QT_VERSION_MINOR}.${QT_VERSION_PATCH} )
167
-
168
- if (${found_qt_version} VERSION_LESS ${minimum_required_qt_version} )
169
- message (FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version} ." )
170
- endif ()
171
-
172
- # Enable required qt module
173
- foreach (qtlib ${qt_wrapped_libs} )
174
- string (TOUPPER ${qtlib} qtlib_uppercase )
175
- if (NOT ${QT_QT${qtlib_uppercase}_FOUND} )
176
- message (FATAL_ERROR "QT_QT${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib} " )
177
- endif ()
178
- set (QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}} )
179
- endforeach ()
137
+ endforeach ()
138
+ if (BUILD_TESTING )
139
+ list (APPEND qt_required_components Test )
140
+ endif ()
141
+ list (REMOVE_DUPLICATES qt_required_components )
180
142
181
- # Enable QtTest in Qt4 is the option BUILD_TESTING was activated
182
- set ( QT_USE_QTTEST ${BUILD_TESTING} )
143
+ message ( STATUS " ${PROJECT_NAME} : Required Qt components [ ${qt_required_components} ]" )
144
+ find_package ( Qt5 ${minimum_required_qt_version} COMPONENTS ${qt_required_components} REQUIRED )
183
145
184
- include (${QT_USE_FILE} )
185
- else ()
186
- message (FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable" )
187
- endif ()
146
+ set (QT_LIBRARIES )
147
+ foreach (qtlib ${qt_required_components} )
148
+ include_directories (${Qt5${qtlib}_INCLUDE_DIRS} )
149
+ add_definitions (${Qt5${qtlib}_DEFINITIONS} )
150
+ list (APPEND QT_LIBRARIES ${Qt5${qtlib}_LIBRARIES} )
151
+ endforeach ()
188
152
189
- macro (pythonqt_wrap_cpp )
190
- qt4_wrap_cpp (${ARGV} )
191
- endmacro ()
153
+ # Required for use of "QtCore/private/qmetaobjectbuilder_p.h" in "PythonQt.cpp"
154
+ include_directories (${Qt5Core_PRIVATE_INCLUDE_DIRS} )
192
155
193
- endif ()
156
+ macro (pythonqt_wrap_cpp )
157
+ qt5_wrap_cpp (${ARGV} )
158
+ endmacro ()
194
159
195
160
if (UNIX )
196
161
find_package (OpenGL )
197
162
if (OPENGL_FOUND )
198
163
list (APPEND QT_LIBRARIES ${OPENGL_LIBRARIES} )
199
164
endif ()
200
165
endif ()
166
+
201
167
#-----------------------------------------------------------------------------
202
168
# The variable "generated_cpp_suffix" allows to conditionnally compile the generated wrappers
203
169
# associated with the Qt version being used.
204
170
205
- set (generated_cpp_suffix_46 _47 )
206
171
set (generated_cpp_suffix_52 _50 )
207
172
set (generated_cpp_suffix_51 _50 )
208
173
209
174
set (generated_cpp_suffix "_${QT_VERSION_MAJOR}${QT_VERSION_MINOR} " )
210
175
if (DEFINED generated_cpp_suffix_${QT_VERSION_MAJOR}${QT_VERSION_MINOR} )
211
176
set (generated_cpp_suffix "${generated_cpp_suffix_${QT_VERSION_MAJOR}${QT_VERSION_MINOR} }" )
212
- elseif (${QT_VERSION_MAJOR} .${QT_VERSION_MINOR} VERSION_GREATER "5.4" )
177
+ elseif ("${QT_VERSION_MAJOR} .${QT_VERSION_MINOR} " VERSION_GREATER "5.5" )
178
+ set (generated_cpp_suffix "_56" )
179
+ elseif ("${QT_VERSION_MAJOR} .${QT_VERSION_MINOR} " VERSION_GREATER "5.3" )
213
180
set (generated_cpp_suffix "_54" )
214
181
endif ()
215
182
@@ -227,9 +194,11 @@ set(sources
227
194
src/PythonQtMethodInfo.cpp
228
195
src/PythonQtMisc.cpp
229
196
src/PythonQtObjectPtr.cpp
197
+ src/PythonQtProperty.cpp
230
198
src/PythonQtQFileImporter.cpp
231
199
src/PythonQtSignalReceiver.cpp
232
200
src/PythonQtSlot.cpp
201
+ src/PythonQtSlotDecorator.cpp
233
202
src/PythonQtSignal.cpp
234
203
src/PythonQtStdDecorators.cpp
235
204
src/PythonQtStdIn.cpp
@@ -261,9 +230,11 @@ set(headers
261
230
src/PythonQtMethodInfo.h
262
231
src/PythonQtMisc.h
263
232
src/PythonQtObjectPtr.h
233
+ src/PythonQtProperty.h
264
234
src/PythonQtQFileImporter.h
265
235
src/PythonQtSignalReceiver.h
266
236
src/PythonQtSlot.h
237
+ src/PythonQtSlotDecorator.h
267
238
src/PythonQtSignal.h
268
239
src/PythonQtStdDecorators.h
269
240
src/PythonQtStdIn.h
@@ -290,6 +261,7 @@ set(moc_sources
290
261
291
262
#-----------------------------------------------------------------------------
292
263
# Add extra sources
264
+
293
265
foreach (qtlib ${qt_wrapped_libs} )
294
266
295
267
if (${PythonQt_Wrap_Qt${qtlib}} )
0 commit comments