Skip to content

Commit 09196af

Browse files
committed
🔨 Another CMake github actions attempt
1 parent 2e4dbd9 commit 09196af

File tree

1 file changed

+51
-13
lines changed

1 file changed

+51
-13
lines changed

.github/workflows/cmake-multi-platform.yml

+51-13
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ jobs:
1616
include:
1717
- os: windows-latest
1818
cpp_compiler: cl
19+
separator: '\\'
1920
- os: ubuntu-latest
2021
cpp_compiler: g++
22+
separator: "/"
2123

2224
steps:
2325
- uses: actions/checkout@v4
@@ -56,34 +58,70 @@ jobs:
5658
shell: bash
5759
run: |
5860
conan profile detect --force
61+
echo "[conf]" >> ~/.conan2/profiles/default
62+
echo "tools.system.package_manager:mode=install" >> ~/.conan2/profiles/default
63+
echo "tools.system.package_manager:sudo=True" >> ~/.conan2/profiles/default
5964
60-
- name: Install Conan Dependencies
65+
- name: Cache Conan packages
66+
uses: actions/cache@v3
67+
with:
68+
path: ~/.conan2
69+
key: ${{ runner.os }}-conan-${{ hashFiles('**/conanfile.txt') }}
70+
restore-keys: |
71+
${{ runner.os }}-conan-
72+
73+
- name: Install Conan Dependencies (Linux)
74+
if: runner.os == 'Linux'
6175
run: |
6276
conan install . --build=missing -s build_type=${{ matrix.build_type }}
6377
64-
- name: Configure CMake
78+
- name: Install Conan Dependencies (Windows)
79+
if: runner.os == 'Windows'
80+
shell: pwsh
6581
run: |
66-
cmake --preset conan-${{ matrix.build_type }}
67-
68-
- name: Build
69-
run: cmake --build --preset conan-${{ matrix.build_type }}
82+
conan install . --build=missing -s build_type=${{ matrix.build_type }} -c tools.cmake.cmake_layout:build_folder_vars=['generators'] -c tools.cmake.cmaketoolchain:generator=Ninja
7083
71-
- name: Test
72-
run: ctest --preset conan-${{ matrix.build_type }}
84+
- name: Set Build Directory
85+
id: strings
86+
shell: bash
87+
run: |
88+
if [ "${{ runner.os }}" == "Windows" ]; then
89+
echo "build-output-dir=${{ github.workspace }}\\build\\${{ matrix.build_type }}" >> "$GITHUB_OUTPUT"
90+
echo "game-path=src\\game\\stabby.exe" >> "$GITHUB_OUTPUT"
91+
echo "preset=conan-default" >> "$GITHUB_OUTPUT"
92+
else
93+
echo "build-output-dir=${{ github.workspace }}/build/${{ matrix.build_type }}" >> "$GITHUB_OUTPUT"
94+
echo "game-path=src/game/stabby" >> "$GITHUB_OUTPUT"
95+
echo "preset=conan-release" >> "$GITHUB_OUTPUT"
96+
fi
7397
74-
- name: Set Artifact Path
75-
id: artifact
98+
- name: Configure CMake
7699
shell: bash
77100
run: |
78101
if [ "${{ runner.os }}" == "Windows" ]; then
79-
echo "game-path=build/${{ matrix.build_type }}/src/game/stabby.exe" >> "$GITHUB_OUTPUT"
102+
build_dir="${{ github.workspace }}\\build\\${{ matrix.build_type }}"
103+
toolchain_path="${{ github.workspace }}\\build\\${{ matrix.build_type }}\\generators\\conan_toolchain.cmake"
80104
else
81-
echo "game-path=build/${{ matrix.build_type }}/src/game/stabby" >> "$GITHUB_OUTPUT"
105+
build_dir="${{ github.workspace }}/build/${{ matrix.build_type }}"
106+
toolchain_path="${{ github.workspace }}/build/${{ matrix.build_type }}/generators/conan_toolchain.cmake"
82107
fi
83108
109+
cmake -S . \
110+
-B "$build_dir" \
111+
-G Ninja \
112+
-DCMAKE_TOOLCHAIN_FILE="$toolchain_path" \
113+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
114+
115+
- name: Build
116+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }}
117+
118+
- name: Test
119+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
120+
run: ctest --build-config ${{ matrix.build_type }}
121+
84122
- name: Upload Build Artifacts
85123
uses: actions/upload-artifact@v3
86124
with:
87125
name: ${{ runner.os }}-${{ matrix.build_type }}-build
88-
path: ${{ steps.artifact.outputs.game-path }}
126+
path: ${{ steps.strings.outputs.build-output-dir }}/${{ steps.strings.outputs.game-path }}
89127
if-no-files-found: ignore

0 commit comments

Comments
 (0)