Skip to content

Commit

Permalink
Refactory cmake preset
Browse files Browse the repository at this point in the history
add Debug and Relese workflow presets
use Ninja Multi-Config generator for Debug
  • Loading branch information
ClausKlein committed Feb 15, 2024
1 parent 3e282e3 commit b96c595
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 149 deletions.
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ build-job: # This job runs in the build stage, which runs first.
extends:
- .standard-rules # Reuse the configuration in `.standard-rules` here
script:
- echo "Build default workflow ..."
- cmake --workflow --preset default --fresh
- echo "Build Release workflow ..."
- cmake --workflow --preset Release --fresh
- echo "Build workflow complete."

unit-test-job: # This job runs in the test stage.
Expand All @@ -73,8 +73,8 @@ unit-test-job: # This job runs in the test stage.
- .standard-rules # Reuse the configuration in `.standard-rules` here
script:
- echo "Running unit tests... This will take about a view seconds."
- cmake --preset default --fresh
- cmake --build --preset default --target test
- cmake --preset Release --fresh
- cmake --build --preset Release --target test
- gcovr .

lint-test-job: # This job also runs in the test stage.
Expand Down
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(ENABLE_SANITIZER_THREAD "ENABLE_SANITIZER_THREAD")
else()
check_sanitizers_support(
ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_LEAK ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY
)
endif()

Expand Down Expand Up @@ -186,7 +185,7 @@ if(NETKIT_TFTP_TESTS)
if(UNIX)
add_test(
NAME tftpd_test
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh $<TARGET_FILE:tftpd_test>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
Expand Down
233 changes: 123 additions & 110 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,128 +1,141 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default user Config",
"description": "Default build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"installDir": "${sourceDir}/stagedir",
"cacheVariables": {
"CMAKE_PREFIX_PATH": {
"type": "path",
"value": "${sourceDir}/stagedir"
},
"CMAKE_CXX_STANDARD": "20",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_DEBUG_POSTFIX": "D",
"BUILD_SHARED_LIBS": true
},
"environment": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
"CPM_USE_LOCAL_PACKAGES": "NO",
"CPM_SOURCE_CACHE": "$env{HOME}/.cache/CPM",
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}"
},
"warnings": {
"deprecated": true,
"uninitialized": true
}
},
{
"name": "ninja-multi",
"inherits": "default",
"displayName": "Ninja Multi-Config",
"description": "Default build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config"
},
{
"name": "windows-only",
"inherits": "default",
"displayName": "Windows-only configuration",
"description": "This build is only available on Windows",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
{
"name": "install",
"configurePreset": "default",
"targets": ["install"]
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": true}
}
],
"packagePresets": [
{
"name": "default",
"configurePreset": "default",
"generators": [
"TGZ"
]
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
"configurePresets": [
{
"type": "configure",
"name": "default"
"name": "Release",
"displayName": "Release user Config",
"description": "Release build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/{presetName}",
"installDir": "${sourceDir}/stagedir",
"cacheVariables": {
"CMAKE_PREFIX_PATH": {
"type": "path",
"value": "${sourceDir}/stagedir"
},
"CMAKE_CXX_STANDARD": "20",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_DEBUG_POSTFIX": "D",
"BUILD_SHARED_LIBS": true
},
"environment": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
"CPM_USE_LOCAL_PACKAGES": "NO",
"CPM_SOURCE_CACHE": "$env{HOME}/.cache/CPM",
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}"
},
"warnings": {
"deprecated": true,
"uninitialized": true
}
},
{
"type": "build",
"name": "default"
},
"name": "Debug",
"inherits": "Release",
"displayName": "Ninja Multi-Config",
"description": "Debug build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config"
}
],
"buildPresets": [
{
"type": "test",
"name": "default"
"name": "Debug",
"configurePreset": "Debug",
"configuration": "Debug"
},
{
"type": "build",
"name": "install"
"name": "Release",
"configurePreset": "Release"
},
{
"type": "package",
"name": "default"
"name": "install",
"configurePreset": "Release",
"targets": [
"install"
]
}
]
},
{
"name": "debug",
"steps": [
],
"testPresets": [
{
"type": "configure",
"name": "default"
"name": "Release",
"configurePreset": "Release",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
},
{
"type": "build",
"name": "default"
"name": "Debug",
"configurePreset": "Debug",
"configuration": "Debug",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
}
],
"packagePresets": [
{
"name": "Release",
"configurePreset": "Release",
"generators": [
"TGZ"
]
}
],
"workflowPresets": [
{
"name": "Release",
"steps": [
{
"type": "configure",
"name": "Release"
},
{
"type": "build",
"name": "Release"
},
{
"type": "test",
"name": "Release"
},
{
"type": "build",
"name": "install"
},
{
"type": "package",
"name": "Release"
}
]
},
{
"type": "test",
"name": "default"
"name": "Debug",
"steps": [
{
"type": "configure",
"name": "Debug"
},
{
"type": "build",
"name": "Debug"
},
{
"type": "test",
"name": "Debug"
}
]
}
]
}
]
]
}
Loading

0 comments on commit b96c595

Please sign in to comment.