CMake: build examples next to the shared library #63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: C/C++ CI | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: "Windows MSVC17 shared library using LibreSSL" | |
| os: windows-2022 | |
| generator: -G "Visual Studio 17 2022" -A x64 | |
| shared: ON | |
| libressl: -DOPENSSL_ROOT_DIR:PATH=build/external/libressl/install | |
| # don't use Debug to work around issue of FindOpenSSL.cmake which leaves us with | |
| # -- Found OpenSSL: optimized;D:/a/sockpuppet/sockpuppet/build/external/libressl/install/lib/crypto.lib;debug;C:/Program Files/OpenSSL/lib/VC/libcrypto64MDd.lib (found version "2.0.0") | |
| # which fails at link time | |
| type: Release | |
| - name: "Windows MSVC17 shared library using OpenSSL" | |
| os: windows-2022 | |
| generator: -G "Visual Studio 17 2022" -A x64 | |
| shared: ON | |
| # uses pre-installed OpenSSL 1.1.1w | |
| type: Debug | |
| - name: "Unix GCC shared library using LibreSSL" | |
| os: ubuntu-latest | |
| generator: -G "Unix Makefiles" | |
| shared: ON | |
| libressl: -DOPENSSL_ROOT_DIR:PATH=build/external/libressl/install | |
| type: Debug | |
| - name: "Unix GCC static library using OpenSSL" | |
| os: ubuntu-latest | |
| generator: -G "Unix Makefiles" | |
| shared: OFF | |
| # uses pre-installed OpenSSL 3.0.13 | |
| type: Debug | |
| - name: "OSX clang shared library using LibreSSL" | |
| os: macos-latest | |
| generator: -G "Unix Makefiles" | |
| shared: ON | |
| libressl: -DOPENSSL_ROOT_DIR:PATH=build/external/libressl/install | |
| # don't mix LibreSSL with a static build because on demo's OpenSSL find, it will find the pre-installed one with | |
| # -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.13") | |
| # which fails at link time | |
| type: Debug | |
| - name: "OSX clang static library using OpenSSL" | |
| os: macos-latest | |
| generator: -G "Unix Makefiles" | |
| shared: OFF | |
| # uses pre-installed OpenSSL 3.5.2 | |
| type: Debug | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: cache externals restore | |
| id: cache-externals-restore | |
| if: matrix.libressl | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: build/external/libressl/install | |
| key: ${{ matrix.os }}-externals-${{ hashFiles('external/CMakeLists.txt') }} | |
| - name: configure externals | |
| if: matrix.libressl && (steps.cache-externals-restore.outputs.cache-hit != 'true') | |
| run: > | |
| cmake | |
| -B build/external | |
| -S external | |
| ${{ matrix.generator }} | |
| -DCMAKE_BUILD_TYPE:STRING=${{ matrix.type }} | |
| - name: build externals | |
| if: matrix.libressl && (steps.cache-externals-restore.outputs.cache-hit != 'true') | |
| run: cmake --build build/external --config ${{ matrix.type }} | |
| - name: cache externals save | |
| if: matrix.libressl && (steps.cache-externals-restore.outputs.cache-hit != 'true') | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: build/external/libressl/install | |
| key: ${{ steps.cache-externals-restore.outputs.cache-primary-key }} | |
| - name: configure library | |
| run: > | |
| cmake | |
| -B build | |
| -S . | |
| ${{ matrix.generator }} | |
| -DSOCKPUPPET_BUILD_SHARED_LIBS:BOOL=${{ matrix.shared }} | |
| -DSOCKPUPPET_WITH_TLS:BOOL=ON | |
| ${{ matrix.libressl }} | |
| -DCMAKE_BUILD_TYPE:STRING=${{ matrix.type }} | |
| - name: build library | |
| run: cmake --build build --config ${{ matrix.type }} | |
| - name: build & run tests | |
| env: | |
| CTEST_OUTPUT_ON_FAILURE: 1 | |
| run: cmake --build build --target run_tests --config ${{ matrix.type }} | |
| - name: install library and demo | |
| run: cmake --build build --config ${{ matrix.type }} --target install | |
| - name: configure demo | |
| run: > | |
| cmake | |
| -B build/install/demo/build | |
| -S build/install/demo | |
| ${{ matrix.libressl }} | |
| -DCMAKE_BUILD_TYPE:STRING=${{ matrix.type }} | |
| - name: build demo | |
| run: cmake --build build/install/demo/build --config ${{ matrix.type }} |