diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0467049 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build + +on: + push: + branches-ignore: + - "releases/**" + paths-ignore: + - "**.md" + +jobs: + build: + strategy: + matrix: + qt_version: [5.12.11, 5.15.2, 6.2.0] + platform: [ubuntu-20.04, windows-latest, macos-latest] + include: + - qt_version: 6.2.0 + additional_arguments: -D QT_MAJOR=6 + - platform: ubuntu-20.04 + make: make + CXXFLAGS: -Wall -Wextra -pedantic -Werror + MAKEFLAGS: -j2 + - platform: macos-latest + make: make + CXXFLAGS: -Wall -Wextra -pedantic -Werror -Wno-gnu-zero-variadic-macro-arguments # Ignore false-positive warning for qCWarning + MAKEFLAGS: -j3 + - platform: windows-latest + make: nmake + CXXFLAGS: /W4 /WX /MP + + runs-on: ${{ matrix.platform }} + env: + CXXFLAGS: ${{ matrix.CXXFLAGS }} + MAKEFLAGS: ${{ matrix.MAKEFLAGS }} + + steps: + - name: Clone repo + uses: actions/checkout@v2.3.4 + + - name: Install Qt + uses: jurplel/install-qt-action@v2.14.0 + with: + version: ${{ matrix.qt_version }} + + - name: Build with CMake + run: | + cmake . -D QHOTKEY_EXAMPLES=ON ${{ matrix.additional_arguments }} + cmake --build . + + - name: Setup MSVC environment for QMake + uses: ilammy/msvc-dev-cmd@v1 + + - name: Build with QMake + working-directory: HotkeyTest + run: | + qmake + ${{ matrix.make }} diff --git a/CMakeLists.txt b/CMakeLists.txt index df165bc..fe49287 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ option(QHOTKEY_EXAMPLES "Build examples" OFF) option(QHOTKEY_INSTALL "Enable install rule" ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_AUTOMOC ON) set(QT_MAJOR 5 CACHE STRING "Qt major version to use") @@ -15,17 +16,7 @@ else() find_package(Qt${QT_MAJOR} COMPONENTS Core Gui REQUIRED) endif() -if(QT_MAJOR GREATER_EQUAL 6) - qt_wrap_cpp(MOC_HEADERS - QHotkey/qhotkey.h - QHotkey/qhotkey_p.h) -else() - qt5_wrap_cpp(MOC_HEADERS - QHotkey/qhotkey.h - QHotkey/qhotkey_p.h) -endif() - -add_library(qhotkey QHotkey/qhotkey.cpp ${MOC_HEADERS}) +add_library(qhotkey QHotkey/qhotkey.cpp) add_library(QHotkey::QHotkey ALIAS qhotkey) target_link_libraries(qhotkey PUBLIC Qt${QT_MAJOR}::Core) target_link_libraries(qhotkey PRIVATE Qt${QT_MAJOR}::Gui) @@ -43,7 +34,7 @@ else() if(QT_MAJOR GREATER_EQUAL 6) target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES}) else() - find_package(Qt${QT_MAJOR}X11Extras REQUIRED) + find_package(Qt${QT_MAJOR} COMPONENTS X11Extras REQUIRED) target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES} diff --git a/HotkeyTest/CMakeLists.txt b/HotkeyTest/CMakeLists.txt index 6915fb3..17d3f2e 100644 --- a/HotkeyTest/CMakeLists.txt +++ b/HotkeyTest/CMakeLists.txt @@ -1,17 +1,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) -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() +set(CMAKE_AUTOUIC ON) add_executable(HotkeyTest main.cpp hottestwidget.cpp - ${test_UI_HEADERS} - ${test_MOC_HEADERS}) -target_link_libraries(HotkeyTest Qt${QT_MAJOR}::Widgets qhotkey) -target_include_directories(HotkeyTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + hottestwidget.ui) + +find_package(Qt${QT_MAJOR} COMPONENTS Widgets REQUIRED) +target_link_libraries(HotkeyTest Qt${QT_MAJOR}::Widgets QHotkey::QHotkey) diff --git a/QHotkey/qhotkey_p.h b/QHotkey/qhotkey_p.h index d1bd1d2..d588270 100644 --- a/QHotkey/qhotkey_p.h +++ b/QHotkey/qhotkey_p.h @@ -59,7 +59,4 @@ private: return hotkeyPrivate;\ } -Q_DECLARE_METATYPE(Qt::Key) -Q_DECLARE_METATYPE(Qt::KeyboardModifiers) - #endif // QHOTKEY_P_H