From e55c6a4b46708233a6016a253156a8967442f3a8 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 2 May 2023 23:10:11 -0400 Subject: Does this work --- .github/workflows/build-binaries.yml | 93 ++++++++++++++++++++++++++++++++++++ .gitignore | 1 + CMakeLists.txt | 14 +++--- CMakePresets.json | 34 +++++++++++++ 4 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build-binaries.yml create mode 100644 CMakePresets.json diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml new file mode 100644 index 0000000..0ecff40 --- /dev/null +++ b/.github/workflows/build-binaries.yml @@ -0,0 +1,93 @@ +# Copyright (c) 2021-2022-2023 Luca Cappa +# Released under the term specified in file LICENSE.txt +# SPDX short identifier: MIT + +# A "pure" GitHub workflow using CMake, Ninja and vcpkg to build a C/C++ codebase. +# It leverages both CMakePresets.json and vcpkg.json. +# It is called "pure workflow" because it is an example which minimizes the usage of +# custom GitHub Actions, but leverages directly the tools that could be easily run on +# your development machines (i.e. CMake, vcpkg, Ninja) to ensure a perfectly identical +# and reproducible local build (on your development machine) and a remote build on +# build agents. +name: build-binaries +on: + workflow_dispatch: + +jobs: + job: + name: ${{ matrix.os }}-${{ github.workflow }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: windows-latest + triplet: x64-windows + - os: ubuntu-latest + triplet: x64-linux + - os: macos-latest + triplet: x64-osx + env: + # Indicates the location of the vcpkg as a Git submodule of the project repository. + VCPKG_ROOT: ${{ github.workspace }}/vendor/vcpkg + # Tells vcpkg where binary packages are stored. + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vendor/vcpkg/bincache + # Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature. + VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' + + steps: + # Set env vars needed for vcpkg to leverage the GitHub Action cache as a storage + # for Binary Caching. + - uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - uses: actions/checkout@v3 + with: + submodules: true + - name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'" + run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE + shell: bash + + # Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be +quickly restored from GitHub cache service. + - uses: lukka/get-cmake@latest + + # Restore vcpkg from the GitHub Action cache service. Note that packages are restored by vcpkg's binary caching + # when it is being run afterwards by CMake. + - name: Restore vcpkg + uses: actions/cache@v3 + with: + # The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the + # built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var. + # The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages. + path: | + ${{ env.VCPKG_ROOT }} + !${{ env.VCPKG_ROOT }}/buildtrees + !${{ env.VCPKG_ROOT }}/packages + !${{ env.VCPKG_ROOT }}/downloads + !${{ env.VCPKG_ROOT }}/installed + # The key is composed in a way that it gets properly invalidated whenever a different version of vcpkg is being used. + key: | + ${{ hashFiles( '.git/modules/vcpkg/HEAD' )}} + + # On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. + # As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK. + - uses: ilammy/msvc-dev-cmd@v1 + + # Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install + # the dependencies as specified in vcpkg.json. Note that the vcpkg's toolchain is specified + # in the CMakePresets.json file. + # This step also runs vcpkg with Binary Caching leveraging GitHub Action cache to + # store the built packages artifacts. + - name: Restore from cache the dependencies and generate project files + run: | + cmake --preset lingo-ap-tracker-preset + + # Build (Release configuration only) the whole project with Ninja (which is spawn by CMake). + - name: Build (Release configuration) + run: | + cmake --build --preset lingo-ap-tracker-preset --config Release diff --git a/.gitignore b/.gitignore index 3fac228..d008edb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ +builds/ assets/LL1.yaml .DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index 756c776..6d9a111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,9 @@ project (lingo_ap_tracker) set(CMAKE_BUILD_TYPE Debug) -find_package(wxWidgets COMPONENTS core base) -include(${wxWidgets_USE_FILE}) - -find_package(OpenSSL) -find_package(yaml-cpp) +find_package(wxWidgets CONFIG REQUIRED) +find_package(OpenSSL REQUIRED) +find_package(yaml-cpp REQUIRED) include_directories( vendor/hkutil @@ -18,8 +16,12 @@ include_directories( vendor/websocketpp vendor/wswrap/include ${yaml-cpp_INCLUDE_DIRS} + ${OpenSSL_INCLUDE_DIRS} ) +find_path(SYSTEM_INCLUDE_DIR zlib.h) +include_directories(${SYSTEM_INCLUDE_DIR}) + link_directories(${openssl_LIBRARY_DIRS}) add_executable(lingo_ap_tracker @@ -36,4 +38,4 @@ add_executable(lingo_ap_tracker ) set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) -target_link_libraries(lingo_ap_tracker ${wxWidgets_LIBRARIES} ${yaml-cpp_LIBRARIES} ${openssl_LIBRARIES}) +target_link_libraries(lingo_ap_tracker PRIVATE OpenSSL::SSL OpenSSL::Crypto wx::core wx::base yaml-cpp) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..69774f3 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,34 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 1, + "patch": 0 + }, + "configurePresets": [ + { + "name": "lingo-ap-tracker-preset", + "displayName": "Lingo AP Tracker preset", + "description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations", + "binaryDir": "${sourceDir}/builds/${presetName}", + "generator": "Ninja Multi-Config", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } + }, + "environment": { + "VCPKG_ROOT": "./vendor/vcpkg" + } + } + ], + "buildPresets": [ + { + "name": "lingo-ap-tracker-preset", + "configurePreset": "lingo-ap-tracker-preset", + "displayName": "Build lingo-ap-tracker-preset", + "description": "Build" + } + ] +} -- cgit 1.4.1