Why would QT_VERSION_MAJOR be empty?
Unsolved
General and Desktop
-
We have a Qt 6 CMake-based project. In CMakeLists, we try to concatenate the Qt version like so:
Qt${QT_VERSION_MAJOR}::Core
This was failing, apparently because QT_VERSION_MAJOR is an empty string. Why would that be?
-
Hi @Stokestack,
QT_VERSION_MAJOR
is set byfind_package(QT ...)
, so either it failed, or you didn't call it.Do you have something like this before you use
Qt${QT_VERSION_MAJOR}::Core
?find_package(QT REQUIRED COMPONENTS Core NAMES Qt6 Qt5) message(STATUS "Found Qt ${Qt${QT_VERSION_MAJOR}_VERSION}")
The
message()
is optional, and just for diagnostics, but I like to include it in my projects.If your
find_package()
doesn't includeREQUIRED
, then you should also check the package (Qt) was actually found.Cheers.