Skip to content

Commit 456bffb

Browse files
committed
feat: add cmakepresets.json
This file helps editors to generate compile_commands.json database files as well as streamlining some of the cmake commands.
1 parent 3fa4969 commit 456bffb

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

CMakePresets.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"binaryDir": "build/${presetName}",
6+
"name": "Release",
7+
"displayName": "Release build",
8+
"cacheVariables": {
9+
"ARM_NONE_EABI_TOOLCHAIN_PATH": "${fileDir}/sdk-toolchain/gcc-arm-none-eabi-10.3-2021.10",
10+
"NRF5_SDK_PATH": "${fileDir}/sdk-toolchain/nRF5_SDK_15.3.0_59ac345",
11+
"CMAKE_BUILD_TYPE": "Release",
12+
"BUILD_DFU": "1",
13+
"BUILD_RESOURCES": "1"
14+
}
15+
}
16+
],
17+
"buildPresets": [
18+
{
19+
"name": "Release",
20+
"configurePreset": "Release"
21+
}
22+
]
23+
}

doc/buildAndProgram.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ To build this project, you'll need:
1212
python -m venv .venv
1313
source .venv/bin/activate
1414
python -m pip install wheel
15-
python -m pip install -r tools/mcuboot/requirements.txt
15+
python -m pip install -r tools/mcuboot/requirements.txt adafruit-nrfutil
1616
```
17-
- A reasonably recent version of CMake (I use 3.16.5)
17+
- A reasonably recent version of CMake (minimum 3.10)
1818
- lv_font_conv, to generate the font .c files
1919
- see [lv_font_conv](https://github.com/lvgl/lv_font_conv#install-the-script)
2020
- install npm (commonly done via the package manager, ensure node's version is at least 12)
@@ -24,7 +24,7 @@ To build this project, you'll need:
2424
2525
### Clone the repo
2626
27-
```
27+
```sh
2828
git clone https://github.com/InfiniTimeOrg/InfiniTime.git
2929
cd InfiniTime
3030
git submodule update --init
@@ -34,6 +34,40 @@ cd build
3434
3535
### Project generation using CMake
3636
37+
#### CMakePresets
38+
39+
Note that this requires CMake 3.19 or later to be installed.
40+
This project provides a `CMakePresets.json` file, enabling easy and fast development with modern editors such as VSCode, neovim or CLion.
41+
The `CMakePresets.json` file looks for the arm-gcc toolchaing and NRF52 SDK in the `sdk-toolchain` directory.
42+
So to download and exctract these in the correct directory, do the following:
43+
44+
```sh
45+
mkdir -p sdk-toolchain
46+
47+
# Get the nRF5 SDK
48+
wget https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip
49+
mv nRF5_SDK_15.3.0_59ac345.zip sdk-toolchain/
50+
cd sdk-toolchain
51+
unzip nRF5_SDK_15.3.0_59ac345.zip
52+
cd -
53+
54+
# Get the arm cross compiler (There's probably a more linux-y way of doing this though...)
55+
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
56+
mv gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 sdk-toolchain/
57+
cd sdk-toolchain
58+
tar xjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
59+
cd -
60+
```
61+
62+
To use the presets, simply call `cmake` like so (make sure you have activated the python virtual environment as described [above](##dependencies)):
63+
64+
```sh
65+
cmake --preset Release
66+
cmake --build build/Release
67+
```
68+
69+
#### CMake Variables
70+
3771
CMake configures the project according to variables you specify the command line. The variables are:
3872

3973
Variable | Description | Example|

0 commit comments

Comments
 (0)