From f0fcc88a24bb8f1b9bf7b22597cd49a9f976e304 Mon Sep 17 00:00:00 2001 From: Denis Arnst Date: Tue, 20 Feb 2024 23:00:36 +0100 Subject: [PATCH] Test CI --- .github/workflows/build-windows.yml | 4 +- .github/workflows/build.yml | 31 ++++--------- .gitignore | 2 + CMakeLists.txt | 12 +++++ CMakePresets.json | 71 +++++++++++++++++++++++++++++ vcpkg.json | 7 +++ 6 files changed, 104 insertions(+), 23 deletions(-) create mode 100644 CMakePresets.json create mode 100644 vcpkg.json diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 12dc153..fddf2db 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -8,7 +8,7 @@ jobs: run: shell: msys2 {0} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: msystem: MINGW64 @@ -25,7 +25,7 @@ jobs: cd build make test - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: headsetcontrol.exe path: build/headsetcontrol.exe diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89ded00..9b84a35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,31 +15,20 @@ jobs: include: - os: ubuntu-latest triplet: x64-linux - INSTALL_DEPS: sudo apt-get -y install libhidapi-dev - os: macos-latest triplet: x64-osx - INSTALL_DEPS: brew install hidapi steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest - - name: Install Dependencies - run: ${{ matrix.INSTALL_DEPS }} - - - name: dir - run: find $RUNNER_WORKSPACE - shell: bash - - name: Run CMake with Ninja - uses: lukka/run-cmake@v3 - id: runcmake + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 with: - cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - buildWithCMakeArgs: '-- -v' - buildDirectory: ${{ env.buildDir }} - - - name: Run test - run: cd ${{ env.buildDir }} && ctest + vcpkgGitCommitId: 'fba75d09065fcc76a25dcf386b1d00d33f5175af' - - name: dir - run: find $RUNNER_WORKSPACE - shell: bash + - name: Run CMake consuming CMakePreset.json and run vcpkg to build packages + uses: lukka/run-cmake@v10 + with: + configurePreset: 'release' + buildPreset: 'release-build' + testPreset: 'release-test' diff --git a/.gitignore b/.gitignore index 43a75c3..910f2c1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ cmake-build-debug/ .vscode/* *.code-workspace +vcpkg_installed/ + .DS_Store \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c68a5b..4477d58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ project(headsetcontrol LANGUAGES C) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") set(CLANG_FORMAT_EXCLUDE_PATTERNS "build/") +set(HIDAPI_BUILD_PP_DATA_DUMP OFF) +set(HIDAPI_BUILD_HIDTEST OFF) + find_package(hidapi REQUIRED) # ------------------------------------------------------------------------------ @@ -165,6 +168,15 @@ endif() # ------------------------------------------------------------------------------ add_executable(headsetcontrol ${SOURCE_FILES}) + +if(APPLE) + # Link against CoreFoundation and IOKit frameworks on macOS + find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) + find_library(IOKIT_FRAMEWORK IOKit) + find_library(APPKIT_FRAMEWORK AppKit) + target_link_libraries(headsetcontrol ${CORE_FOUNDATION_FRAMEWORK} ${IOKIT_FRAMEWORK} ${APPKIT_FRAMEWORK}) +endif() + target_link_libraries(headsetcontrol m ${HIDAPI_LIBRARIES}) install(TARGETS headsetcontrol DESTINATION bin) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..3b6942c --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,71 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 19, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "hidden": true, + "description": "Use 'debug' or 'release' presets", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES" + } + }, + { + "name": "debug", + "inherits": "default", + "description": "Configure for Debug build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "release", + "inherits": "default", + "description": "Configure for Release build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ], + "buildPresets": [ + { + "name": "default-build", + "hidden": true, + "configurePreset": "default" + }, + { + "name": "debug-build", + "inherits": "default-build", + "configurePreset": "debug" + }, + { + "name": "release-build", + "inherits": "default-build", + "configurePreset": "release" + } + ], + "testPresets": [ + { + "name": "default-test", + "hidden": true, + "configurePreset": "default" + }, + { + "name": "debug-test", + "inherits": "default-test", + "configurePreset": "debug" + }, + { + "name": "release-test", + "inherits": "default-test", + "configurePreset": "release" + } + ] + } + \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..28be44d --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "headsetcontrol", + "version-string": "1.0.0", + "dependencies": [ + "hidapi" + ] +}