diff options
author | Gerald Combs <gerald@wireshark.org> | 2022-06-03 13:47:41 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2022-06-05 13:04:07 -0700 |
commit | 2ac2b0670a4ae0d0ea0d481f42f23885aa8c10ce (patch) | |
tree | 6233d7e4566d538b3ac1be92b4dbdbff107ecc20 | |
parent | c0bd7266ad6f08e7b8af5f96718a55f3d62175c5 (diff) |
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
.editorconfig.
-rw-r--r-- | .editorconfig | 3 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_tools.adoc | 27 |
3 files changed, 28 insertions, 4 deletions
diff --git a/.editorconfig b/.editorconfig index 14417951b3..2e412b62a3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,6 +20,9 @@ insert_final_newline = true # https://gitlab.kitware.com/cmake/cmake/-/blob/master/.editorconfig [{CMake*,*.cmake,*.cmake.in}] indent_style = tab +[CMake*.json] +indent_style = space +indent_size = 2 # Makefiles. Although we dropped Autotools we still have a few lying around. [Makefile*] diff --git a/.gitignore b/.gitignore index 60422d33c0..ad0e6c90a1 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ wireshark-tap-register.c /*build*/ CMakeCache.txt CMakeFiles -CMakeListsCustom.txt +CMakeUserPresets.json cmake_install.cmake CPackConfig.cmake CPackSourceConfig.cmake diff --git a/docbook/wsdg_src/WSDG_chapter_tools.adoc b/docbook/wsdg_src/WSDG_chapter_tools.adoc index d3a866fbc8..b0572ebc77 100644 --- a/docbook/wsdg_src/WSDG_chapter_tools.adoc +++ b/docbook/wsdg_src/WSDG_chapter_tools.adoc @@ -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 https://cmake.org/cmake/help/latest/manual/cmake.1.html#options[`-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 https://cmake.org/cmake/help/v3.23/manual/cmake-presets.7.html[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`: + +[source,json] +---- +{ + "version: 4, + "configurePresets": [ + { + "name": "mydev", + "displayName": "Local development", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "ENABLE_CCACHE": "ON", + }, + "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. |