use CMAKE_PREFIX_PATH to specify Qt version for find_package() call

This commit is contained in:
Alexander Kavon 2024-01-18 19:14:55 -05:00
parent 3f9fa56ea2
commit 42230d5d0c
2 changed files with 8 additions and 11 deletions

View File

@ -5,15 +5,12 @@
macro(qsk_setup_Qt)
# Use QSK_QT_VERSION specified with baseline 5.15
# otherwise fallback to latest known supported Qt version gte 5.15
# set vars for correct alpha descending sort order and direction (ex. Qt6, Qt5)
if ( NOT QSK_QT_VERSION ) # QSK_QT_VERSION=Qt5
set(QSK_QT_VERSION Qt6 Qt5)
# find_package() sort order and direction bug
# where Qt6 is not considered before Qt5
# bug link: https://gitlab.kitware.com/cmake/cmake/-/issues/23575
set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
endif()
find_package(QT "5.15" NAMES ${QSK_QT_VERSION} REQUIRED COMPONENTS Quick)
find_package(QT "5.15" NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick)
if(QT_VERSION_MAJOR VERSION_GREATER_EQUAL 6)
# we need the qsb tool for Qt6

View File

@ -27,11 +27,11 @@ $ cmake ../ && make # build
$ sudo make install # install
....
To target a specific Qt version simply pass the cmake build variable `QSK_QT_VERSION` during the build step:
To target a specific Qt version simply pass the cmake build variable `CMAKE_PREFIX_PATH` during the build step:
[source,shell]
....
$ cmake -DQSK_QT_VERSION=Qt5 ../ && make
$ cmake -DCMAKE_PREFIX_PATH=/usr/local/Qt-6.7.0 ../ && make
....
=== Compiling our first app