Skip to content

Commit daa1820

Browse files
authored
Updated ##building-projects
- Minor changes for disambiguation around ##building-projects - Updated examples for IAR_INSTALL_DIR - Updated *notes* for IAR_INSTALL_DIR - Updated ###configuring-the-build-system-generator
1 parent 128eebc commit daa1820

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

README.md

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,48 +38,43 @@ On the [examples/iar-toolchain.cmake](examples/iar-toolchain.cmake) file, perfor
3838
* Update [__CMAKE_SYSTEM_PROCESSOR__](examples/iar-toolchain.cmake#L11) with one of the valid compiler's target `<arch>`:
3939
>`430`, `8051`, `arm`, `avr`, `riscv`, `rx`, `rh850`, `rl78`, `stm8` or `v850`.
4040
41-
* Update [__IAR_INSTALL_DIR__](examples/iar-toolchain.cmake#L14) to point to the location where the corresponding IAR tools are __installed__ on __your__ system:
42-
>__Windows__ examples:
43-
>```
44-
>"C:/Program\ Files/IAR\ Systems/Embedded\ Workbench\ 9.0"
45-
>```
46-
>```
47-
>"C:/IAR_Systems/EWARM/9.10.2"
48-
>```
49-
>__Linux__ examples:
50-
>```
51-
>"/opt/iarsystems/bxarm-9.10.2"
52-
>```
53-
>```
54-
>"/opt/iarsystems/bxarm"
55-
>```
56-
> __Notes__
57-
> * If the __IAR_INSTALL_DIR__ contains blank spaces, it might be necessary to escape them using backslashes `\ ` or, instead, use `\\`.
58-
> * __Do not__ include `<arch>/bin` on the __IAR_INSTALL_DIR__ variable. The `<arch>` will be automatically added in the [__TOOLKIT_DIR__](https://github.com/IARSystems/cmake-tutorial/blob/1.0.0/examples/iar-toolchain.cmake#L17) variable using __CMAKE_SYSTEM_PROCESSOR__. The `/bin` sub-directory will be hardcoded to the ephemeral `PATH` environment variable used internally while CMake is running.
41+
* Update [__IAR_INSTALL_DIR__](examples/iar-toolchain.cmake#L14) to match the corresponding location where the active product was __installed__ on __your__ system, adjusting as needed. Below you will find some general examples for Windows and Linux:
42+
43+
| IAR_INSTALL_DIR example for | Windows tools | Linux tools |
44+
| ------------------------------- | ----------------------------------------------------------- | ------------------------- |
45+
| a typical installation location | `"C:/Program\ Files/IAR\ Systems/Embedded\ Workbench\ N.n"` | `"/opt/iarsystems/bxarm"` |
46+
| a custom installation location | `"C:/IAR_Systems/EWARM/N.nn.n"` | Not applicable |
47+
48+
> __Notes on IAR_INSTALL_DIR__
49+
> * Replace `N.nn` by the active product's corresponding version.
50+
> * If the path contains blank spaces, escape them with backslashes (`\ `).
51+
> * The [__TOOLKIT_DIR__](https://github.com/IARSystems/cmake-tutorial/blob/1.0.0/examples/iar-toolchain.cmake#L17) is a variable that points to the directory of the active product. (e.g. `"${IAR_INSTALL_DIR}/${CMAKE_SYSTEM_PROCESSOR}"`).
52+
> * The __TOOLKIT_DIR__ variable is used to set the [PATH](https://github.com/IARSystems/cmake-tutorial/blob/1.0.0/examples/iar-toolchain.cmake#L20-L24) environment variable with the `bin` directory so that the compiler can be found on the search path. Setting the PATH with this method lasts for the time CMake is running.
5953
6054
* When using the __IAR Assembler__ for `430`, `8051`, `avr` or `v850` architecture, update [__CMAKE_ASM_COMPILER__](examples/iar-toolchain.cmake#L29) to:
6155
>`"a${CMAKE_SYSTEM_PROCESSOR}"`
6256
6357

64-
### Generate a <i>Project Buildsystem</i>
65-
The general syntax to generate the input files for a native build system is:
66-
```
67-
cmake -G <generator> -B <build-dir> --toolchain <file>
68-
```
58+
### Configuring the build system generator
59+
Once the toolchain file is modified, the next step for when cross-compiling with CMake is the configuration step. Among other possibilities, here is possible to choose which _build system generator_ and _toolchain file_ should be used for a project. A project is defined by one or more CMakeLists.txt file(s). Details about these files can be found in the [examples](#examples) section.
60+
61+
The simplified general syntax for the configuration step is: `cmake -G <generator> -B <build-dir> --toolchain <file>`.
6962

70-
|__Option__ | __Explanation__ |
71-
| :------------ | :---------------------------------------------------------------------------------------------------------------------- |
72-
| `-B` | Explicitly specify a build directory. |
73-
| `-G` | Specify a generator name. |
74-
| `--toolchain` | Specify the toolchain file `[CMAKE_TOOLCHAIN_FILE]` |
63+
|__Option__ | __Explanation__ |
64+
| :------------ | :---------------------------------------------------- |
65+
| `-B` | Explicitly specify a build directory. |
66+
| `-G` | Specify a build system generator. |
67+
| `--toolchain` | Specify the toolchain file `[CMAKE_TOOLCHAIN_FILE]` |
7568

76-
In this example we will use the __Ninja__ generator. Once the toolchain file is modified, inside each example's __architecture__ subdirectory, use the following command to generate the build scripts in the `_builds` sub-directory:
69+
>:bulb: Use `cmake --help` for more information.
70+
71+
In this example we will take advantage of the `"Ninja Multi-Config"` generator option. This option can be used to generate build configurations for "Debug" and "Release" purposes. From inside each example's __architecture__ subdirectory you will find a corresponding CMakeLists.txt. From that location, use the following command to generate the scripts for the build system in the `_builds` sub-directory:
7772
```
7873
cmake -G "Ninja Multi-Config" -B_builds --toolchain ../../iar-toolchain.cmake
7974
```
8075
The expected output is similar to:
8176
>```
82-
>-- The C compiler identification is IAR <ARCH> <VERSION>
77+
>-- The C compiler identification is IAR <ARCH> N.nn
8378
>-- Detecting C compiler ABI info
8479
>-- Detecting C compiler ABI info - done
8580
>-- Check for working C compiler: C:/<install-path>/<arch>/bin/icc<arch>.exe - skipped
@@ -90,15 +85,13 @@ The expected output is similar to:
9085
>-- Build files have been written to: C:/<...>/cmake-tutorial/examples/<example>/<arch>/_builds
9186
>```
9287
93-
>:warning: Once the `_builds` is configured, there is no need to re-run the configuration step, except if there are changes to the toolchain file.
88+
>:bulb: Once the `_builds` is configured, there is no need to re-run the configuration step, except if there are changes to the toolchain file.
9489
95-
>:warning: If for some reason the configuration step fails, try removing the `_builds` subdirectory before running it again, in order to avoid any potential cache misses.
90+
>:warning: If for some mistake the configuration step fails (e.g. wrong option, wrong selection, etc.), it might be necessary to remove the `_builds` subdirectory before trying again. This helps CMake to avoid potential cache misses interfering during a new attempt.
9691
9792
### Build the project
98-
The general syntax to __build__ a project through CMake is:
99-
```
100-
cmake --build <build-dir> --config <cfg> [extra-options]
101-
```
93+
The general syntax to __build__ a project through CMake is: `cmake --build <build-dir> --config <cfg> [extra-options]`
94+
10295
|__Option__ | __Explanation__ |
10396
| :----------------------------------- | :---------------------------------------------------------------------------------- |
10497
| `--build` | Build a CMake-generated project binary tree. |

0 commit comments

Comments
 (0)