From 0a446a312fdd6260320eeed51697ecadf61ee11f Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 10 Mar 2023 10:51:26 +0100 Subject: [PATCH 1/2] cmake: Add dev-mode CMake preset To use, invoke `cmake` with argument `--preset dev-mode`. Solves one item in #1235. One disadvantage over `./configure --enable-dev-mode` is that CMake does not provide a way to "hide" presets from users. That is, `cmake --list-presets` will list dev-mode, and it will also appear in `cmake-gui`, even though it's not selectable there due to bug https://gitlab.kitware.com/cmake/cmake/-/issues/23341. (So in our case, that's probably rather a feature than a bug.) We curently use version 3 presets which require CMake 3.21+. Unfortunately, CMake versions before 3.19 may ignore the `--preset` argument silently. So if the preset is not picked up, make sure you have a recent enough CMake version. More unfortunately, we can't even spell this warning out in CMakePresets.json because CMake does not support officially support comments in JSON, see - https://gitlab.kitware.com/cmake/cmake/-/issues/21858 - https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5853 . We could use a hack hinted at in https://gitlab.kitware.com/cmake/cmake/-/issues/21858#note_908543 but that's risky, because it could simply break for future versions, and we probably want to use presets not only for dev mode. --- CMakePresets.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 CMakePresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..b35cd80579 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,19 @@ +{ + "cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0}, + "version": 3, + "configurePresets": [ + { + "name": "dev-mode", + "displayName": "Development mode (intended only for developers of the library)", + "cacheVariables": { + "SECP256K1_EXPERIMENTAL": "ON", + "SECP256K1_ENABLE_MODULE_RECOVERY": "ON", + "SECP256K1_BUILD_EXAMPLES": "ON" + }, + "warnings": { + "dev": true, + "uninitialized": true + } + } + ] +} From ce5ba9e24dfcceb49ed7f83a87548fd8b3b0cab2 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Thu, 16 Mar 2023 22:58:24 +0900 Subject: [PATCH 2/2] gitignore: Add CMakeUserPresets.json This file is specifically intended for *local* CMake templates (as opposed to CMakePresets.json). --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bc7e499de7..574902b8b5 100644 --- a/.gitignore +++ b/.gitignore @@ -59,5 +59,7 @@ build-aux/compile build-aux/test-driver libsecp256k1.pc +### CMake +/CMakeUserPresets.json # Default CMake build directory. /build