You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All what can be defined should be in CMake files and configuration (app/mbed .json files). Our build system would parse the configuration, create rules and generate top level CMake file that would include others (application CMake files plus also Mbed OS core CMake).
12
+
All what can be defined should be in CMake files and configuration (app/mbed .json files). Our build system would parse the configurationand generate config CMake file.
9
13
10
14
To stay backward compatible, we create common rules as follows.
11
15
12
-
We replace current `TOOLCHAIN_`, `FEATURE_`, `TARGET_` by providing `add_subdirectory` macros. There would be `if_target()`, `if_feature()`, `_if_toolchain()` macros for better readability.
13
-
14
-
Example, to add stm_directory only for STM targets (current rule TARGET_STM):
15
-
16
-
```
17
-
add_subdirectory_if_target(STM stm_directory)
18
-
19
-
```
16
+
We use target labels to include subfolders. The function goes through target labels and if there is a folder in the current CMake source directory, it includes it.
20
17
21
-
Application example:
18
+
An example, to add `TARGET_STM` in the a folder `targets`:
There would be static CMakes in the `./TARGET_STM/qspi/` and `./TARGET_STM/peripheral_specific_to_stm` that would define what files should be included or specific settins for these modules.
24
+
The same could be applied to other labels like features or components.
37
25
38
26
To migrate to the new build system, we can provide auto scanning of the module and generate CMake based on what we find or use the way as described above. In both cases, we could stay backward compatible.
39
27
40
28
## Mbed OS Core (Mbed OS repository)
41
29
42
30
There are couple of CMakes in the tree.
43
31
44
-
1. Mbed OS boiler plate defined in Mbed OS root (provides way for build system to overwrite/add configuration)
45
-
2. Mbed OS Toolchain settings (toolchain.cmake) that would get generated based on the toolchain selected
46
-
3. Each module has own CMake (describing the module - what files are there, target/feature/component selection based on target, etc)
32
+
1. The boiler plate for Mbed OS defined in Mbed OS root (provides way for the build system to overwrite/add configuration)
33
+
1. Toolchain settings (toolchain.cmake) - configures the toolchain from cmake/toolchains directory based on the selected toolchain (`MBED_TOOLCHAIN`)
34
+
1. Profile configuration (profile.cmake) - configures the profile from cmake/profiles directory based on the selected profile (`MBED_PROFILE`)
35
+
1. Core configuration (core.cmake) - configures the core from cmake/cores directory based on the selected target (`MBED_CPU_CORE`)
36
+
1. Utilities (util.cmake) - functions or macros we use
37
+
1. Application cmake (app.cmake) - an application includes it to
38
+
1. Each component has own CMake file (describing the component - what files are to include, target/feature/component selection based on target, etc)
47
39
48
40
The next sections will describe static CMake files within Mbed OS Core repository.
49
41
50
42
### 1. Boilerplate CMake
51
43
52
-
The main CMake file in Mbes OS repository provides just boilerplate for Mbed OS to be built. It described the Mbed OS tree, provides all the options we have in Mbed OS. This will be autogenerated by the tools.
44
+
The main CMake file in Mbes OS repository provides just boilerplate for Mbed OS to be built. It described the Mbed OS tree, provides all the options we have in Mbed OS.
45
+
46
+
This is not intended to be included by an application.
53
47
54
48
### 2. Toolchain CMake
55
49
56
-
There are 3 toolchains, we provide the template that tools could fill in. The information is already in the build tools, we just need to extract that info and make it CMake compatible.
50
+
All the toolchain settings are defined in cmake/toolchains cmake files.
57
51
58
-
This toolchain CMake is included by the Mbed OS CMake.
52
+
### 3. Profile CMake
59
53
60
-
### 3. Module CMake
54
+
The application profiles are defined in cmake/profiles.
61
55
62
-
This file statically defines the structure of the module within Mbed OS. It's conditionally config based. We use regular CMake expressions plus extend it with own macros to conditionally include/exclude directories. The thumb of the rule, do not expose headers that are internal. We would like to avoid having everything in the include paths as we do now.
56
+
### 4. Core CMake
63
57
58
+
The core definitions are defined in cmake/cores.
64
59
65
-
`add_subdirectory` always adds the directory to the main CMake.
60
+
### 5. Utilities
66
61
67
-
```
68
-
add_subdirectory(drivers)
69
-
```
62
+
Functions or macros that we use within Mbed OS and might be useful for other as well.
63
+
64
+
### 6. Application CMake
70
65
71
-
Conditionally directories addition based on the config:
66
+
This is the cmake that must be included by an application, using:
Conditionally directories addition based on the target/toolchain/feature.
72
+
### 7. Component CMake
78
73
74
+
This file statically defines the structure of the component within Mbed OS. It is conditionally config based. We use regular CMake expressions plus extend it with own macros to conditionally include/exclude directories. The thumb of the rule, do not expose headers that are internal. We would like to avoid having everything in the include paths as we do now.
75
+
76
+
77
+
`add_subdirectory` always adds the directory to the main CMake.
We should provide application CMake functionality with our own configuration. There are couple of approaches we could take. Statically defined CMake but then this disconnectes config and CMake - as CMake contains configuration for a project (like includes, sources, etc). Our build tool would need to parse CMake to get all paths used in the project or Mbed OS to find out where to look for configuration file. Therefore the build system has a knowledge as it is currently. We use `requires` to include/exclude modules.
@@ -96,6 +92,5 @@ A user create own CMake file to configure an application, also with `mbed_app.js
96
92
2. Parse the application configuration
97
93
3. Get the target configuration
98
94
4. Get the Mbed OS configuration (select what modules we need and get their config, paths, etc)
99
-
5. Create the toolchain.cmake file
100
-
6. Inject all previous steps to the Mbed OS Core CMake
0 commit comments