Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/CMAKE_PREFIX_PATH for find_package Qt Version #370

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions cmake/QskFindMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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() 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)
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
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials/03-writing-your-first-application.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,14 +74,13 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt5 REQUIRED COMPONENTS Widgets Quick)
find_package(Qt5 REQUIRED COMPONENTS Quick)
find_package(QSkinny REQUIRED)

add_executable(myapp
src/main.cpp)

target_link_libraries(myapp PRIVATE
Qt5::Widgets
Qt5::Quick
QSkinny::QSkinny)
....
Expand Down Expand Up @@ -123,6 +122,7 @@ int main( int argc, char* argv[] )
QGuiApplication app( argc, argv );

auto* horizontalBox = new QskLinearBox( Qt::Horizontal );
horizontalBox->setPanel( true );
auto* button1 = new QskPushButton( "button 1", horizontalBox );
auto* button2 = new QskPushButton( "button 2", horizontalBox );

Expand Down