Skip to content

Commit 9c286b6

Browse files
authored
feat(single build system): Add CMake to allow switching to cmake + vcpkg 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.
1 parent c2886de commit 9c286b6

26 files changed

+1848
-6
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Don't export certain files via `git archive` (e.g. via "Download ZIP")
22
.gitattributes export-ignore
33
.gitignore export-ignore
4+
.gitmodules export-ignore
45
.github export-ignore

.github/path-filters.yml

+9
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,14 @@ codeblocks_files:
5353
- '*.cbp'
5454
- 'utils/check_codeblocks.sh'
5555

56+
cmake_files:
57+
- CMakeLists.txt
58+
- source/CMakeLists.txt
59+
- tests/unit/CMakeLists.txt
60+
- tests/integration/IntegrationTests.cmake
61+
- CMakePresets.json
62+
- 'vcpkg/**'
63+
- vcpkg.json
64+
5665
copyright:
5766
- 'copyright'

.github/workflows/ci.yml

+104
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,107 @@ jobs:
537537
- name: Execute style checker
538538
run: python ./utils/check_code_style.py
539539

540+
541+
# CI runs to test the CMake build system.
542+
543+
build_ubuntu_cmake:
544+
needs: changed
545+
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' }}
546+
runs-on: ubuntu-latest
547+
steps:
548+
- uses: actions/checkout@v3
549+
with:
550+
submodules: true
551+
- name: Install development dependencies
552+
run: |
553+
sudo rm /etc/apt/sources.list.d/* && sudo dpkg --clear-avail # Speed up installation and get rid of unwanted lists
554+
sudo apt update
555+
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
556+
- uses: lukka/get-cmake@latest
557+
- uses: lukka/run-vcpkg@v10
558+
- uses: lukka/run-cmake@v10
559+
with:
560+
configurePreset: 'linux-ci'
561+
buildPreset: 'linux-ci'
562+
testPreset: 'linux-ci'
563+
- name: Run Benchmarks
564+
run: ctest --preset linux-ci-benchmark
565+
- name: Prevent saving cache on failure
566+
run: |
567+
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
568+
if: ${{ failure() || cancelled() }}
569+
shell: bash
570+
571+
572+
build_windows_cmake:
573+
needs: changed
574+
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
575+
runs-on: windows-latest
576+
steps:
577+
- uses: actions/checkout@v3
578+
with:
579+
submodules: true
580+
- uses: lukka/get-cmake@latest
581+
- uses: lukka/run-vcpkg@v10
582+
with:
583+
prependedCacheKey: mingw-x64
584+
- uses: lukka/run-cmake@v10
585+
with:
586+
configurePreset: 'mingw-ci'
587+
buildPreset: 'mingw-ci'
588+
testPreset: 'mingw-ci'
589+
- name: Run Benchmarks
590+
run: ctest --preset mingw-ci-benchmark
591+
- name: Prevent saving cache on failure
592+
run: |
593+
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
594+
if: ${{ failure() || cancelled() }}
595+
shell: bash
596+
597+
build_macos_cmake:
598+
needs: changed
599+
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
600+
runs-on: macos-latest
601+
steps:
602+
- uses: actions/checkout@v3
603+
with:
604+
submodules: true
605+
- uses: lukka/get-cmake@latest
606+
- uses: lukka/run-vcpkg@v10
607+
- uses: lukka/run-cmake@v10
608+
with:
609+
configurePreset: 'macos-ci'
610+
buildPreset: 'macos-ci'
611+
testPreset: 'macos-ci'
612+
- name: Run Benchmarks
613+
run: ctest --preset macos-ci-benchmark
614+
- name: Prevent saving cache on failure
615+
run: |
616+
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
617+
if: ${{ failure() || cancelled() }}
618+
shell: bash
619+
620+
build_windows_clang_cmake:
621+
needs: changed
622+
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
623+
runs-on: windows-latest
624+
steps:
625+
- uses: actions/checkout@v3
626+
with:
627+
submodules: true
628+
- uses: lukka/get-cmake@latest
629+
- uses: lukka/run-vcpkg@v10
630+
with:
631+
prependedCacheKey: vs-x64
632+
- uses: lukka/run-cmake@v10
633+
with:
634+
configurePreset: 'clang-cl-ci'
635+
buildPreset: 'clang-cl-ci'
636+
testPreset: 'clang-cl-ci'
637+
- name: Run Benchmarks
638+
run: ctest --preset clang-cl-ci-benchmark
639+
- name: Prevent saving cache on failure
640+
run: |
641+
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
642+
if: ${{ failure() || cancelled() }}
643+
shell: bash

.github/workflows/compute-changes.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121
value: ${{ jobs.changed.outputs.xcode_files }}
2222
codeblocks_files:
2323
value: ${{ jobs.changed.outputs.codeblocks_files }}
24+
cmake_files:
25+
value: ${{ jobs.changed.outputs.cmake }}
2426
copyright:
2527
value: ${{ jobs.changed.outputs.copyright }}
2628

@@ -38,6 +40,7 @@ jobs:
3840
codespell: ${{ steps.filter.outputs.codespell }}
3941
xcode_files: ${{ steps.filter.outputs.xcode_files }}
4042
codeblocks_files: ${{ steps.filter.outputs.codeblocks_files }}
43+
cmake_files: ${{ steps.filter.outputs.cmake_files }}
4144
copyright: ${{ steps.filter.outputs.copyright }}
4245
steps:
4346
- uses: actions/checkout@v2

.github/workflows/projects_check.yml

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ jobs:
6363
run: ./utils/check_codeblocks.sh
6464

6565

66+
check-cmake:
67+
needs: changed
68+
if: ${{ needs.changed.outputs.cmake || needs.changed.outputs.game_code || needs.changed.outputs.unit_tests }}
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v3
72+
- name: Validate CMake project files
73+
run: ./utils/check_cmake.sh
74+
75+
6676

6777
validate-copyright:
6878
needs: changed

.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ libendless-sky.a
66
*.lnk
77
*.AppImage
88

9+
# Autogenerated files
10+
icons/endless-sky.icns
11+
912
# dlls needed to run the binary
1013
*.dll
1114

@@ -60,9 +63,8 @@ ipch/
6063
*.xcodeproj/**
6164
.idea/
6265
.idea_modules/
63-
CMakeLists.txt
6466
compile_commands.json
65-
/.gitmodules
67+
CMakeUserPresets.json
6668

6769
# static code analysis
6870
/.scannerwork

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "vcpkg"]
2+
path = vcpkg
3+
url = https://github.com/microsoft/vcpkg

0 commit comments

Comments
 (0)