Date: | 2023-06-11 |
---|
Explore how cmake-presets can be used.
# -- STEP: Which cmake-presets are available ?!
$ cmake --list-presets
Available configure presets:
"debug" - debug
"release" - release
"multi" - multi
"multi.release" - multi.release
# -- STEP: Init/configure CMAKE_BUILD_DIR by using a preset=<PRESET_NAME>
$ cmake --preset=multi
# -- STEP: Run a workflow by using a preset=<PRESET_NAME>
# WORKFLOW STEPS: init, build, test, ...
$ cmake --workflow --preset=multi
SEE ALSO:
EXAMPLES FOR: CMakePresets.json
- repo: cmake/Help/manual/presets/example.json ( file: example.json)
- repo: cmake/Tests/RunCMake/CMakePresetsTest/Good.json.in ( file: CMakePresetsTest/Good.json.in)
- repo: cpp-best-practices/cmake_template/CMakePresets.json ( file: CMakePresets.json)
RELATED TO: cmake-presets issues
- ON_ERROR: cmake #21310: Presets-related error messages don't provide enough information
- ANY_OS: cmake #23283: presets: Inheritance of conditional presets
- ANY_OS: cmake #24976: Portable way to set filepaths in presets
You often run into problems while developing a CMakePresets.json
file,
where cmake just states invalid preset
without any explanation.
REASONS:
Invalid JSON, like:
trailing-comma
for last entry in alist
/dict
.Violates JSON schema: Does not conform to the JSON schema for cmake-presets
JSON schema
check isOK
, but cmake still complains:preset data is internally inconsistent for cmake.
EXAMPLE:
generator = ...
is missing in inheritedConfigurePreset
macro-expansion fails, because
placeholder
is not supported for this preset-type.EXAMPLE: Using
"outputLogfile" = "${binaryDir}/some.log"
inTestPreset
macro-expansion fails, like: ...
Use a JSON schema checker/linter to find the most common errors. This solves the following problem points:
- Invalid JSON
- Violates JSON schema for cmake-presets
# -- REQUIRES: pip install check-jsonschema
# cmake-presets.schema.json: https://gitlab.kitware.com/cmake/cmake/-/blob/master/Help/manual/presets/schema.json
$ check-jsonschema --schemafile cmake-preset.schema.json --verbose CMakePresets.json
# -- ALTERNATIVE: USE SCRIPT: bin/check_cmake-presets.sh
$ bin/check_cmake-presets.sh # CHECKS: CMakePresets.json (implicit)
$ bin/check_cmake-presets.sh CMakePresets.json # CHECKS: CMakePresets.json (explicit)
$ bin/check_cmake-presets.sh CMakePresets1.json CMakePresets2.json ... # CHECKS: Many files
SEE ALSO:
Category: | spelling-checker |
---|
- https://github.com/codespell-project/codespell (language: Python3, license: GPL-2.0)
- EXAMPLE: https://gitlab.kitware.com/cmake/cmake/-/blob/master/.codespellrc
- https://www.thegeekdiary.com/codespell-spellchecker-for-source-code/