CMake presets + simple CMake Workflow

This commit is contained in:
MACHIZAUD Andréa 2022-04-02 16:48:47 +02:00
parent acb9c24b99
commit e16fd004cd
3 changed files with 140 additions and 0 deletions

41
.github/workflows/cmake.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: CMake
on: push
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macOS-latest
- ubuntu-20.04
- windows-2022
include:
- os: windows-2022
platform: windows
- os: ubuntu-20.04
platform: linux
- os: macOS-latest
platform: macos
steps:
- uses: actions/checkout@v3
- uses: lukka/get-cmake@latest
name: Get CMake
- uses: ilammy/msvc-dev-cmd@v1
name: Setup Windows dev environment
with:
arch: 'x64'
if: ${{ matrix.platform == 'windows' }}
- name: 'Configure, Build and Install'
run: |
cmake --preset=${{ matrix.platform }}-x64
cmake --build --preset build-${{ matrix.platform }}
cmake --build --preset install-${{ matrix.platform }}

2
.gitignore vendored
View File

@ -105,6 +105,8 @@ build*/
# CMake build directories
build*/
/build
/out
# Xcode
xcode/Capstone.xcodeproj/xcuserdata

97
CMakePresets.json Normal file
View File

@ -0,0 +1,97 @@
{
"version": 3,
"configurePresets": [
{
"name": "locations-base",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}"
},
{
"name": "warnings-base",
"hidden": true,
"warnings": {
"dev": true,
"deprecated": true,
"systemVars": true
},
"errors": {
"dev": true,
"deprecated": false
}
},
{
"name": "ninja",
"hidden": true,
"displayName": "Ninja",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"CMAKE_DEFAULT_BUILD_TYPE": "Debug"
}
},
{
"name": "x64",
"hidden": true,
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
"name": "linux-x64",
"inherits": [ "ninja", "x64", "locations-base", "warnings-base" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux"}
},
{
"name": "macos-x64",
"inherits": [ "ninja", "x64", "locations-base", "warnings-base" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Darwin"}
},
{
"name": "windows-x64",
"inherits": [ "ninja", "x64", "locations-base", "warnings-base" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows"}
}
],
"buildPresets": [
{
"name": "build-linux",
"configurePreset": "linux-x64",
"nativeToolOptions": [ "-v" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux"}
},
{
"name": "build-macos",
"configurePreset": "macos-x64",
"nativeToolOptions": [ "-v" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Darwin"}
},
{
"name": "build-windows",
"configurePreset": "windows-x64",
"nativeToolOptions": [ "-v" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows"}
},
{
"name": "install-linux",
"configurePreset": "linux-x64",
"inherits": "build-linux",
"targets": [ "install" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux"}
},
{
"name": "install-macos",
"configurePreset": "macos-x64",
"inherits": "build-macos",
"targets": [ "install" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Darwin"}
},
{
"name": "install-windows",
"configurePreset": "windows-x64",
"inherits": "build-windows",
"targets": [ "install" ],
"condition": {"type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows"}
}
]
}