|
| 1 | +name: CMake on Linux, macOS, and Windows |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + c_compiler: gcc |
| 17 | + cpp_compiler: g++ |
| 18 | + build_type: Release |
| 19 | + - os: macos-latest |
| 20 | + c_compiler: clang |
| 21 | + cpp_compiler: clang++ |
| 22 | + build_type: Release |
| 23 | + - os: windows-latest |
| 24 | + c_compiler: cl |
| 25 | + cpp_compiler: cl |
| 26 | + build_type: Release |
| 27 | + |
| 28 | + runs-on: ${{ matrix.os }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - name: Install OpenSSL |
| 33 | + run: | |
| 34 | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then |
| 35 | + sudo apt update |
| 36 | + sudo apt install -y libssl-dev |
| 37 | + echo "CMAKE_PREFIX_PATH=/usr" >> $GITHUB_ENV |
| 38 | + elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then |
| 39 | + brew update |
| 40 | + brew install openssl |
| 41 | + OPENSSL_DIR=$(brew --prefix openssl) |
| 42 | + echo "CMAKE_PREFIX_PATH=${OPENSSL_DIR}" >> $GITHUB_ENV |
| 43 | + elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then |
| 44 | + choco install openssl.light -y |
| 45 | + echo "CMAKE_PREFIX_PATH=C:/Program Files/OpenSSL-Win64" >> $GITHUB_ENV |
| 46 | + fi |
| 47 | + shell: bash |
| 48 | + |
| 49 | + - name: Set reusable strings |
| 50 | + id: strings |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
| 54 | +
|
| 55 | + - name: Configure CMake |
| 56 | + run: > |
| 57 | + cmake -B ${{ steps.strings.outputs.build-output-dir }} |
| 58 | + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| 59 | + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
| 60 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 61 | + -DCMAKE_PREFIX_PATH=${{ env.CMAKE_PREFIX_PATH }} |
| 62 | + -S ${{ github.workspace }} |
| 63 | +
|
| 64 | + - name: Build |
| 65 | + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} |
| 66 | + |
| 67 | + - name: Test |
| 68 | + working-directory: ${{ steps.strings.outputs.build-output-dir }} |
| 69 | + run: ctest --build-config ${{ matrix.build_type }} |
0 commit comments