Git+CMake: Add support for CMake presets.

CMake 3.19 added support for CMakePresets.json and
CMakeUserPresets.json, which let you prepopulate various configure,
build, and test options. Add CMakeUserPresets.json to .gitignore as
recommended by the documentation and add an example to the Developer's
Guide. CMake uses 2-space indentation; specify that for CMake*.json in
Gerald Combs 2022-06-03 13:47:41 -07:00
parent c0bd7266ad
commit 2ac2b0670a
3 changed files with 28 additions and 4 deletions

View File

@ -20,6 +20,9 @@ insert_final_newline = true
indent_style = tab
indent_style = space
indent_size = 2
# Makefiles. Although we dropped Autotools we still have a few lying around.

.gitignore vendored
View File

@ -60,7 +60,7 @@ wireshark-tap-register.c

View File

@ -129,9 +129,30 @@ You can list all build variables (with help) by running `cmake -LH [options]
../<Name_of_WS_source_dir>`. This lists the cache of build variables
after the cmake run. To only view the current cache, add option `-N`.
You prepopulate variables using CMake's[`-C` command line option] or by adding a file named `CMakeListsCustom.txt` to the top-level source directory.
In either case you must set each variable using CMake's “set” command.
For example `set(ENABLE_CCACHE ON)` will enable ccache.
Depending on your needs, it might be useful to save your CMake configuration options in a file outside your build directory.
CMake supports this via its[presets] option.
For example, adding the follwing to `CMakeUserPresets.json` would let you build using Ninja in the `build` directory, enable ccache, and set a custom Qt directory by running `cmake --preset mydev`:
"version: 4,
"configurePresets": [
"name": "mydev",
"displayName": "Local development",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"environment": {
"CMAKE_PREFIX_PATH": "/usr/local/Qt6"
After running cmake, you can always run `make help` to see a list of all possible make targets.