|
| 1 | +--- |
| 2 | +title: CMake Options Guide |
| 3 | +description: Some useful options and options that we have defined |
| 4 | +--- |
| 5 | +The following is a list of options along with their brief description. The guide is divided into most used and extra for convenience. You can go to the end of this page for examples on how to chain these options together. |
| 6 | + |
| 7 | +:::note |
| 8 | +**Options suffixed with an equal sign should have an argument passed into them.** Options without an equal sign suffix just need to be specified, no arguments needed. |
| 9 | + |
| 10 | +If an argument is marked as **Default**, it will be the default argument that is used if the option is not specified. If there are no arguments marked as default then nothing will happen. |
| 11 | +::: |
| 12 | + |
| 13 | +## Most Used Options |
| 14 | +These are options that you will frequently be using while compiling. **Unless otherwise specified these options are to be use within the `build_arm` directory of the project** |
| 15 | + |
| 16 | +### `-DCMAKE_BUILD_TYPE=` (Can be used in directories other than `build_arm`) |
| 17 | +This specifies what the current build directory is for. You can pass either of the **four** arguments into this command... |
| 18 | +* `OBC`: Used to build for the board (use in the `build_arm` directory) |
| 19 | +* `GS`: Used to build code for the ground station (use in the `build_gs` directory) |
| 20 | +* `Test`: Used to build the testing directory for the interfaces (use in the `build` folder) |
| 21 | +* `Examples`: Used to build examples which are barebone binaries to test certain functionality on the board (use in the `build_examples` directory) |
| 22 | + |
| 23 | +### `-DBOARD_TYPE=` |
| 24 | +This option specifies the board that the binary is being built for since different board files will require different HAL (Hardware Abstraction Layer) files to be sourced. You can pass either of the **three** arguments... |
| 25 | +* **Default** `RM46_LAUNCHPAD`: Build the files for the launchpad board |
| 26 | +* `OBC_REVISION_1`: Build the files for the first revision of the OBC |
| 27 | +* `OBC_REVISION_2`: Build the files for the second revision of the OBC |
| 28 | + |
| 29 | + |
| 30 | +## Extra Options |
| 31 | + |
| 32 | +### `-DDEBUG` |
| 33 | +If specified, this removes all optimization flags to debug. Sometimes optimizations can interfere with critical code but, first check your code's logic before using this option. |
| 34 | + |
| 35 | +### `-DLOG_DEFAULT_LEVEL=` |
| 36 | +Specifies the default level for logs. You can pass any enum in the `obc_logging.h` file to this option. |
| 37 | + |
| 38 | +### `-DENABLE_BL_BYPASS=` |
| 39 | +A boolean (takes a 0 or a 1) that specifies whether the app should bypass the bootloader (when you want to flash without the bootloader) to load the app. The boolean values define the following functionality... |
| 40 | +* `0`: The app should not bypass the bootloader and write to the `0x0` address (this is the default address the board looks for to load a program). |
| 41 | +* **Default** `1`: The app should bypass the bootloader and write to `0x0` |
| 42 | + |
| 43 | +### `-DCOMMS_PHY=` |
| 44 | +:::tip[Warning]{icon="seti:html"} |
| 45 | +This option is not fully implemented yet. It's for when comms is complete. |
| 46 | +::: |
| 47 | + |
| 48 | +### `-DOBC_UART_BAUD_RATE=` |
| 49 | +This option helps set the baud rate for the board. |
| 50 | +:::caution |
| 51 | +When using this option, you have to change the baud rate in the HAL using **`HALCOGen`** |
| 52 | +::: |
| 53 | +You can pass any **valid integer baud rate** into this option. |
| 54 | + |
| 55 | +### `-DENABLE_TASK_STATS_COLLECTOR` |
| 56 | +This option enables or disables the task stats collector (statistics on how much memory/cpu each task is using sent via logs). This is a boolean option with each argument defining the functionality... |
| 57 | +* `0`: The app should not send task statistics via logs |
| 58 | +* **Default** `1`: The app should send task statistics via logs |
| 59 | + |
| 60 | +### `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` |
| 61 | +This is a useful option for IDEs like `neovim` that use Language Servers that require a `compile_commands.json` file. If specified this command will generate a `compile_commands.json` file, else it will not. |
| 62 | +:::tip |
| 63 | +By default cmake will generate this file in the directory you use the `cmake ..` command in. You may have to create a symbolic link to a `compile_commands.json` file in your root directory. |
| 64 | +::: |
| 65 | + |
| 66 | +## Examples |
| 67 | +The following are some examples that might be useful in understanding how to define these options. |
| 68 | + |
| 69 | +1. Say you wanted to build for the 1st revision of the obc and wanted to use the bootloader. |
| 70 | + ```shell |
| 71 | + cmake .. -DCMAKE_BUILD_TYPE=OBC -DBOARD_TYPE=OBC_REVISION_1 -DENABLE_BL_BYPASS=0 |
| 72 | + ``` |
| 73 | + |
| 74 | +2. Say you wanted to build for the 2nd revision of the obc and wanted to output compile commands as well. |
| 75 | + ```shell |
| 76 | + cmake .. -DCMAKE_BUILD_TYPE=OBC -DBOARD_TYPE=OBC_REVISION_2 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 77 | + ``` |
0 commit comments