From 357aab36ef784a18573cf9516024f96bd6bce2e2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Tue, 8 Aug 2017 12:57:39 -0400 Subject: [PATCH 1/3] Add support to build Qml and Quick wrapping --- CMakeLists.txt | 16 ++++++++++++---- generated_cpp_56/PythonQt_QtBindings.cpp | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bea6937..70316d32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,11 +5,9 @@ # If you are not a CMake expert, you should better use the provided qmake profiles. #----------------------------------------------------------------------------- -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0) -#----------------------------------------------------------------------------- project(PythonQt) -#----------------------------------------------------------------------------- #---------------------------------------------------------------------------- # Qt version @@ -44,10 +42,19 @@ if(PythonQt_QT_VERSION VERSION_GREATER "4") find_package(Qt5 COMPONENTS Core QUIET) endif() +#---------------------------------------------------------------------------- # Qt components set(qt5libs Core Widgets Network OpenGL Sql Svg UiTools Xml XmlPatterns) if(PythonQt_QT_VERSION VERSION_GREATER "4" AND "${Qt5_VERSION}" VERSION_LESS "5.6.0") - list(APPEND qt5libs WebKitWidgets) + list(APPEND qt5libs + WebKitWidgets + ) +endif() +if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_GREATER "5.5") + list(APPEND qt5libs + Qml + Quick + ) endif() set(qt4libs core gui network opengl sql svg uitools webkit xml xmlpatterns) set(qtlibs ${qt${PythonQt_QT_VERSION}libs}) @@ -81,6 +88,7 @@ if(NOT DEFINED PythonQt_INSTALL_INCLUDE_DIR) set(PythonQt_INSTALL_INCLUDE_DIR include/PythonQt) endif() +#----------------------------------------------------------------------------- # Since the Qt bindings sources used for both Qt4 and Qt5 are # grouped using Qt4 naming convention, qt_wrapped_libs variables are the # same for the two Qt versions. diff --git a/generated_cpp_56/PythonQt_QtBindings.cpp b/generated_cpp_56/PythonQt_QtBindings.cpp index 7ae1630a..4e082e66 100644 --- a/generated_cpp_56/PythonQt_QtBindings.cpp +++ b/generated_cpp_56/PythonQt_QtBindings.cpp @@ -10,6 +10,8 @@ void PythonQt_init_QtNetwork(PyObject*); void PythonQt_init_QtCore(PyObject*); void PythonQt_init_QtWebKit(PyObject*); void PythonQt_init_QtOpenGL(PyObject*); +void PythonQt_init_QtQml(PyObject*); +void PythonQt_init_QtQuick(PyObject*); void PythonQt_init_QtXml(PyObject*); void PythonQt_init_QtXmlPatterns(PyObject*); void PythonQt_init_QtUiTools(PyObject*); @@ -32,6 +34,14 @@ PYTHONQT_EXPORT void PythonQt_init_QtBindings() PythonQt_init_QtOpenGL(0); #endif + #ifdef PYTHONQT_WRAP_Qtqml + PythonQt_init_QtQml(0); + #endif + + #ifdef PYTHONQT_WRAP_Qtquick + PythonQt_init_QtQuick(0); + #endif + #ifdef PYTHONQT_WRAP_Qtsql PythonQt_init_QtSql(0); #endif From 490bcb62e9275d586c950e45cc42908488afc8c8 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Tue, 8 Aug 2017 12:58:03 -0400 Subject: [PATCH 2/3] Update minimum required CMake version to 3.5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70316d32..34fbadfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # If you are not a CMake expert, you should better use the provided qmake profiles. #----------------------------------------------------------------------------- -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) project(PythonQt) From af9065e7f1af5dbcd857276038d9d7a0c44c9acb Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Tue, 8 Aug 2017 14:00:47 -0400 Subject: [PATCH 3/3] Consolidate handling of component and wrapped library names --- CMakeLists.txt | 77 ++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34fbadfe..1aa2da44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,20 +44,28 @@ endif() #---------------------------------------------------------------------------- # Qt components -set(qt5libs Core Widgets Network OpenGL Sql Svg UiTools Xml XmlPatterns) +set(qtlibs + Core + Widgets + Network + OpenGL + Sql + Svg + UiTools + Xml + XmlPatterns + ) if(PythonQt_QT_VERSION VERSION_GREATER "4" AND "${Qt5_VERSION}" VERSION_LESS "5.6.0") - list(APPEND qt5libs + list(APPEND qtlibs WebKitWidgets ) endif() if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_GREATER "5.5") - list(APPEND qt5libs + list(APPEND qtlibs Qml Quick ) endif() -set(qt4libs core gui network opengl sql svg uitools webkit xml xmlpatterns) -set(qtlibs ${qt${PythonQt_QT_VERSION}libs}) #----------------------------------------------------------------------------- # Python libraries @@ -89,25 +97,18 @@ if(NOT DEFINED PythonQt_INSTALL_INCLUDE_DIR) endif() #----------------------------------------------------------------------------- -# Since the Qt bindings sources used for both Qt4 and Qt5 are -# grouped using Qt4 naming convention, qt_wrapped_libs variables are the -# same for the two Qt versions. -set(qt4_wrapped_libs ${qt4libs}) -set(qt5_wrapped_libs ${qt4libs}) -set(qt_wrapped_libs ${qt${PythonQt_QT_VERSION}_wrapped_libs}) - -set(qt5_wrapped_lib_depends_gui Multimedia PrintSupport) - -set(qtlib_to_wraplib_Widgets gui) -set(qtlib_to_wraplib_WebKitWidgets webkit) - # Define PythonQt_Wrap_Qt* options option(PythonQt_Wrap_QtAll "Make all Qt components available in python" OFF) foreach(qtlib ${qt_wrapped_libs}) OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF) endforeach() +#----------------------------------------------------------------------------- # Set qtlib_to_wraplib_* variables + +set(qtlib_to_wraplib_Widgets gui) +set(qtlib_to_wraplib_WebKitWidgets webkit) + foreach(qtlib ${qtlibs}) string(TOLOWER ${qtlib} qtlib_lowercase) if(DEFINED qtlib_to_wraplib_${qtlib}) @@ -116,19 +117,24 @@ foreach(qtlib ${qtlibs}) set(qtlib_to_wraplib_${qtlib} ${qtlib_lowercase}) endforeach() +set(qt5_wrapped_lib_depends_gui Multimedia PrintSupport) + +#----------------------------------------------------------------------------- # Force option if it applies if(PythonQt_Wrap_QtAll) - set(_qt_wrapped_libs ${qt_wrapped_libs}) - # XXX xmlpatterns wrapper does *NOT* build at all :( - list(REMOVE_ITEM _qt_wrapped_libs xmlpatterns) - - foreach(qtlib ${_qt_wrapped_libs}) - if(NOT ${PythonQt_Wrap_Qt${qtlib}}) - set(PythonQt_Wrap_Qt${qtlib} ON CACHE BOOL "Make all of Qt${qtlib} available in python" FORCE) - message(STATUS "Enabling [PythonQt_Wrap_Qt${qtlib}] because of [PythonQt_Wrap_QtAll] evaluates to True") + foreach(qtlib ${qtlibs}) + # XXX xmlpatterns wrapper does *NOT* build at all :( + if(${qtlib} STREQUAL "XmlPatterns") + continue() + endif() + set(qt_wrapped_lib ${qtlib_to_wraplib_${qtlib}}) + if(NOT ${PythonQt_Wrap_Qt${qt_wrapped_lib}}) + set(PythonQt_Wrap_Qt${qt_wrapped_lib} ON CACHE BOOL "Make all of Qt${qt_wrapped_lib} available in python" FORCE) + message(STATUS "Enabling [PythonQt_Wrap_Qt${qt_wrapped_lib}] because of [PythonQt_Wrap_QtAll] evaluates to True") endif() endforeach() + endif() option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF) @@ -189,12 +195,13 @@ else() endif() # Enable required qt module - foreach(qtlib ${qt_wrapped_libs}) - string(TOUPPER ${qtlib} qtlib_uppercase) - if (NOT ${QT_QT${qtlib_uppercase}_FOUND}) - message(FATAL_ERROR "QT_QT${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}") + foreach(qtlib ${qtlibs}) + set(qt_wrapped_lib ${qtlib_to_wraplib_${qtlib}}) + string(TOUPPER ${qt_wrapped_lib} qt_wrapped_lib_uppercase) + if (NOT ${QT_QT${qt_wrapped_lib_uppercase}_FOUND}) + message(FATAL_ERROR "QT_QT${qt_wrapped_lib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qt_wrapped_lib}") endif() - set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}}) + set(QT_USE_QT${qt_wrapped_lib_uppercase} ${PythonQt_Wrap_Qt${qt_wrapped_lib}}) endforeach() # Enable QtTest in Qt4 is the option BUILD_TESTING was activated @@ -316,13 +323,15 @@ set(moc_sources #----------------------------------------------------------------------------- # Add extra sources -foreach(qtlib ${qt_wrapped_libs}) +foreach(qtlib ${qtlibs}) + + set(qt_wrapped_lib ${qtlib_to_wraplib_${qtlib}}) - if (${PythonQt_Wrap_Qt${qtlib}}) + if (${PythonQt_Wrap_Qt${qt_wrapped_lib}}) - ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib}) + ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qt_wrapped_lib}) - set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib}) + set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qt_wrapped_lib}/com_trolltech_qt_${qt_wrapped_lib}) foreach(index RANGE 0 12)