Skip to content

Commit 380e068

Browse files
author
gojimmypi
committed
Introduce CMakePresets.json and CMakeSettings.json
1 parent 7610b4e commit 380e068

4 files changed

Lines changed: 83 additions & 0 deletions

File tree

CMakePresets.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 22,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "vs2022-x64",
11+
"displayName": "Visual Studio 2022 x64",
12+
"generator": "Visual Studio 17 2022",
13+
"architecture": "x64",
14+
"binaryDir": "${sourceDir}/build",
15+
"cacheVariables": {
16+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
17+
}
18+
}
19+
]
20+
}

CMakeSettings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "No-CMake",
5+
"generator": "Ninja",
6+
"buildCommandArgs": "echo 'No build command'"
7+
}
8+
]
9+
}

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ EXTRA_DIST+= LPCExpresso.cproject
156156
EXTRA_DIST+= LPCExpresso.project
157157
EXTRA_DIST+= resource.h wolfssl.rc
158158
EXTRA_DIST+= CMakeLists.txt
159+
EXTRA_DIST+= CMakePresets.json
160+
EXTRA_DIST+= CMakeSettings.json
159161
EXTRA_DIST+= m4/ax_atomic.m4
160162

161163
include cmake/include.am

cmake/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,55 @@ This directory contains some supplementary functions for the [CMakeLists.txt](..
55
See also cmake notes in the [INSTALL](../INSTALL) documentation file.
66

77
If new CMake build options are added `cmake/options.h.in` must also be updated.
8+
9+
For more information on building wolfSSL, see the [wolfSSL Manual](https://www.wolfssl.com/documentation/manuals/wolfssl/).
10+
11+
In summary for cmake:
12+
13+
```
14+
# From the root of the wolfSSL repo:
15+
16+
mkdir -p out
17+
pushd out
18+
cmake ..
19+
cmake --build .
20+
21+
# View the available ciphers with:
22+
./examples/client/client -e
23+
popd
24+
```
25+
26+
## CMake Presets
27+
28+
The `CMakePresets.json`; see [cmake-presets(https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html)
29+
30+
- Cross-platform and cross-IDE.
31+
32+
- Standardized CMake feature (since CMake 3.19+, recommended after 3.21).
33+
34+
- Works in Visual Studio, VS Code, CLI, CI systems, etc..
35+
36+
## Visual Studio Settings
37+
38+
There's also a Visual Studio specific file: `CMakeSettings.json`. This the file that supports the GUI CMake settings.
39+
40+
See the Microsoft [CMakeSettings.json schema reference](https://learn.microsoft.com/en-us/cpp/build/cmakesettings-reference?view=msvc-170)
41+
42+
## Visual Studio (2022 v17.1 and later):
43+
44+
- Prefers `CMakePresets.json` if it exists.
45+
46+
- Falls back to `CMakeSettings.json` if no presets are found.
47+
48+
- Lets you override or extend presets via `CMakeSettings.json`.
49+
50+
### Recommendations:
51+
52+
- Use `CMakePresets.json` to define shared, cross-platform presets.
53+
54+
- Use `CMakeSettings.json` to define Visual Studio-specific overrides, like:
55+
* Custom output directories
56+
* Specific environment variables
57+
* *UI-related tweaks
58+
59+

0 commit comments

Comments
 (0)