Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patched-9] Update PythonQtGenerator CMake build-system to support Qt5 and Qt6 #89

Open
wants to merge 1 commit into
base: patched-9
Choose a base branch
from

Conversation

jcfr
Copy link
Member

@jcfr jcfr commented Jan 31, 2024

This removes Qt4 support and adds support for Qt5 and Qt6.

@jcfr
Copy link
Member Author

jcfr commented Jan 31, 2024

After #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 jamesobutler@dfa14ff

cc: @jamesobutler

@jcfr jcfr force-pushed the patched-9_update-generate-cmakelists branch from 5ece53c to 58781ab Compare January 31, 2024 03:14
This removes Qt4 support and adds support for Qt5 and Qt6.
@jcfr jcfr force-pushed the patched-9_update-generate-cmakelists branch from 58781ab to aa976ba Compare January 31, 2024 03:34
@jcfr
Copy link
Member Author

jcfr commented Jan 31, 2024

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

@jcfr jcfr changed the title Update PythonQtGenerator CMake build-system to support Qt5 and Qt6 [patched-9] Update PythonQtGenerator CMake build-system to support Qt5 and Qt6 Jan 31, 2024
Copy link

@jamesobutler jamesobutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not surprisingly about the update to Qt >= 6.5 as that is what the upstream is testing against. Qt 6.2 LTS commercial support ends later this year. Ultimately the only thing really supported for open source is the latest release of Qt.

Also it appears that upstream may be adding Qt 5.15 generated bindings (MeVisLab/pythonqt#183) which could probably be compared to what is created here through the CMake build system.

@he-hesce
Copy link

he-hesce commented Feb 2, 2024

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.

@jamesobutler
Copy link

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.

thienhung1989 pushed a commit to billow-vn/PythonQt that referenced this pull request Mar 1, 2024
(cherry-picked and adapted from MeVisLab/pythonqt@1e794e5)

* minor improvements in code and unit tests
* disable warnings for deprecated declarations
* add -Wpedantic and even -Werror for src, but relax some warnings
* fix undefined behavior
* fix memory leaks
* use QT_NO_CAST_TO_ASCII  to prevent incorrect behavior on non-Latin1 input

* Improvements in build and CI:
** add parallel build
** add `make check` support
** fix `debug`/`release` builds
** force C++11
** introduce UBSan into CI
** fixes for macOS build with clang
** add pkg-config support:
  if PKGCONFIG is set, skip old-style lookup (useful on Linux and macOS GHA,
  when `python-config` returns incorrect linkage options with missing `-Ldirs`)
** add macOS GHA CI
thienhung1989 pushed a commit to billow-vn/PythonQt that referenced this pull request Mar 1, 2024
- this has been introduced in commontk#89 and breaks builds including "pythread.h"
- fixes #103

(cherry picked from commit MeVisLab/pythonqt@30ca585)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants