@@ -8,18 +8,20 @@ option(QHOTKEY_INSTALL "Enable install rule" ON)
8
8
set (CMAKE_POSITION_INDEPENDENT_CODE ON )
9
9
set (CMAKE_AUTOMOC ON )
10
10
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 ()
12
14
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 )
15
17
else ()
16
- find_package (Qt${QT_MAJOR } COMPONENTS Core Gui REQUIRED )
18
+ find_package (Qt${QT_DEFAULT_MAJOR_VERSION } COMPONENTS Core Gui REQUIRED )
17
19
endif ()
18
20
19
21
add_library (qhotkey QHotkey/qhotkey.cpp )
20
22
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 )
23
25
24
26
if (BUILD_SHARED_LIBS )
25
27
target_compile_definitions (qhotkey PRIVATE QHOTKEY_LIBRARY )
@@ -36,14 +38,14 @@ elseif(WIN32)
36
38
target_sources (qhotkey PRIVATE QHotkey/qhotkey_win.cpp )
37
39
else ()
38
40
find_package (X11 REQUIRED )
39
- if (QT_MAJOR GREATER_EQUAL 6 )
41
+ if (QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6 )
40
42
target_link_libraries (qhotkey PRIVATE ${X11_LIBRARIES} )
41
43
else ()
42
- find_package (Qt${QT_MAJOR } COMPONENTS X11Extras REQUIRED )
44
+ find_package (Qt${QT_DEFAULT_MAJOR_VERSION } COMPONENTS X11Extras REQUIRED )
43
45
target_link_libraries (qhotkey
44
46
PRIVATE
45
47
${X11_LIBRARIES}
46
- Qt${QT_MAJOR }::X11Extras )
48
+ Qt${QT_DEFAULT_MAJOR_VERSION }::X11Extras )
47
49
endif ()
48
50
49
51
include_directories (${X11_INCLUDE_DIR} )
0 commit comments