If you want to use the presets in an IDE
, you only need the configurePresets
, or not?
If you do not know, what the binary directory
is, you need the buildPresets
too on console.
And with the cmake --build builddirpath --taget test
you need no testPresets
!
If the user has a Multi-Config
project created, than the user may switch with --config
i.e. from Debug
to Release
.
cmake . --preset=ninja-multi cmake --build --preset=ninja-multi --config Release
cmake --build --preset=ninja-multi --config Release --target help # or test, install, ...
ctest --preset=ninja-multi --build-config Release
And perheps, see your preset list available for your host:
use cmake . --list-presets=all
But this does not work out of the box! see this post
ClausKlein
(Claus Klein)
4
If used in workflow
presets, the testPresets
makes sense. i.e.:
cat CMakePresets.json
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default develop test Config",
"description": "Default build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceParentDir}/build/test",
"installDir": "${sourceParentDir}/stagedir",
"cacheVariables": {
"CMAKE_PREFIX_PATH": {
"type": "path",
"value": "${sourceParentDir}/stagedir"
},
"CMAKE_CXX_STANDARD": "20",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_DEBUG_POSTFIX": "D",
"CPM_USE_LOCAL_PACKAGES": "NO",
"BUILD_SHARED_LIBS": "YES",
"TEST_INSTALLED_VERSION": "YES"
},
"environment": {
"CPM_USE_LOCAL_PACKAGES": "YES",
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}",
"LD_LIBRARY_PATH": "${sourceParentDir}/stagedir/lib${pathListSep}penv{LD_LIBRARY_PATH}"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": true}
}
],
"packagePresets": [
{
"name": "default",
"configurePreset": "default",
"generators": [
"TGZ"
]
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
},
{
"type": "test",
"name": "default"
}
]
}
]
}