Skip to content

Commit

Permalink
Simplify workflow using CMake preset. Use git pulled vcpkg.
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe2933 committed Aug 1, 2024
1 parent b89dd45 commit 4ee2f00
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": 6,
"configurePresets": [
{
"name": "clang",
"displayName": "Clang",
"inherits": "vcpkg",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++ -lc++abi",
"VCPKG_OVERLAY_TRIPLETS": ".github/workflows/triplets",
"VCPKG_TARGET_TRIPLET": "x64-linux-clang"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "msvc",
"displayName": "MSVC",
"inherits": "vcpkg",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}
]
}
17 changes: 8 additions & 9 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
run: |
sudo apt-get install ninja-build xorg-dev libc++-dev libc++abi-dev
- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && ./bootstrap-vcpkg.sh
echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
Expand All @@ -39,15 +45,8 @@ jobs:
- name: Configure
run: |
cmake --preset=vcpkg \
-DCMAKE_C_COMPILER="/usr/bin/clang-18" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++-18" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_OVERLAY_TRIPLETS=".github/workflows/triplets" \
-DVCPKG_TARGET_TRIPLET="x64-linux-clang" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi"
mv .github/workflows/CMakeUserPresets.json .
cmake --preset=clang
- name: Build
run: cmake --build build --config release
11 changes: 8 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && .\bootstrap-vcpkg.bat
echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
Expand All @@ -40,9 +46,8 @@ jobs:
- name: Configure
run: |
cmake --preset=vcpkg `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
mv .github\workflows\CMakeUserPresets.json .\
cmake --preset=msvc
- name: Build
run: cmake --build build --config release
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"name": "vcpkg",
"displayName": "vcpkg-based dependency management",
"inherits": "default",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_PORTS": "${sourceDir}/overlays"
}
}
Expand Down

0 comments on commit 4ee2f00

Please sign in to comment.