cmake.yml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. tags: [ 'v*' ]
  12. pull_request:
  13. paths:
  14. - '.github/workflows/cmake.yml'
  15. - 'src/**'
  16. - 'CMakeModules/**'
  17. - CMakeLists.txt
  18. - 'protocols/**'
  19. branches: [ main ]
  20. workflow_dispatch:
  21. jobs:
  22. formatting:
  23. name: Formatting check
  24. runs-on: ubuntu-latest
  25. steps:
  26. - uses: actions/checkout@v4
  27. - name: Run clang-format style check for C/C++ programs.
  28. uses: jidicula/clang-format-action@v4.18.0
  29. with:
  30. check-path: "src"
  31. exclude-regex: "(src/External)"
  32. - run: echo "Formatted with clang-format version ${{ steps.clang-format.outputs.clang-format-version }}"
  33. tests:
  34. #needs: formatting
  35. env:
  36. BUILD_TYPE: Release
  37. strategy:
  38. matrix:
  39. os: [ubuntu-24.04]
  40. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  41. # You can convert this to a matrix build if you need cross-platform coverage.
  42. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  43. runs-on: ${{ matrix.os }}
  44. steps:
  45. - uses: actions/checkout@v3
  46. with:
  47. submodules: true
  48. # cache some build information
  49. - name: ccache
  50. uses: hendrikmuhs/ccache-action@v1.2
  51. with:
  52. key: ${{ github.job }}-${{ matrix.os }}
  53. - name: Install dependencies
  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 libdbus-1-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 --verbose
  62. - name: Run tests
  63. # Run the unit tests available
  64. run: ${{github.workspace}}/build/output/tests
  65. build:
  66. needs: tests
  67. permissions:
  68. actions: read
  69. contents: read
  70. security-events: write
  71. strategy:
  72. matrix:
  73. include:
  74. - build_type: Release
  75. variant: kde
  76. disable_kde: 'OFF'
  77. - build_type: Release
  78. variant: generic
  79. disable_kde: 'ON'
  80. - build_type: Debug
  81. variant: kde
  82. disable_kde: 'OFF'
  83. runs-on: ubuntu-24.04
  84. steps:
  85. - uses: actions/checkout@v3
  86. with:
  87. submodules: true
  88. - name: ccache
  89. uses: hendrikmuhs/ccache-action@v1.2
  90. with:
  91. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}-${{ matrix.variant }}
  92. - name: Initialize CodeQL
  93. # Initializes the CodeQL tools for scanning.
  94. uses: github/codeql-action/init@v3
  95. if: ${{ matrix.build_type == 'Debug' }}
  96. with:
  97. languages: 'cpp'
  98. - name: Install dependencies
  99. 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 libdbus-1-dev wayland-scanner++ wayland-protocols libwayland-dev
  100. - name: Configure CMake
  101. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DDISABLE_KDE_FEATURES=${{matrix.disable_kde}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  102. - name: Build
  103. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --parallel --verbose
  104. - name: Perform CodeQL Analysis
  105. if: ${{ matrix.build_type == 'Debug' }}
  106. uses: github/codeql-action/analyze@v3
  107. - name: Package
  108. if: ${{ matrix.build_type == 'Release' }}
  109. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64 "$RUNNER_TEMP"
  110. - uses: actions/upload-artifact@v4
  111. if: ${{ matrix.build_type == 'Release' }}
  112. with:
  113. name: linux-wallpaperengine-${{ matrix.variant }}
  114. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64.tar.gz
  115. if-no-files-found: error
  116. distro-build:
  117. needs: tests
  118. strategy:
  119. fail-fast: false
  120. matrix:
  121. distro: [fedora-44, arch]
  122. variant: [kde, generic]
  123. include:
  124. - distro: fedora-44
  125. image: fedora:44
  126. install: >-
  127. dnf -y install git gcc gcc-c++ make cmake pkgconf-pkg-config binutils tar gzip
  128. libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel libXxf86vm-devel
  129. mesa-libGL-devel mesa-libEGL-devel glew-devel freeglut-devel sdl2-compat-devel lz4-devel
  130. zlib-ng-compat-devel ffmpeg-free-devel glm-devel glfw-devel mpv-devel pulseaudio-libs-devel
  131. freetype-devel harfbuzz-devel dbus-devel wayland-devel wayland-protocols-devel fftw-devel gmp-devel
  132. - distro: arch
  133. image: archlinux:latest
  134. install: >-
  135. pacman -Syu --noconfirm --needed git base-devel cmake glew freeglut sdl2-compat lz4 zlib
  136. ffmpeg glm glfw mpv libpulse freetype2 harfbuzz dbus wayland wayland-protocols mesa
  137. libxrandr libxinerama libxcursor libxi libxxf86vm fftw gmp
  138. runs-on: ubuntu-24.04
  139. container: ${{ matrix.image }}
  140. steps:
  141. # git has to be there before checkout, otherwise it falls back to a tarball without submodules
  142. - name: Install dependencies
  143. run: ${{ matrix.install }}
  144. - uses: actions/checkout@v4
  145. with:
  146. submodules: true
  147. - name: Configure CMake
  148. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  149. - name: Build
  150. run: cmake --build build --parallel
  151. - name: Package
  152. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64 "$RUNNER_TEMP"
  153. - uses: actions/upload-artifact@v4
  154. with:
  155. name: linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}
  156. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64.tar.gz
  157. if-no-files-found: error
  158. release:
  159. needs: [build, distro-build]
  160. if: startsWith(github.ref, 'refs/tags/v')
  161. runs-on: ubuntu-latest
  162. permissions:
  163. contents: write
  164. steps:
  165. - uses: actions/checkout@v4
  166. - uses: actions/download-artifact@v4
  167. with:
  168. path: release
  169. merge-multiple: true
  170. - name: Create release
  171. env:
  172. GH_TOKEN: ${{ github.token }}
  173. run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes release/*.tar.gz
  174. clang-build:
  175. needs: tests
  176. permissions:
  177. actions: read
  178. contents: read
  179. security-events: write
  180. strategy:
  181. matrix:
  182. build_type: [Debug, Release]
  183. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  184. # You can convert this to a matrix build if you need cross-platform coverage.
  185. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  186. runs-on: ubuntu-24.04
  187. steps:
  188. - uses: actions/checkout@v3
  189. with:
  190. submodules: true
  191. - name: ccache
  192. uses: hendrikmuhs/ccache-action@v1.2
  193. with:
  194. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  195. - name: Install dependencies
  196. 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 libdbus-1-dev wayland-scanner++ wayland-protocols libwayland-dev
  197. - name: Configure CMake
  198. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  199. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  200. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++
  201. - name: Build
  202. # Build your program with the given configuration
  203. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose