KDAB / GammaRay

GammaRay is a tool to poke around in a Qt-application and also to manipulate the application to some extent.
https://www.kdab.com/gammaray
Other
1.61k stars 283 forks source link

Updated ECM dependencies require use of BUILD_WITH_QT6 option (instead of / in addition to GAMMARAY_QT6_BUILD) #742

Closed ferdnyc closed 1 year ago

ferdnyc commented 1 year ago

With #740 fixed and the QtVersionOption.cmake file now present in the repo, it appears that the option it provides, BUILD_WITH_QT6, must be enabled when configuring to build the Qt6 version of GammaRay, if Qt5 is also present on the build system. (Or, the QT_MAJOR_VERSION variable can be manually set to 6, which is effectively what happens when the BUILD_WITH_QT6 option is enabled.)

Regardless of the setting of other options (like GAMMARAY_QT6_BUILD), or the placement of Qt6 paths in the usual locations (CMAKE_PREFIX_PATH / the PATH environment variable, etc.), if QT_MAJOR_VERSION is not defined and BUILD_WITH_QT6 is not set, QtVersionOption.cmake will default to configuring for Qt5. This can lead to difficult-to-diagnose errors when running CMake.

(That's an understatement. The errors are, quite frankly, bizarre. For example, the Qt6 CMake configuration might error out with a complaint that qt_generate_foreign_qml_types() is only available in Qt 6:

$ cmake -B x86_64-redhat-linux-gnu_qt6 -S . -DGAMMARAY_QT6_BUILD:BOOL=TRUE                               
-- The CXX compiler identification is GNU 12.2.1
-- The C compiler identification is GNU 12.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to Release as none was specified.
-- Found libdw: /usr/lib64/libdw.so  
-- Found libbfd: /usr/lib64/libbfd.so  
-- Could NOT find libdwarf (missing: LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR) 
-- Found Backward: ...GammaRay/3rdparty/backward-cpp  
-- Building GammaRay 2.99.50 in Release mode
-- Performing Test C_SUPPORTS_UNUSED_BUT_SET
-- Performing Test C_SUPPORTS_UNUSED_BUT_SET - Success
-- Performing Test CXX_SUPPORTS_UNUSED_BUT_SET
-- Performing Test CXX_SUPPORTS_UNUSED_BUT_SET - Success
-- Performing Test C_SUPPORTS_LOGICAL_OP
-- Performing Test C_SUPPORTS_LOGICAL_OP - Success
-- Performing Test CXX_SUPPORTS_LOGICAL_OP
-- Performing Test CXX_SUPPORTS_LOGICAL_OP - Success
-- Performing Test C_SUPPORTS_POINTER_MEMACCESS
-- Performing Test C_SUPPORTS_POINTER_MEMACCESS - Success
-- Performing Test CXX_SUPPORTS_POINTER_MEMACCESS
-- Performing Test CXX_SUPPORTS_POINTER_MEMACCESS - Success
-- Performing Test C_SUPPORTS_REORDER
-- Performing Test C_SUPPORTS_REORDER - Failed
-- Performing Test CXX_SUPPORTS_REORDER
-- Performing Test CXX_SUPPORTS_REORDER - Success
-- Performing Test C_SUPPORTS_FORMAT_SECURITY
-- Performing Test C_SUPPORTS_FORMAT_SECURITY - Failed
-- Performing Test CXX_SUPPORTS_FORMAT_SECURITY
-- Performing Test CXX_SUPPORTS_FORMAT_SECURITY - Failed
-- Performing Test C_SUPPORTS_SUGGEST_OVERRIDE
-- Performing Test C_SUPPORTS_SUGGEST_OVERRIDE - Failed
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE - Success
-- Performing Test HAVE_GXX_GNUXX11
-- Performing Test HAVE_GXX_GNUXX11 - Success
-- Performing Test HAVE_GXX_CXX11
-- Performing Test HAVE_GXX_CXX11 - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenGL: /usr/lib64/libOpenGL.so   
-- Found WrapOpenGL: TRUE  
-- Found XKB: /usr/lib64/libxkbcommon.so (found suitable version "1.4.0", minimum required is "0.5.0") 
-- Found WrapVulkanHeaders: /usr/include  
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
CMake Error at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:2092 (message):
  qt_generate_foreign_qml_types() is only available in Qt 6.
Call Stack (most recent call first):
  /usr/lib64/cmake/Qt6Qml/Qt6QmlConfig.cmake:125 (include)
  /usr/share/cmake/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  /usr/lib64/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  /usr/lib64/cmake/Qt63DQuick/Qt63DQuickDependencies.cmake:96 (_qt_internal_find_dependencies)
  /usr/lib64/cmake/Qt63DQuick/Qt63DQuickConfig.cmake:50 (include)
  /usr/lib64/cmake/Qt6/Qt6Config.cmake:223 (find_package)
  CMakeLists.txt:449 (find_package)

-- Configuring incomplete, errors occurred!

Tracing the execution of ECMQueryQt.cmake will eventually reveal that it is configuring for Qt5, despite the command-line parameters pointing at Qt6 as the desired version.

Adding -DBUILD_WITH_QT6=TRUE eliminates the error:

$ rm -r x86_64-redhat-linux-gnu_qt6; cmake -B x86_64-redhat-linux-gnu_qt6 -S . -DGAMMARAY_QT6_BUILD:BOOL=TRUE -DBUILD_WITH_QT6=TRUE
-- The CXX compiler identification is GNU 12.2.1
-- The C compiler identification is GNU 12.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to Release as none was specified.
-- Found libdw: /usr/lib64/libdw.so  
-- Found libbfd: /usr/lib64/libbfd.so  
-- Could NOT find libdwarf (missing: LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR) 
-- Found Backward: ...GammaRay/3rdparty/backward-cpp  
-- Building GammaRay 2.99.50 in Release mode
-- Performing Test C_SUPPORTS_UNUSED_BUT_SET
-- Performing Test C_SUPPORTS_UNUSED_BUT_SET - Success
-- Performing Test CXX_SUPPORTS_UNUSED_BUT_SET
-- Performing Test CXX_SUPPORTS_UNUSED_BUT_SET - Success
-- Performing Test C_SUPPORTS_LOGICAL_OP
-- Performing Test C_SUPPORTS_LOGICAL_OP - Success
-- Performing Test CXX_SUPPORTS_LOGICAL_OP
-- Performing Test CXX_SUPPORTS_LOGICAL_OP - Success
-- Performing Test C_SUPPORTS_POINTER_MEMACCESS
-- Performing Test C_SUPPORTS_POINTER_MEMACCESS - Success
-- Performing Test CXX_SUPPORTS_POINTER_MEMACCESS
-- Performing Test CXX_SUPPORTS_POINTER_MEMACCESS - Success
-- Performing Test C_SUPPORTS_REORDER
-- Performing Test C_SUPPORTS_REORDER - Failed
-- Performing Test CXX_SUPPORTS_REORDER
-- Performing Test CXX_SUPPORTS_REORDER - Success
-- Performing Test C_SUPPORTS_FORMAT_SECURITY
-- Performing Test C_SUPPORTS_FORMAT_SECURITY - Failed
-- Performing Test CXX_SUPPORTS_FORMAT_SECURITY
-- Performing Test CXX_SUPPORTS_FORMAT_SECURITY - Failed
-- Performing Test C_SUPPORTS_SUGGEST_OVERRIDE
-- Performing Test C_SUPPORTS_SUGGEST_OVERRIDE - Failed
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE - Success
-- Performing Test HAVE_GXX_GNUXX11
-- Performing Test HAVE_GXX_GNUXX11 - Success
-- Performing Test HAVE_GXX_CXX11
-- Performing Test HAVE_GXX_CXX11 - Success
-- Found Threads: TRUE  
-- Found OpenGL: /usr/lib64/libOpenGL.so   
-- Found WrapOpenGL: TRUE  
-- Found XKB: /usr/lib64/libxkbcommon.so (found suitable version "1.4.0", minimum required is "0.5.0") 
-- Found WrapVulkanHeaders: /usr/include  
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
-- Found Wayland_Client: /usr/lib64/libwayland-client.so (found version "1.21.0") 
-- Found Wayland_Server: /usr/lib64/libwayland-server.so (found version "1.21.0") 
-- Found Wayland_Cursor: /usr/lib64/libwayland-cursor.so (found version "1.21.0") 
-- Found Wayland_Egl: /usr/lib64/libwayland-egl.so (found version "18.1.0") 
-- Performing Test C_SUPPORTS_ZERO_AS_NULL_POINTER_CONSTANT
-- Performing Test C_SUPPORTS_ZERO_AS_NULL_POINTER_CONSTANT - Failed
-- Performing Test CXX_SUPPORTS_ZERO_AS_NULL_POINTER_CONSTANT
-- Performing Test CXX_SUPPORTS_ZERO_AS_NULL_POINTER_CONSTANT - Success
-- Looking for QT_NO_OPENGL
-- Looking for QT_NO_OPENGL - not found
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for backtrace
-- Looking for backtrace - found
-- Looking for abi::__cxa_demangle
-- Looking for abi::__cxa_demangle - found
-- Building probe for ABI: qt6_3-x86_64 (Release)
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Performing Test HAVE_NO_CXX_ZERO_AS_NULL_POINTER_CON
-- Performing Test HAVE_NO_CXX_ZERO_AS_NULL_POINTER_CON - Success
-- Performing Test HAVE_NO_CXX_UNNEEDED_INTERNAL_DEC
-- Performing Test HAVE_NO_CXX_UNNEEDED_INTERNAL_DEC - Success
-- Performing Test HAVE_NO_CXX_NULL_CONVERSION
-- Performing Test HAVE_NO_CXX_NULL_CONVERSION - Success
-- WARNING: Skipping the translatortest since the translations are not installed.
-- Found Wayland: /usr/lib64/libwayland-client.so;/usr/lib64/libwayland-server.so;/usr/lib64/libwayland-cursor.so;/usr/lib64/libwayland-egl.so (found suitable version "1.21.0", minimum required is "1.12") found components: Server 
-- Unable to build user manual in qch format.
-- qdoc executable: /usr/lib64/qt6/bin/qdoc
-- qhelpgenerator executable: /usr/bin/qhelpgenerator
-- qtattributionsscanner executable: QTATTRIBUTIONSSCANNER_EXECUTABLE-NOTFOUND
-- qdoc template (qt-html-templates-offline.qdocconf): /usr/share/doc/qt6/global/qt-html-templates-offline.qdocconf
-- qdoc qtcore index (qtcore.index): QDOC_QTCORE_INDEX-NOTFOUND
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.1") found components: doxygen dot 
-- The following features have been enabled:

 * Option GAMMARAY_BUILD_UI, Build the GammaRay client and in-process UI.
 * Option GAMMARAY_MULTI_BUILD, Build multiple applicable probe configurations.
 * Option GAMMARAY_BUILD_CLI_INJECTOR, Build command line injector on Windows.
 * Option GAMMARAY_BUILD_DOCS, Build GammaRay documentation.
 * Option GAMMARAY_QT6_BUILD, Build with Qt6.
 * Widget .ui file export, Requires QtDesigner library.
 * ELF ABI detection, Automatic probe ABI detection on ELF-based systems. Requires elf.h.

-- The following OPTIONAL packages have been found:

 * OpenGL
 * XKB (required version >= 0.5.0), XKB API common to servers and clients., <http://xkbcommon.org>
 * Vulkan
 * Qt6GuiTools (required version >= 6.3.1)
 * Qt6CoreTools (required version >= 6.3.1)
 * Qt6DBusTools (required version >= 6.3.1)
 * Qt6Gui
 * Qt6Network
 * Qt63DAnimation
 * Qt63DExtras
 * Qt63DInput
 * Qt63DLogic
 * Qt63DRender
 * Qt63DQuick
 * Qt6Bluetooth
 * Qt6Designer
 * Qt6OpenGL
 * Qt6Positioning
 * Qt6QmlTools (required version >= 6.3.1)
 * Qt6Qml
 * Qt6Quick
 * WrapVulkanHeaders
 * Qt6QuickWidgets
 * Qt6Svg
   Required for widget SVG export.
 * Qt6Test
 * Qt6WaylandScannerTools (required version >= 6.3.1)
 * Qt6WaylandCompositor
 * Qt6ScxmlTools (required version >= 6.3.1)
 * Qt6Scxml (required version >= 5.8)
 * Qt6Help
 * Qt6LinguistTools
 * Qt6WidgetsTools (required version >= 6.3.1)
 * Qt6Widgets
 * QmlLint, <https://qt.io>
   Validate QML code.
 * PkgConfig
 * Wayland (required version >= 1.12), C library implementation of the Wayland protocol: a protocol for a compositor to talk to its clients, <https://wayland.freedesktop.org/>
   Needed for the QtWayland compositor inspector plug-in.
 * Doxygen, API Documentation system, <https://www.doxygen.org>
   Needed to build the API documentation.

-- The following RECOMMENDED packages have been found:

 * Qt6Concurrent
   Required for the GammaRay launcher process list.
 * pod2man, Man page generator
   Generate GammaRay man pages.

-- The following REQUIRED packages have been found:

 * Qt (required version >= 5.5)
 * Qt6, <https://qt.io/>

-- The following features have been disabled:

 * Option GAMMARAY_PROBE_ONLY_BUILD, Build only an additional probe configuration for an already existing launcher.
 * Option GAMMARAY_CLIENT_ONLY_BUILD, Build the client part only.
 * Option GAMMARAY_ENABLE_GPL_ONLY_FEATURES, Enable features only available under GPL license.
 * Option GAMMARAY_INSTALL_QT_LAYOUT, Install into Qt directory layout.
 * Option GAMMARAY_STATIC_PROBE, Build the probe as static library for compile-time injection.
 * Option GAMMARAY_ENFORCE_QT_ASSERTS, Force QT_ASSERT in all builds.
 * Option GAMMARAY_DISABLE_FEEDBACK, Disable user feedback support.
 * Option GAMMARAY_USE_PCH, Enable Precompiled Headers support
 * Option ENABLE_GOLD_LINKER, Use GNU gold linker
 * Option GAMMARAY_CORE_ONLY_LAUNCHER, Only use QtCore in the CLI launcher (breaks style injector, but is needed for Boot2Qt compatibility)
 * QtScript debugger, Requires QtScript and QtScriptTools.
 * User Manual creation in qch format, Requires qdoc, qhelpgenerator, qtattributionsscanner, the qdoc templates and index files

-- The following OPTIONAL packages have not been found:

 * Qt6QmlCompilerPlusPrivate
 * Qt6Location
 * Qt6Script
 * Qt6ScriptTools
 * Qt6WebEngineWidgets
 * Qt6IviCore (required version >= 1.1)
 * Qt6IviVehicleFunctions (required version >= 1.1)
 * Qt6IviMedia (required version >= 1.1)
 * KF6CoreAddons, KDE KCoreAddons Framework, <https://www.kde.org/>
   Required for the KJob tracker plug-in.

-- The following RECOMMENDED packages have not been found:

 * KF6SyntaxHighlighting (required version >= 5.28), <https://www.kde.org/>
   Syntax highlighting for code editor.

-- Configuring done
-- Generating done
-- Build files have been written to: ...GammaRay/x86_64-redhat-linux-gnu_qt6

Part of the issue here, and the reason that the ECM option has to be set by the user, is that the ECM probes for Qt version are triggered at the include(ECMGeneratePriFile) on line 149 of the CMakeLists.txt, long before the Qt configuration is started.

As soon as that ECM file is include()ed, the ECMQueryQt.cmake and QtVersionOption.cmake logic is triggered, causing the build to be configured for Qt5 even if the GammaRay configs later try to override that and enable Qt6.

Suggested fix(es)

  1. Don't include(ECMGeneratePriFile) so early in the root CMakeLists.txt; move it down to the includes placed "after the last Qt-related find_package() call" (as the comment above explains).
  2. Set QT_MAJOR_VERSION to 6 if GAMMARAY_QT6_BUILD is enabled for the build, to ensure that the ECM code follows GammaRay's lead.
ferdnyc commented 1 year ago

I'll repeat the information I included when closing #743 unmerged:

I've decided to abandon [that] change — building GammaRay is possible without it, although it requires some hoop-jumping.

(For example, on Fedora 38 with both Qt5 and Qt6 installed on the system...)

Otherwise, the build will pick bits from the wrong Qt for at least some of its dependencies.

I feel this could be improved with changes to the root CMakeLists.txt that would better integrate it with ECM's own Qt probe/detection logic, but it's not a showstopper and command-line workarounds are possible with not too much effort.

ferdnyc commented 1 year ago

This situation has been changed enough by recent commits that this report is no longer current, closing.