-
Notifications
You must be signed in to change notification settings - Fork 0
Build System
CMake, which is an open-source system that manages the firmware build process, was chosen as the foundation of the mJacket API build strategy in order to provide compatibility across a wide range of development environments, as well as to provide flexibility in configuring the API to best suit the project that is using it.
"CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner. Unlike many cross-platform systems, CMake is designed to be used in conjunction with the native build environment. Simple configuration files placed in each source directory (called CMakeLists.txt files) are used to generate standard build files (e.g., makefiles on Unix and projects/workspaces in Windows MSVC) which are used in the usual way. CMake can generate a native build environment that will compile source code, create libraries, generate wrappers, and build executables in arbitrary combinations. CMake supports in-place and out-of-place builds, and can, therefore, support multiple builds from a single source tree. CMake also supports static and dynamic library builds. Another nice feature of CMake is that it generates a cache file that is designed to be used with a graphical editor. For example, when CMake runs, it locates files, libraries, and executables, and may encounter optional build directives. This information is gathered into the cache, which may be changed by the user prior to the generation of the native build files." - https://cmake.org
The mJackets API uses what is called Modern CMake, which is technically CMake version 3.0 and greater. Modern CMake takes a different approach than traditional CMake, and is much more streamlined and efficient. Below are some detailed references on Modern CMake and best practices:
The mJacket's API incorporates many of the functionalities of Modern CMake such as:
- Interface libraries
The mJackets API requires CMake version 3.13 as the minimum version in order to support several more recent features of CMake such as target_link_options.
Setting up a robust CMake system is no small feat. Luckily, thanks to the wonderful open-source community, there exists a project called stm32-cmake (https://github.com/ObKo/stm32-cmake), which is essentially a collection of CMake files designed to configure a build system for STM32 applications. It supports the full range of ST Microelectronics ARM Cortex-M 32-bit microcontrollers and compiles using GCC.
The CMake system used in the mJackets-api is a heavily modified version of the modern CMake branch of the stm32-cmake project. The main modifications made were to support the inclusion of the API libraries, as well as to remove the dependency on STM32CubeMX. The mJackets API CMake system is designed to be mostly independent of STM32CubeMX, and requires at a minimum only a HAL config file and a pin definition list to compile firmware for a particular target board. This is accomplished by directly incorporating the source repositories used by STM32CubeMX into the API, and dynamically configuring the build system based on the configuration of the target microcontroller. An in-depth explanation on how this is accomplished is provided below.