Add support for Qt6 (#51)

CMake:
The 'QT_MAJOR' CMake variable controls which major version
of Qt is used for building. Defaults to '5', so nothing
changes when using the default 'cmake' invocation, as it
will default to search/build for Qt5.

qmake:
Just build in the usual way with 'qmake6 && make' or
'qmake-qt5 && make'.

When building with Qt6 on GNU/Linux and similar UNIXes,
the minimium required Qt version is 6.2.0, as Qt 6.1
and 6.0 lacks support for getting the X11 display.
This commit is contained in:
Daniel Bermond
2021-09-30 20:46:35 +03:00
committed by GitHub
parent eb7ddaba57
commit 25f21849b3
6 changed files with 112 additions and 25 deletions
+8 -3
View File
@@ -1,12 +1,17 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
qt5_wrap_ui(test_UI_HEADERS hottestwidget.ui)
qt5_wrap_cpp(test_MOC_HEADERS hottestwidget.h)
if(QT_MAJOR GREATER_EQUAL 6)
qt_wrap_ui(test_UI_HEADERS hottestwidget.ui)
qt_wrap_cpp(test_MOC_HEADERS hottestwidget.h)
else()
qt5_wrap_ui(test_UI_HEADERS hottestwidget.ui)
qt5_wrap_cpp(test_MOC_HEADERS hottestwidget.h)
endif()
add_executable(HotkeyTest
main.cpp
hottestwidget.cpp
${test_UI_HEADERS}
${test_MOC_HEADERS})
target_link_libraries(HotkeyTest Qt5::Widgets qhotkey)
target_link_libraries(HotkeyTest Qt${QT_MAJOR}::Widgets qhotkey)
target_include_directories(HotkeyTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})