PythonQt
PythonQt copied to clipboard
[patched-9] Update PythonQtGenerator CMake build-system to support Qt5 and Qt6
This removes Qt4 support and adds support for Qt5 and Qt6.
After https://github.com/commontk/PythonQt/pull/88 is integrated, this allows to generate Qt5 wrappers using command like the following:
./PythonQtGenerator \
--qt-version=5.15.2 \
--include-paths=/home/jcfr/Support/Qt/5.15.2/gcc_64/include/ \
--output-directory=/tmp/PythonQtGenerator-output/
This allows to generates wrappers similar to the ones referenced in https://github.com/jamesobutler/PythonQt/commit/dfa14ff435e87f8b011a9f21afca9e89020015c9
cc: @jamesobutler
After trying to build against Qt6, I realized the minimum Qt version with a working set of Qt config CMake files allowing to configure with -DQt6_DIR:PATH=/path/to/lib/cmake/Qt6
was Qt >= 6.5
Attempting to configure against older version reported message like the following:
Configuration error associated with Qt 6.2.4
$ /Support/cmake-3.28.1-linux-x86_64/bin/cmake \
-DQt6_DIR:PATH=/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6 \
-DCMAKE_BUILD_TYPE:STRING=Release \
../PythonQt/generator/
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- PythonQtGenerator: Required Qt6 components [Core;Xml;Core5Compat]
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at /home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package):
Found package configuration file:
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND. Reason given by package:
Target "Qt6::Core" was not found.
Call Stack (most recent call first):
CMakeLists.txt:31 (find_package)
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at /home/jcfr/Support/cmake-3.28.1-linux-x86_64/share/cmake-3.28/Modules/CMakeFindDependencyMacro.cmake:76 (find_package):
Found package configuration file:
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND. Reason given by package:
Target "Qt6::Core" was not found.
Call Stack (most recent call first):
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Xml/Qt6XmlDependencies.cmake:96 (_qt_internal_find_dependencies)
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Xml/Qt6XmlConfig.cmake:40 (include)
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package)
CMakeLists.txt:31 (find_package)
CMake Warning at /home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package):
Found package configuration file:
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Xml/Qt6XmlConfig.cmake
but it set Qt6Xml_FOUND to FALSE so package "Qt6Xml" is considered to be
NOT FOUND. Reason given by package:
Qt6Xml could not be found because dependency Qt6Core could not be found.
Call Stack (most recent call first):
CMakeLists.txt:31 (find_package)
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at /home/jcfr/Support/cmake-3.28.1-linux-x86_64/share/cmake-3.28/Modules/CMakeFindDependencyMacro.cmake:76 (find_package):
Found package configuration file:
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND. Reason given by package:
Target "Qt6::Core" was not found.
Call Stack (most recent call first):
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core5Compat/Qt6Core5CompatDependencies.cmake:96 (_qt_internal_find_dependencies)
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake:40 (include)
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package)
CMakeLists.txt:31 (find_package)
CMake Warning at /home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package):
Found package configuration file:
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake
but it set Qt6Core5Compat_FOUND to FALSE so package "Qt6Core5Compat" is
considered to be NOT FOUND. Reason given by package:
Qt6Core5Compat could not be found because dependency Qt6Core could not be
found.
Call Stack (most recent call first):
CMakeLists.txt:31 (find_package)
CMake Error at CMakeLists.txt:31 (find_package):
Found package configuration file:
/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6/Qt6Config.cmake
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:
Failed to find Qt component "Core".
Expected Config file at
"/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake"
exists
Failed to find Qt component "Xml".
Expected Config file at
"/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Xml/Qt6XmlConfig.cmake"
exists
Failed to find Qt component "Core5Compat".
Expected Config file at
"/home/jcfr/Support/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake"
exists
Technically, Qt 5.15 is supported in open-source Rocky Linux 9 until 31 May 2032 and in open-source Rocky Linux 8 until 31 May 2029. It depends on your definition of support. Early 2030s seems like a good time to start looking at using Qt 6 as it might appear in LTS distros by then and may have reached a stability point of view like 5.15 :-) It will be interesting to see what RHEL/Rocky 10 ships with.
The CommonTK organization primarily supports applications such as 3D Slicer and MITK. Since 3D Slicer is cross platform (Windows/macOS/Linux distros), it will soon support Qt 6 which will then be utilized by the published binaries. Although Qt 5.15 support isn't likely to be removed from this CommonTK fork of PythonQt, the applications that use it will be primarily developing on Qt 6 since Qt 5.15 extended support for open-source is limited as it is primarily for paying commercial license holders. 3D Slicer is quick to drop support to support new functionality with limited developer resources and generally only supports hardware up to 5 years old.