CMake support for qt-version we are linking to
-
@TomZ said in CMake support for qt-version we are linking to:
no longer has any value like it did
It has.
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Sql) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Sql) message(STATUS "Qt version: ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") --> -- Qt version: 6.5.0
-
@TomZ said in CMake support for qt-version we are linking to:
Weird, but I'm happy it does the trick!
The first find_package() already sets it.
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Sql) message(STATUS "Qt version: ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Sql) message(STATUS "Qt version: ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") --> -- Qt version: 6.5.0 -- Qt version: 6.5.0
-
Is there something special about the usage of NAMES with the call that fills those variables?
My usage (since my code won't compile against Qt5) was simply;
find_package(Qt6 COMPONENTS Core Quick Svg REQUIRED OPTIONAL_COMPONENTS Multimedia)
Which did not set the version variables.
So I needed to add the otherwise unneeded line
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
in order to get those variables.
I don't understand the logic why my first line doesn't generate the version variables. Not sure if I care enough if you don't know, but if you know if this is a bug or if this is just me not knowing cmake well enough, I'd be happy to learn.Full cmake file here.
-
Ok, I can see the problem. Imo they should also be set without the first call but they are not. Will take a look on it.
-
I must say - those variables were also not set with Qt5. There I relied on e.g. 'Qt5Core_VERSION'
-
Hello
I am trying desperately to get this working, it is not.
I am not sure what I am doing wrong.
Is there a special path or something?
For some reason, it is not detecting Qt6
I am using Manjaro