Refactor CMakePresets and gitlab-ci

This commit is contained in:
2025-04-11 10:27:01 +02:00
parent 0dc9eeeea2
commit f3cd73d569
2 changed files with 124 additions and 99 deletions

View File

@@ -9,8 +9,8 @@ stages:
build: build:
stage: build stage: build
script: script:
- cmake --preset ci-coverage - cmake --preset coverage
- cmake --build build/coverage -j$(nproc) - cmake --build --preset build-coverage
after_script: after_script:
- find . -name "*.o" -type f -delete - find . -name "*.o" -type f -delete
- find . -name "*.a" -type f -delete - find . -name "*.a" -type f -delete
@@ -25,20 +25,20 @@ test:
needs: needs:
- build - build
script: script:
- cd build/coverage - ctest --preset test-coverage
- ctest --output-on-failure -j$(nproc)
after_script: after_script:
- find . -name "*.tdb" -type f -delete - find . -name "*.tdb" -type f -delete
artifacts: artifacts:
paths: paths:
- build/coverage - build/coverage
expire_in: 1 hour expire_in: 1 hour
coverage: coverage:
stage: coverage stage: coverage
needs: needs:
- test - test
script: script:
- cmake --build build/coverage --target coverage - cmake --build --preset build-coverage --target coverage
artifacts: artifacts:
paths: paths:
- build/coverage/coverage_html - build/coverage/coverage_html

View File

@@ -1,97 +1,122 @@
{ {
"version": 3, "version": 6,
"cmakeMinimumRequired": { "cmakeMinimumRequired": {
"major": 3, "major": 3,
"minor": 21, "minor": 25,
"patch": 0 "patch": 0
}, },
"configurePresets": [ "configurePresets": [
{
"name": "cpp-standard",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_STANDARD": "17",
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
"CMAKE_CXX_EXTENSIONS": "OFF"
}
},
{ {
"name": "vcpkg", "name": "vcpkg",
"hidden": true, "hidden": true,
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": { "cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_INSTALL_OPTIONS": "--no-print-usage" "VCPKG_INSTALL_OPTIONS": "--no-print-usage"
} }
}, },
{
"name": "cmake-pedantic",
"hidden": true,
"warnings": {
"dev": true,
"deprecated": true,
"unusedCli": true,
"systemVars": false
}
},
{
"name": "dev-mode",
"hidden": true,
"inherits": "cmake-pedantic",
"cacheVariables": {
"DRAMSYS_BUILD_TESTS": "ON",
"DRAMSYS_BUILD_BENCHMARKS": "ON",
"DRAMSYS_BUILD_TRACE_ANALYZER": "ON"
}
},
{
"name": "std",
"description": "This preset makes sure the project actually builds with at least the specified standard",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
}
},
{
"name": "ci-common",
"binaryDir": "${sourceDir}/build",
"inherits": [
"std",
"dev-mode"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "ci-coverage",
"binaryDir": "${sourceDir}/build/coverage",
"inherits": "ci-common",
"cacheVariables": {
"DRAMSYS_ENABLE_COVERAGE": "ON",
"CMAKE_BUILD_TYPE": "Coverage",
"CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-static-functions",
"CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage"
}
},
{ {
"name": "dev", "name": "dev",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"inherits": [ "inherits": [
"dev-mode", "cpp-standard"
"std"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -fdiagnostics-color=always"
}
},
{
"name": "dev-local",
"binaryDir": "${sourceDir}/build",
"inherits": [
"dev-mode",
"std"
], ],
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug", "CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -fdiagnostics-color=always", "CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -fdiagnostics-color=always",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"DRAMSYS_BUILD_TESTS": "ON",
"DRAMSYS_BUILD_BENCHMARKS": "ON",
"DRAMSYS_BUILD_TRACE_ANALYZER": "ON"
}
},
{
"name": "dev-local",
"inherits": [
"dev"
],
"cacheVariables": {
"DRAMSYS_USE_FETCH_CONTENT": "OFF" "DRAMSYS_USE_FETCH_CONTENT": "OFF"
} }
},
{
"name": "dev-vcpkg",
"inherits": [
"dev",
"vcpkg"
],
"cacheVariables": {
"DRAMSYS_USE_FETCH_CONTENT": "ON",
"DRAMSYS_USE_FETCH_CONTENT_INTERNAL": "ON",
"DRAMSYS_USE_FETCH_CONTENT_SYSTEMC": "OFF",
"DRAMSYS_USE_FETCH_CONTENT_SQLITE3": "OFF",
"DRAMSYS_USE_FETCH_CONTENT_NLOHMANN_JSON": "OFF"
}
},
{
"name": "coverage",
"binaryDir": "${sourceDir}/build/coverage",
"inherits": [
"cpp-standard",
"dev"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Coverage",
"CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-static-functions",
"CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage",
"DRAMSYS_ENABLE_COVERAGE": "ON"
}
}
],
"buildPresets": [
{
"name": "build-dev",
"configurePreset": "dev",
"jobs": 0,
"targets": [
"all"
]
},
{
"name": "build-coverage",
"configurePreset": "coverage",
"jobs": 0,
"targets": [
"all"
]
}
],
"testPresets": [
{
"name": "test-dev",
"configurePreset": "dev",
"configuration": "Debug",
"execution": {
"jobs": 0
},
"output": {
"outputOnFailure": true
}
},
{
"name": "test-coverage",
"configurePreset": "coverage",
"configuration": "Coverage",
"execution": {
"jobs": 0
},
"output": {
"outputOnFailure": true
}
} }
] ]
} }