Closed ferdnyc closed 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...)
GAMMARAY_QT6_BUILD=TRUE
QT_MAJOR_VERSION=6
, to appease ECMQt6_DIR=/usr/lib64/cmake/Qt6
GAMMARAY_QT6_BUILD=FALSE
QT_MAJOR_VERSION=5
Qt_DIR=/usr/lib64/cmake/Qt5
Qt5_DIR=/usr/lib64/cmake/Qt5
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.
This situation has been changed enough by recent commits that this report is no longer current, closing.
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, theQT_MAJOR_VERSION
variable can be manually set to6
, which is effectively what happens when theBUILD_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
/ thePATH
environment variable, etc.), ifQT_MAJOR_VERSION
is not defined andBUILD_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
: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: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 theCMakeLists.txt
, long before the Qt configuration is started.As soon as that ECM file is
include()
ed, theECMQueryQt.cmake
andQtVersionOption.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)
include(ECMGeneratePriFile)
so early in the rootCMakeLists.txt
; move it down to the includes placed "after the last Qt-related find_package() call" (as the comment above explains).QT_MAJOR_VERSION
to6
ifGAMMARAY_QT6_BUILD
is enabled for the build, to ensure that the ECM code follows GammaRay's lead.