@@ -37,13 +37,15 @@ set(qtlibs
3737 Sql
3838 Svg
3939 Multimedia
40+ WebEngineWidgets
4041 UiTools
4142 Xml
4243 )
43- # XmlPatterns is removed from Qt 6
44+ # XmlPatterns and WebKitWidgets are removed from Qt 6
4445if (PythonQt_QT_VERSION VERSION_EQUAL "5" )
4546 list (APPEND qtlibs
4647 XmlPatterns
48+ WebKitWidgets
4749 )
4850endif ()
4951
@@ -58,6 +60,7 @@ find_package(Python3 COMPONENTS Development REQUIRED)
5860option (PythonQt_SUPPORT_NAME_PROPERTY "Enable PythonQt name-property support" ON )
5961option (PythonQt_USE_RELEASE_PYTHON_FALLBACK "Fallback to Release python when Debug missing" ON )
6062option (PythonQt_DEBUG "Enable PythonQt debug output" OFF )
63+ option (PythonQt_BUILD_QTALL "Build PythonQt_QtAll bindings as a separate library" ON )
6164
6265if (NOT DEFINED PythonQt_INSTALL_RUNTIME_DIR)
6366 set (PythonQt_INSTALL_RUNTIME_DIR bin)
@@ -91,10 +94,8 @@ set(qt_wrapped_lib_depends_svg )
9194if (PythonQt_QT_VERSION VERSION_EQUAL "6" )
9295 list (APPEND qt_wrapped_lib_depends_svg SvgWidgets)
9396endif ()
97+ set (qt_wrapped_lib_depends_webenginewidgets )
9498set (qt_wrapped_lib_depends_webkit )
95- if (PythonQt_QT_VERSION VERSION_EQUAL "6" )
96- list (APPEND qt_wrapped_lib_depends_webkit WebKitWidgets)
97- endif ()
9899
99100foreach (qtlib ${qtlibs} )
100101 string (TOLOWER ${qtlib} qtlib_lowercase)
@@ -184,187 +185,11 @@ if(NOT IS_DIRECTORY "${PythonQt_GENERATED_PATH}")
184185endif ()
185186
186187#-----------------------------------------------------------------------------
187- # Sources
188-
189- set (sources
190- src/PythonQtBoolResult.cpp
191- src/PythonQtClassInfo.cpp
192- src/PythonQtClassWrapper.cpp
193- src/PythonQtConversion.cpp
194- src/PythonQt.cpp
195- src/PythonQtImporter.cpp
196- src/PythonQtInstanceWrapper.cpp
197- src/PythonQtMethodInfo.cpp
198- src/PythonQtMisc.cpp
199- src/PythonQtObjectPtr.cpp
200- src/PythonQtProperty.cpp
201- src/PythonQtQFileImporter.cpp
202- src/PythonQtSignalReceiver.cpp
203- src/PythonQtSlot.cpp
204- src/PythonQtSlotDecorator.cpp
205- src/PythonQtSignal.cpp
206- src/PythonQtStdDecorators.cpp
207- src/PythonQtStdIn.cpp
208- src/PythonQtStdOut.cpp
209- src/PythonQtThreadSupport.cpp
210- src/gui/PythonQtScriptingConsole.cpp
211-
212- extensions/PythonQt_QtAll/PythonQt_QtAll.cpp
213-
214- ${PythonQt_GENERATED_PATH} /com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp
215- ${PythonQt_GENERATED_PATH} /com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp
216- ${PythonQt_GENERATED_PATH} /com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp
217- ${PythonQt_GENERATED_PATH} /com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin_init.cpp
218- )
219-
220- #-----------------------------------------------------------------------------
221- # List headers. This list is used for the install command.
222-
223- set (headers
224- src/PythonQtBoolResult.h
225- src/PythonQtClassInfo.h
226- src/PythonQtClassWrapper.h
227- src/PythonQtConversion.h
228- src/PythonQtCppWrapperFactory.h
229- src/PythonQtDoc.h
230- src/PythonQt.h
231- src/PythonQtImporter.h
232- src/PythonQtImportFileInterface.h
233- src/PythonQtInstanceWrapper.h
234- src/PythonQtMethodInfo.h
235- src/PythonQtMisc.h
236- src/PythonQtObjectPtr.h
237- src/PythonQtProperty.h
238- src/PythonQtQFileImporter.h
239- src/PythonQtSignalReceiver.h
240- src/PythonQtSlot.h
241- src/PythonQtSlotDecorator.h
242- src/PythonQtSignal.h
243- src/PythonQtStdDecorators.h
244- src/PythonQtStdIn.h
245- src/PythonQtStdOut.h
246- src/PythonQtSystem.h
247- src/PythonQtThreadSupport.h
248- src/PythonQtUtils.h
249- src/PythonQtVariants.h
250- src/PythonQtPythonInclude.h
251- extensions/PythonQt_QtAll/PythonQt_QtAll.h
252- )
253-
254- #-----------------------------------------------------------------------------
255- # Headers that should run through moc
256-
257- set (moc_sources
258- )
259-
260- #-----------------------------------------------------------------------------
261- # Add extra sources
262-
263- foreach (qtlib ${qtlibs} )
264-
265- set (qt_wrapped_lib ${qtlib_to_wraplib_${qtlib} })
266-
267- if (${PythonQt_Wrap_Qt${qt_wrapped_lib} })
268-
269- # Variable expected by PythonQt_QtAll.cpp
270- string (TOUPPER ${qt_wrapped_lib} qt_wrapped_lib_uppercase)
271- ADD_DEFINITIONS (-DPYTHONQT_WITH_${qt_wrapped_lib_uppercase} )
272-
273- set (file_prefix com_trolltech_qt_${qt_wrapped_lib} /com_trolltech_qt_${qt_wrapped_lib} )
274-
275- foreach (index RANGE 0 12)
276-
277- # Source files
278- if (EXISTS ${PythonQt_GENERATED_PATH} /${file_prefix}${index} .cpp)
279- list (APPEND sources ${PythonQt_GENERATED_PATH} /${file_prefix}${index} .cpp)
280- endif ()
281-
282- # Headers that should run through moc
283- if (EXISTS ${PythonQt_GENERATED_PATH} /${file_prefix}${index} .h)
284- list (APPEND moc_sources ${PythonQt_GENERATED_PATH} /${file_prefix}${index} .h)
285- endif ()
286-
287- endforeach ()
288-
289- list (APPEND sources ${PythonQt_GENERATED_PATH} /${file_prefix} _init.cpp)
290-
291- endif ()
292- endforeach ()
293-
294- #-----------------------------------------------------------------------------
295- # Do wrapping
296- qt_wrap_cpp (sources ${moc_sources} )
297-
298- #-----------------------------------------------------------------------------
299- # Configure header
300-
301- # Map the CMake option `PythonQt_USE_RELEASE_PYTHON_FALLBACK` (camelCase)
302- # to a plain variable used by the configured header. The public-facing
303- # preprocessor symbol remains `PYTHONQT_USE_RELEASE_PYTHON_FALLBACK`.
304- set (PYTHONQT_USE_RELEASE_PYTHON_FALLBACK ${PythonQt_USE_RELEASE_PYTHON_FALLBACK} )
305- configure_file (
306- src/PythonQtConfigure.h.in
307- ${CMAKE_CURRENT_BINARY_DIR} /src/PythonQtConfigure.h
308- )
309- unset (PYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
310-
311- list (APPEND headers
312- ${CMAKE_CURRENT_BINARY_DIR} /src/PythonQtConfigure.h
313- )
314-
315- #-----------------------------------------------------------------------------
316- # Build the library
317-
318- add_library (PythonQt SHARED ${sources} )
319- set_target_properties (PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS )
320-
321- set_target_properties (PythonQt
322- PROPERTIES
323- AUTOMOC TRUE
324- )
325-
326- # Disable AUTOMOC for specified moc sources to avoid QMetaTypeId specialization conflicts.
327- foreach (moc_source IN LISTS moc_sources)
328- set_property (SOURCE ${moc_source} PROPERTY SKIP_AUTOMOC ON )
329- endforeach ()
330-
331- target_compile_definitions (PythonQt
332- PRIVATE
333- $<$<BOOL :${PythonQt_DEBUG} >:PYTHONQT_DEBUG >
334- $<$<BOOL :${PythonQt_SUPPORT_NAME_PROPERTY} >:PYTHONQT_SUPPORT_NAME_PROPERTY >
335- # No need to export PYTHONQT_USE_RELEASE_PYTHON_FALLBACK publicly. the
336- # configured header handles consumers.
337- )
338-
339- target_compile_options (PythonQt PRIVATE
340- $<$<CXX_COMPILER_ID :MSVC >:/bigobj >
341- )
342-
343- target_include_directories (PythonQt
344- PUBLIC
345- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /src >
346- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /extensions /PythonQt_QtAll >
347- $<BUILD_INTERFACE :${CMAKE_CURRENT_BINARY_DIR} /src >
348- $<INSTALL_INTERFACE :${PythonQt_INSTALL_INCLUDE_DIR} >
349- )
350-
351- target_link_libraries (PythonQt
352- PUBLIC
353- Python3::Python
354- ${QT_LIBRARIES}
355- PRIVATE
356- # Required for use of "QtCore/private/qmetaobjectbuilder_p.h" in "PythonQt.cpp"
357- Qt${PythonQt_QT_VERSION}::CorePrivate
358- )
359-
360- #-----------------------------------------------------------------------------
361- # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
362-
363- install (TARGETS PythonQt
364- RUNTIME DESTINATION ${PythonQt_INSTALL_RUNTIME_DIR}
365- LIBRARY DESTINATION ${PythonQt_INSTALL_LIBRARY_DIR}
366- ARCHIVE DESTINATION ${PythonQt_INSTALL_ARCHIVE_DIR} )
367- install (FILES ${headers} DESTINATION ${PythonQt_INSTALL_INCLUDE_DIR} )
188+ # Build targets
189+ add_subdirectory (src )
190+ if (PythonQt_BUILD_QTALL)
191+ add_subdirectory (extensions/PythonQt_QtAll )
192+ endif ()
368193
369194#-----------------------------------------------------------------------------
370195# Testing
@@ -412,9 +237,35 @@ if(BUILD_TESTING)
412237 $<$<BOOL :${PythonQt_SUPPORT_NAME_PROPERTY} >:PYTHONQT_SUPPORT_NAME_PROPERTY >
413238 )
414239
415- add_test (
416- NAME tests_PythonQtTestMain
417- COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE :PythonQtCppTests > tests/PythonQtTestMain
418- )
240+ if (WIN32 )
241+ # Python3::Python may resolve to the import library directory (e.g. .../libs),
242+ # while pythonXY.dll typically lives one level above. Add both.
243+ get_filename_component (_python3_lib_dir "${Python3_LIBRARY} " DIRECTORY )
244+ get_filename_component (_python3_root_dir "${_python3_lib_dir} " DIRECTORY )
245+
246+ set (_pythonqt_test_path_entries
247+ "$<TARGET_FILE_DIR :PythonQtCppTests >"
248+ "$<TARGET_FILE_DIR :PythonQt >"
249+ "$<TARGET_FILE_DIR :Qt ${PythonQt_QT_VERSION} ::Core >"
250+ "$<TARGET_FILE_DIR :Python3 ::Python >"
251+ "${_python3_lib_dir} "
252+ "${_python3_root_dir} "
253+ )
254+ if (PythonQt_BUILD_QTALL)
255+ list (APPEND _pythonqt_test_path_entries "$<TARGET_FILE_DIR :PythonQt_QtAll >" )
256+ endif ()
257+ list (JOIN _pythonqt_test_path_entries ";" _pythonqt_test_path_prefix)
258+ set (_pythonqt_test_env "PATH=${_pythonqt_test_path_prefix} ;$ENV{PATH} " )
259+
260+ add_test (
261+ NAME tests_PythonQtTestMain
262+ COMMAND ${CMAKE_COMMAND} -E env "${_pythonqt_test_env} " $<TARGET_FILE :PythonQtCppTests > tests/PythonQtTestMain
263+ )
264+ else ()
265+ add_test (
266+ NAME tests_PythonQtTestMain
267+ COMMAND $<TARGET_FILE :PythonQtCppTests > tests/PythonQtTestMain
268+ )
269+ endif ()
419270endif ()
420271
0 commit comments