Skip to content

Commit 5bee31c

Browse files
massonalfpistm
authored andcommitted
cmake: Add a a page on cubeIDE
1 parent 44bec92 commit 5bee31c

File tree

11 files changed

+73
-1
lines changed

11 files changed

+73
-1
lines changed

_Sidebar.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@
7070
- [[Functions reference]]
7171
- [[Arduino (in)compatibility]]
7272
- [[Advanced usage]]
73-
73+
- [[cubeIDE]]
74+
7475
</details>

_cmake/CMake_presentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ Before delving into this wiki, be sure to read [the dedicated README](https://gi
3232
- [[Functions reference]]
3333
- [[Arduino (in)compatibility]]
3434
- [[Advanced usage]]
35+
- [[cubeIDE]]

_cmake/cubeIDE.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
CMake projects may be integrated in various IDEs.
2+
3+
Some IDEs sport a CMake plug-in, notably VScode.
4+
This is the easy case -- please refer to the documentation of the relevant plug-in.
5+
6+
Unfortunately, ST's Cube IDE does not have such a plug-in. A procedure to handle CMake projects nonetheless,
7+
using its built-in support for Makefiles, is detailed below.
8+
9+
# Requirements
10+
11+
The same requirements as detailed in the [[Setup]] page for shell users apply.
12+
13+
# Walkthrough
14+
15+
The first step is to create or import a __"Makefile Project with Existing Code"__:
16+
17+
![1](./img/cmake_cubeIDE/1.png)
18+
19+
-----------------
20+
21+
Then browse for the project's location, and leave all other settings to default as illustrated below:
22+
23+
![2](./img/cmake_cubeIDE/2.png)
24+
25+
-----------------
26+
27+
The next step is to fill in the build settings.
28+
Right click on the project, hit "Properties" (or `Alt`+`Enter`), then go to the "C/C++ build" section.
29+
Fill in the "Builder Settings" and "Behavior" tabs as follows
30+
(be sure to replace the build location with the relevant value for your project).
31+
32+
![3](./img/cmake_cubeIDE/3.png)
33+
![4](./img/cmake_cubeIDE/4.png)
34+
35+
You may also change the build command to "ninja"; this is known to be much more efficient, in terms of build time, than Make.
36+
37+
-----------------
38+
39+
Once this is done, there remains to tell CubeIDE how to run CMake.
40+
Right click on the project, hit "Build targets" -> "Create" (or `Shift`+`F9`, "Add").
41+
42+
![5](./img/cmake_cubeIDE/5.png)
43+
44+
Fill the window that pops up as follows:
45+
46+
![6](./img/cmake_cubeIDE/6.png)
47+
48+
Build command :
49+
```sh
50+
# if you stuck with Make in the previous step
51+
cmake -S [source folder] -B [build folder] -G Unix\ Makefiles
52+
53+
# or, if you picked Ninja earlier,
54+
cmake -S [source folder] -B [build folder] -G Ninja
55+
```
56+
57+
For the source and build folder, you can use one of Cube's automatic variables, such as `${workspace_loc:/1_Blink}/build`, as in the project settings.
58+
Make sure the build folder (`-B`) matches the value you passed in the project build configuration step!
59+
60+
-----------------
61+
62+
Now, all the configuration steps are done.
63+
64+
To run CMake, build the target you created in the previous step (or hit `F9`):
65+
66+
![7](./img/cmake_cubeIDE/7.png)
67+
68+
To or rebuild the project, hit `Ctrl`+`B`, or right-click on the project -> "Build project".
69+
70+
![8](./img/cmake_cubeIDE/8.png)

img/cmake_cubeIDE/1.png

93.9 KB
Loading

img/cmake_cubeIDE/2.png

87.6 KB
Loading

img/cmake_cubeIDE/3.png

150 KB
Loading

img/cmake_cubeIDE/4.png

181 KB
Loading

img/cmake_cubeIDE/5.png

192 KB
Loading

img/cmake_cubeIDE/6.png

44.7 KB
Loading

img/cmake_cubeIDE/7.png

142 KB
Loading

0 commit comments

Comments
 (0)