Skip to content

Commit

Permalink
refactor: simplify build configuration
Browse files Browse the repository at this point in the history
- Simplify CMakePresets.json by removing unused presets
- Standardize build preset names across platforms
- Remove test presets as they are not used
- Clean up workflow file and use consistent preset names
  • Loading branch information
xujiajiadexiaokeai committed Feb 7, 2025
1 parent e640382 commit 3328786
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 119 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
with:
submodules: true

# - name: Install MSVC problem matcher
# uses: ammaraskar/msvc-problem-matcher@master

# Install latest CMake
- uses: lukka/get-cmake@latest

Expand All @@ -65,7 +68,7 @@ jobs:
uses: lukka/run-cmake@v10
with:
configurePreset: 'windows-msvc-vs17'
buildPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'windows-msvc-vs17-release' || 'windows-msvc-vs17-debug' }}
buildPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'windows-msvc-vs17-release' || 'windows-msvc-vs17' }}

- name: "Check file existence"
uses: andstor/file-existence-action@v3
Expand Down Expand Up @@ -143,8 +146,6 @@ jobs:
sudo apt-get install -y build-essential
sudo apt-get install -y gcc g++
# - uses: lukka/get-cmake@latest

- name: Restore artifacts, or setup vcpkg
uses: lukka/run-vcpkg@v10
with:
Expand All @@ -168,16 +169,15 @@ jobs:
uses: lukka/run-cmake@v10
if: startsWith(github.ref, 'refs/tags/') != true
with:
configurePreset: 'ninja-vcpkg-coverage-no-test'
buildPreset: 'ninja-vcpkg-coverage-no-test'
configurePreset: 'ninja-vcpkg-coverage'
buildPreset: 'ninja-vcpkg-coverage'

- name: 'Run CMake without coverage'
if: startsWith(github.ref, 'refs/tags/')
uses: lukka/run-cmake@v10
with:
configurePreset: 'ninja-vcpkg-release'
buildPreset: 'ninja-vcpkg-release-minimal'
testPreset: 'test-release'
buildPreset: 'ninja-vcpkg-release'

- name: 'Run CTest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
Expand Down Expand Up @@ -278,9 +278,6 @@ jobs:
- name: Install Ninja
run: brew install ninja

# Install latest CMake
# - uses: lukka/get-cmake@latest

# Restore from cache the previously built ports
- name: Restore artifacts, or setup vcpkg
uses: lukka/run-vcpkg@v10
Expand All @@ -297,8 +294,7 @@ jobs:
uses: lukka/run-cmake@v10
with:
configurePreset: 'macos-ninja'
buildPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'macos-ninja-release' || 'macos-ninja-debug' }}
testPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'test-macos-release' || 'test-macos-debug' }}
buildPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'macos-ninja-release' || 'macos-ninja' }}

- name: 'Run CTest'
run: ctest -C ${{ env.BUILD_TYPE }}
Expand Down
124 changes: 17 additions & 107 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@
{
"name": "ninja-vcpkg-coverage",
"inherits": "ninja-vcpkg",
"displayName": "Ninja with Coverage",
"displayName": "Ninja Coverage",
"description": "Configure with code coverage enabled",
"cacheVariables": {
"CODE_COVERAGE": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "ninja-vcpkg-coverage-no-test",
"inherits": "ninja-vcpkg-coverage",
"displayName": "Ninja with Coverage (No Tests)",
"description": "Configure with code coverage enabled but without tests",
"cacheVariables": {
},
"BUILD_TESTING": {
"type": "BOOL",
"value": "OFF"
Expand Down Expand Up @@ -99,81 +91,40 @@
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "windows-msvc-vcpkg",
"displayName": "Windows MSVC",
"description": "Configure with MSVC and vcpkg toolchain",
"generator": "Visual Studio 17 2022",
"architecture": {
"value": "x64",
"strategy": "external"
},
"binaryDir": "${sourceDir}/../../_temp/windows",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}
],
"buildPresets": [
{
"name": "ninja-vcpkg-coverage",
"configurePreset": "ninja-vcpkg-coverage",
"displayName": "Build with Coverage",
"description": "Build with code coverage enabled"
},
{
"name": "ninja-vcpkg-coverage-no-test",
"configurePreset": "ninja-vcpkg-coverage-no-test",
"displayName": "Build with Coverage (No Tests)",
"description": "Build with code coverage enabled but without tests"
},
{
"name": "ninja-vcpkg-release",
"configurePreset": "ninja-vcpkg-release",
"configurePreset": "ninja-vcpkg",
"displayName": "Build Release",
"description": "Build release version without tests"
"description": "Build release version",
"configuration": "Release"
},
{
"name": "macos-ninja-debug",
"name": "ninja-vcpkg-coverage",
"configurePreset": "ninja-vcpkg-coverage",
"displayName": "Build Coverage",
"description": "Build with coverage enabled"
},
{
"name": "macos-ninja",
"configurePreset": "macos-ninja",
"displayName": "Build macOS (Debug)",
"displayName": "Build macOS",
"description": "Build for macOS"
},
{
"name": "macos-ninja-release",
"configurePreset": "macos-ninja",
"displayName": "Build macOS (Release)",
"description": "Build for macOS"
},
{
"name": "windows-msvc-debug",
"configurePreset": "windows-msvc-vcpkg",
"displayName": "Build Windows (Debug)",
"description": "Build with MSVC (Debug)",
"configuration": "Debug"
},
{
"name": "windows-msvc-release",
"configurePreset": "windows-msvc-vcpkg",
"displayName": "Build Windows (Release)",
"description": "Build with MSVC (Release)",
"description": "Build for macOS (Release)",
"configuration": "Release"
},
{
"name": "windows-msvc-vs17-debug",
"name": "windows-msvc-vs17",
"configurePreset": "windows-msvc-vs17",
"displayName": "Build Windows VS17 (Debug)",
"description": "Build with VS17 (Debug)",
"configuration": "Debug"
"displayName": "Build Windows VS17",
"description": "Build with VS17"
},
{
"name": "windows-msvc-vs17-release",
Expand All @@ -182,46 +133,5 @@
"description": "Build with VS17 (Release)",
"configuration": "Release"
}
],
"testPresets": [
{
"name": "test-base",
"hidden": true,
"output": {
"outputOnFailure": true,
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
},
{
"name": "test-debug",
"inherits": "test-base",
"configurePreset": "ninja-vcpkg-coverage"
},
{
"name": "test-windows-vs17-debug",
"inherits": "test-base",
"configurePreset": "windows-msvc-vs17",
"configuration": "Debug"
},
{
"name": "test-windows-vs17-release",
"inherits": "test-base",
"configurePreset": "windows-msvc-vs17",
"configuration": "Release"
},
{
"name": "test-macos-debug",
"inherits": "test-base",
"configurePreset": "macos-ninja"
},
{
"name": "test-macos-release",
"inherits": "test-base",
"configurePreset": "macos-ninja"
}
]
}

0 comments on commit 3328786

Please sign in to comment.