10000 GitHub - jenisys/explore.cmake-presets: Explore how cmake-presets can be used.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jenisys/explore.cmake-presets

Repository files navigation

Explore CMake-Presets

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

RELATED TO: cmake-presets issues

cmake: Invalid Preset

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 a list/dict.

  • Violates JSON schema: Does not conform to the JSON schema for cmake-presets

  • JSON schema check is OK, but cmake still complains:

    • preset data is internally inconsistent for cmake.

      EXAMPLE: generator = ... is missing in inherited ConfigurePreset

    • macro-expansion fails, because placeholder is not supported for this preset-type.

      EXAMPLE: Using "outputLogfile" = "${binaryDir}/some.log" in TestPreset

    • macro-expansion fails, like: ...

BEST PRACTICE:

Use a JSON schema checker/linter to find the most common errors. This solves the following problem points:

# -- 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:

SIDE NOTE: codespell

Category:spelling-checker

About

Explore how cmake-presets can be used.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0