Skip to content

Commit fcf83f3

Browse files
committed
Use QT_DEFAULT_MAJOR_VERSION
1 parent 64fec66 commit fcf83f3

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
platform: [ubuntu-20.04, windows-latest, macos-latest]
1919
include:
2020
- qt_version: 6.2.0
21-
additional_arguments: -D QT_MAJOR=6
21+
additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6
2222
- platform: ubuntu-20.04
2323
make: make
2424
CXXFLAGS: -Wall -Wextra -pedantic -Werror

CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ option(QHOTKEY_INSTALL "Enable install rule" ON)
88
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
99
set(CMAKE_AUTOMOC ON)
1010

11-
set(QT_MAJOR 5 CACHE STRING "Qt major version to use")
11+
if(NOT QT_DEFAULT_MAJOR_VERSION)
12+
set(QT_DEFAULT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
13+
endif()
1214

13-
if(QT_MAJOR EQUAL 6)
14-
find_package(Qt${QT_MAJOR} 6.2.0 COMPONENTS Core Gui REQUIRED)
15+
if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
16+
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} 6.2.0 COMPONENTS Core Gui REQUIRED)
1517
else()
16-
find_package(Qt${QT_MAJOR} COMPONENTS Core Gui REQUIRED)
18+
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Core Gui REQUIRED)
1719
endif()
1820

1921
add_library(qhotkey QHotkey/qhotkey.cpp)
2022
add_library(QHotkey::QHotkey ALIAS qhotkey)
21-
target_link_libraries(qhotkey PUBLIC Qt${QT_MAJOR}::Core)
22-
target_link_libraries(qhotkey PRIVATE Qt${QT_MAJOR}::Gui)
23+
target_link_libraries(qhotkey PUBLIC Qt${QT_DEFAULT_MAJOR_VERSION}::Core)
24+
target_link_libraries(qhotkey PRIVATE Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
2325

2426
if(BUILD_SHARED_LIBS)
2527
target_compile_definitions(qhotkey PRIVATE QHOTKEY_LIBRARY)
@@ -36,14 +38,14 @@ elseif(WIN32)
3638
target_sources(qhotkey PRIVATE QHotkey/qhotkey_win.cpp)
3739
else()
3840
find_package(X11 REQUIRED)
39-
if(QT_MAJOR GREATER_EQUAL 6)
41+
if(QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6)
4042
target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES})
4143
else()
42-
find_package(Qt${QT_MAJOR} COMPONENTS X11Extras REQUIRED)
44+
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS X11Extras REQUIRED)
4345
target_link_libraries(qhotkey
4446
PRIVATE
4547
${X11_LIBRARIES}
46-
Qt${QT_MAJOR}::X11Extras)
48+
Qt${QT_DEFAULT_MAJOR_VERSION}::X11Extras)
4749
endif()
4850

4951
include_directories(${X11_INCLUDE_DIR})

HotkeyTest/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ add_executable(HotkeyTest
77
hottestwidget.cpp
88
hottestwidget.ui)
99

10-
find_package(Qt${QT_MAJOR} COMPONENTS Widgets REQUIRED)
11-
target_link_libraries(HotkeyTest Qt${QT_MAJOR}::Widgets QHotkey::QHotkey)
10+
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Widgets REQUIRED)
11+
target_link_libraries(HotkeyTest Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets QHotkey::QHotkey)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy