| 1 | name: Build raylib CMake - Windows+Linux |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | push: |
| 6 | paths: |
| 7 | - 'src/**' |
| 8 | - 'examples/**' |
| 9 | - '.github/workflows/cmake.yml' |
| 10 | - 'CMakeList.txt' |
| 11 | - 'CMakeOptions.txt' |
| 12 | - 'cmake/**' |
| 13 | pull_request: |
| 14 | paths: |
| 15 | - 'src/**' |
| 16 | - 'examples/**' |
| 17 | - '.github/workflows/cmake.yml' |
| 18 | - 'CMakeList.txt' |
| 19 | - 'CMakeOptions.txt' |
| 20 | - 'cmake/**' |
| 21 | |
| 22 | env: |
| 23 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 24 | BUILD_TYPE: Release |
| 25 | |
| 26 | permissions: |
| 27 | contents: read |
| 28 | |
| 29 | jobs: |
| 30 | build_windows: |
| 31 | name: Windows Build |
| 32 | # The CMake configure and build commands are platform agnostic and should work equally |
| 33 | # well on Windows or Mac. You can convert this to a matrix build if you need |
| 34 | # cross-platform coverage. |
| 35 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 36 | runs-on: windows-latest |
| 37 | |
| 38 | steps: |
| 39 | - uses: actions/checkout@v4 |
| 40 | |
| 41 | - name: Create Build Environment |
| 42 | # Some projects don't allow in-source building, so create a separate build directory |
| 43 | # We'll use this as our working directory for all subsequent commands |
| 44 | run: cmake -E make_directory ${{github.workspace}}/build |
| 45 | |
| 46 | - name: Configure CMake |
| 47 | # Use a bash shell so we can use the same syntax for environment variable |
| 48 | # access regardless of the host operating system |
| 49 | shell: powershell |
| 50 | working-directory: ${{github.workspace}}/build |
| 51 | # Note the current convention is to use the -S and -B options here to specify source |
| 52 | # and build directories, but this is only available with CMake 3.13 and higher. |
| 53 | # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 54 | run: cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DPLATFORM=Desktop |
| 55 | |
| 56 | - name: Build |
| 57 | working-directory: ${{github.workspace}}/build |
| 58 | shell: powershell |
| 59 | # Execute the build. You can specify a specific target with "--target <NAME>" |
| 60 | run: cmake --build . --config $env:BUILD_TYPE |
| 61 | |
| 62 | - name: Test |
| 63 | working-directory: ${{github.workspace}}/build |
| 64 | shell: powershell |
| 65 | # Execute tests defined by the CMake configuration. |
| 66 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 67 | run: ctest -C $env:BUILD_TYPE |
| 68 | |
| 69 | build_linux: |
| 70 | name: Linux Build |
| 71 | # The CMake configure and build commands are platform agnostic and should work equally |
| 72 | # well on Windows or Mac. You can convert this to a matrix build if you need |
| 73 | # cross-platform coverage. |
| 74 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 75 | runs-on: ubuntu-latest |
| 76 | |
| 77 | steps: |
| 78 | - uses: actions/checkout@v4 |
| 79 | |
| 80 | - name: Create Build Environment |
| 81 | # Some projects don't allow in-source building, so create a separate build directory |
| 82 | # We'll use this as our working directory for all subsequent commands |
| 83 | run: cmake -E make_directory ${{github.workspace}}/build |
| 84 | |
| 85 | - name: Setup Environment |
| 86 | run: | |
| 87 | sudo apt-get update -qq |
| 88 | sudo apt-get install gcc-multilib |
| 89 | sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libwayland-bin libxkbcommon-dev |
| 90 | - name: Configure CMake |
| 91 | # Use a bash shell so we can use the same syntax for environment variable |
| 92 | # access regardless of the host operating system |
| 93 | shell: bash |
| 94 | working-directory: ${{github.workspace}}/build |
| 95 | # Note the current convention is to use the -S and -B options here to specify source |
| 96 | # and build directories, but this is only available with CMake 3.13 and higher. |
| 97 | # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 98 | run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=Desktop |
| 99 | |
| 100 | - name: Build |
| 101 | working-directory: ${{github.workspace}}/build |
| 102 | shell: bash |
| 103 | # Execute the build. You can specify a specific target with "--target <NAME>" |
| 104 | run: cmake --build . --config $BUILD_TYPE |
| 105 | |
| 106 | - name: Test |
| 107 | working-directory: ${{github.workspace}}/build |
| 108 | shell: bash |
| 109 | # Execute tests defined by the CMake configuration. |
| 110 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 111 | run: ctest -C $BUILD_TYPE |