cmake.yml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. name: CMake
  2. on:
  3. push:
  4. paths:
  5. - '.github/workflows/cmake.yml'
  6. - 'src/**'
  7. - 'CMakeModules/**'
  8. - CMakeLists.txt
  9. - 'protocols/**'
  10. branches: [ main ]
  11. pull_request:
  12. paths:
  13. - '.github/workflows/cmake.yml'
  14. - 'src/**'
  15. - 'CMakeModules/**'
  16. - CMakeLists.txt
  17. - 'protocols/**'
  18. branches: [ main ]
  19. workflow_dispatch:
  20. jobs:
  21. # formatting:
  22. # name: Formatting check
  23. # runs-on: ubuntu-latest
  24. # steps:
  25. # - uses: actions/checkout@v4
  26. # - name: Run clang-format style check for C/C++ programs.
  27. # uses: jidicula/clang-format-action@v4.16.0
  28. # with:
  29. # check-path: "src"
  30. # exclude-regex: "(src/External)"
  31. # - run: echo "Formatted with clang-format version ${{ steps.clang-format.outputs.clang-format-version }}"
  32. tests:
  33. #needs: formatting
  34. env:
  35. BUILD_TYPE: Release
  36. strategy:
  37. matrix:
  38. os: [ubuntu-24.04]
  39. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  40. # You can convert this to a matrix build if you need cross-platform coverage.
  41. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  42. runs-on: ${{ matrix.os }}
  43. steps:
  44. - uses: actions/checkout@v3
  45. with:
  46. submodules: true
  47. # cache some build information
  48. - name: ccache
  49. uses: hendrikmuhs/ccache-action@v1.2
  50. with:
  51. key: ${{ github.job }}-${{ matrix.os }} # Eg. "some_build-ubuntu-latest"
  52. - name: Install dependencies
  53. if: matrix.os == 'ubuntu-24.04'
  54. run: sudo apt-get update && sudo apt-get -y install libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libfftw3-dev libfreetype-dev
  55. - name: Configure CMake
  56. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  57. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  58. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=1 -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  59. - name: Build
  60. # Build your program with the given configuration
  61. run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target tests
  62. - name: Run tests
  63. # Run the unit tests available
  64. run: ${{github.workspace}}/build/output/tests
  65. build-x11:
  66. needs: tests
  67. strategy:
  68. matrix:
  69. os: [ubuntu-22.04, ubuntu-24.04]
  70. build_type: [Release, Debug]
  71. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  72. # You can convert this to a matrix build if you need cross-platform coverage.
  73. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  74. runs-on: ${{ matrix.os }}
  75. steps:
  76. - uses: actions/checkout@v3
  77. with:
  78. submodules: true
  79. # cache some build information
  80. - name: ccache
  81. uses: hendrikmuhs/ccache-action@v1.2
  82. with:
  83. key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.build_type }} # Eg. "some_build-ubuntu-latest"
  84. - name: Install dependencies
  85. if: matrix.os == 'ubuntu-22.04'
  86. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev
  87. - name: Install dependencies
  88. if: matrix.os == 'ubuntu-24.04'
  89. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev
  90. - name: Configure CMake
  91. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  92. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  93. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  94. - name: Build
  95. # Build your program with the given configuration
  96. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
  97. build-x11-wayland:
  98. needs: tests
  99. permissions:
  100. actions: read
  101. contents: read
  102. security-events: write
  103. strategy:
  104. matrix:
  105. os: [ubuntu-22.04, ubuntu-24.04]
  106. build_type: [Release, Debug]
  107. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  108. # You can convert this to a matrix build if you need cross-platform coverage.
  109. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  110. runs-on: ${{ matrix.os }}
  111. steps:
  112. - uses: actions/checkout@v3
  113. with:
  114. submodules: true
  115. - name: ccache
  116. uses: hendrikmuhs/ccache-action@v1.2
  117. with:
  118. key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.build_type }} # Eg. "some_build-ubuntu-latest"
  119. - name: Initialize CodeQL
  120. # Initializes the CodeQL tools for scanning.
  121. uses: github/codeql-action/init@v3
  122. if: ${{ matrix.os == 'ubuntu-24.04' && matrix.build_type == 'Debug' }}
  123. with:
  124. languages: 'cpp'
  125. - name: Install dependencies
  126. if: matrix.os == 'ubuntu-22.04'
  127. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev wayland-scanner++ wayland-protocols libwayland-dev
  128. - name: Install dependencies
  129. if: matrix.os == 'ubuntu-24.04'
  130. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev wayland-scanner++ wayland-protocols libwayland-dev
  131. - name: Configure CMake
  132. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  133. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  134. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  135. - name: Build
  136. # Build your program with the given configuration
  137. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
  138. - name: Perform CodeQL Analysis
  139. if: ${{ matrix.os == 'ubuntu-24.04' && matrix.build_type == 'Debug' }}
  140. uses: github/codeql-action/analyze@v3
  141. build-wayland:
  142. needs: tests
  143. strategy:
  144. matrix:
  145. os: [ubuntu-22.04, ubuntu-24.04]
  146. build_type: [Release, Debug]
  147. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  148. # You can convert this to a matrix build if you need cross-platform coverage.
  149. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  150. runs-on: ${{ matrix.os }}
  151. steps:
  152. - uses: actions/checkout@v3
  153. with:
  154. submodules: true
  155. - name: ccache
  156. uses: hendrikmuhs/ccache-action@v1.2
  157. with:
  158. key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.build_type }} # Eg. "some_build-ubuntu-latest"
  159. - name: Install dependencies
  160. if: matrix.os == 'ubuntu-22.04'
  161. run: sudo apt-get update && sudo apt-get -y install wayland-scanner++ wayland-protocols libwayland-dev libwayland-egl-backend-dev libglfw3-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev
  162. - name: Install dependencies
  163. if: matrix.os == 'ubuntu-24.04'
  164. run: sudo apt-get update && sudo apt-get -y install wayland-scanner++ wayland-protocols libwayland-dev libwayland-egl-backend-dev libglfw3-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev
  165. - name: Configure CMake
  166. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  167. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  168. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  169. - name: Build
  170. # Build your program with the given configuration
  171. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}