Skip to content

Commit

Permalink
feat(single build system): Add CMake to allow switching to cmake + vc…
Browse files Browse the repository at this point in the history
…pkg instead of scons and other build systems (endless-sky#7020)

* Adds a new CMake build system.
* Use EGL's offscreen buffer for the integration tests.
* Use a space for the game executable on Apple and Windows platforms.
  • Loading branch information
quyykk authored Dec 7, 2022
1 parent c2886de commit 9c286b6
Show file tree
Hide file tree
Showing 26 changed files with 1,848 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Don't export certain files via `git archive` (e.g. via "Download ZIP")
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
9 changes: 9 additions & 0 deletions .github/path-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,14 @@ codeblocks_files:
- '*.cbp'
- 'utils/check_codeblocks.sh'

cmake_files:
- CMakeLists.txt
- source/CMakeLists.txt
- tests/unit/CMakeLists.txt
- tests/integration/IntegrationTests.cmake
- CMakePresets.json
- 'vcpkg/**'
- vcpkg.json

copyright:
- 'copyright'
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,107 @@ jobs:
- name: Execute style checker
run: python ./utils/check_code_style.py


# CI runs to test the CMake build system.

build_ubuntu_cmake:
needs: changed
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.integration_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install development dependencies
run: |
sudo rm /etc/apt/sources.list.d/* && sudo dpkg --clear-avail # Speed up installation and get rid of unwanted lists
sudo apt update
sudo apt install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libosmesa6 mesa-utils libglvnd-dev
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
- uses: lukka/run-cmake@v10
with:
configurePreset: 'linux-ci'
buildPreset: 'linux-ci'
testPreset: 'linux-ci'
- name: Run Benchmarks
run: ctest --preset linux-ci-benchmark
- name: Prevent saving cache on failure
run: |
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
if: ${{ failure() || cancelled() }}
shell: bash


build_windows_cmake:
needs: changed
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
with:
prependedCacheKey: mingw-x64
- uses: lukka/run-cmake@v10
with:
configurePreset: 'mingw-ci'
buildPreset: 'mingw-ci'
testPreset: 'mingw-ci'
- name: Run Benchmarks
run: ctest --preset mingw-ci-benchmark
- name: Prevent saving cache on failure
run: |
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
if: ${{ failure() || cancelled() }}
shell: bash

build_macos_cmake:
needs: changed
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
- uses: lukka/run-cmake@v10
with:
configurePreset: 'macos-ci'
buildPreset: 'macos-ci'
testPreset: 'macos-ci'
- name: Run Benchmarks
run: ctest --preset macos-ci-benchmark
- name: Prevent saving cache on failure
run: |
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
if: ${{ failure() || cancelled() }}
shell: bash

build_windows_clang_cmake:
needs: changed
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
with:
prependedCacheKey: vs-x64
- uses: lukka/run-cmake@v10
with:
configurePreset: 'clang-cl-ci'
buildPreset: 'clang-cl-ci'
testPreset: 'clang-cl-ci'
- name: Run Benchmarks
run: ctest --preset clang-cl-ci-benchmark
- name: Prevent saving cache on failure
run: |
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
if: ${{ failure() || cancelled() }}
shell: bash
3 changes: 3 additions & 0 deletions .github/workflows/compute-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ on:
value: ${{ jobs.changed.outputs.xcode_files }}
codeblocks_files:
value: ${{ jobs.changed.outputs.codeblocks_files }}
cmake_files:
value: ${{ jobs.changed.outputs.cmake }}
copyright:
value: ${{ jobs.changed.outputs.copyright }}

Expand All @@ -38,6 +40,7 @@ jobs:
codespell: ${{ steps.filter.outputs.codespell }}
xcode_files: ${{ steps.filter.outputs.xcode_files }}
codeblocks_files: ${{ steps.filter.outputs.codeblocks_files }}
cmake_files: ${{ steps.filter.outputs.cmake_files }}
copyright: ${{ steps.filter.outputs.copyright }}
steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/projects_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ jobs:
run: ./utils/check_codeblocks.sh


check-cmake:
needs: changed
if: ${{ needs.changed.outputs.cmake || needs.changed.outputs.game_code || needs.changed.outputs.unit_tests }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate CMake project files
run: ./utils/check_cmake.sh



validate-copyright:
needs: changed
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ libendless-sky.a
*.lnk
*.AppImage

# Autogenerated files
icons/endless-sky.icns

# dlls needed to run the binary
*.dll

Expand Down Expand Up @@ -60,9 +63,8 @@ ipch/
*.xcodeproj/**
.idea/
.idea_modules/
CMakeLists.txt
compile_commands.json
/.gitmodules
CMakeUserPresets.json

# static code analysis
/.scannerwork
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg
Loading

0 comments on commit 9c286b6

Please sign in to comment.