This branch adds comprehensive cmake support to QP/C
## Quick Start
create your project with a root `CMakeLists.txt` file, following this blueprint.
1. copy [qpc_sdk_import.cmake](https://github.com/QuantumLeaps/3rd_party/cmake/qpc_sdk_import.cmake) into your project. Make sure, it can be found by `cmake` as an included script
This file prepares your project for integrating qpc.
Before adding this file to your project with `include(qpc_sdk_import)` make sure to set `CMAKE_MODULE_PATH` accordingly.
To configure the integration of qpc you can provide information either with cmake variables or via environment variables of the very same names.
* Mandatory variables (only one of the two must be set)
-`QPC_SDK_PATH` - set this variable to point to the full path of an already installed qpc instance.
-`QPC_FETCH_FROM_GIT` - set this variable to ON or TRUE, if no pre-installed qpc directory exists. QPC
will then be downloaded from git automatically. The download URL is pre-defined in `qpc_sdk_import.cmake`
* Optional variables
-`QPC_FETCH_FROM_GIT_PATH` - set this variable to download qpc from git (`QPC_FETCH_FROM_GIT`) into the
specified directory
-`QPC_URL`- set this variable to the URL to download qpc from. This must point to a remote git
repository
### `qpc_sdk_init.cmake`
This file is situated in the root directory of qpc. It performs a pre-initialization of the qpc package and provides the function `qpc_sdk_init`. Call this function from your project's `CMakeLists.txt` file to perform the final integration of qpc into your project. To configure qpc to your projects requirements set these variables before calling `qpc_sdk_init()`
*`QPC_CFG_KERNEL` - STRING: set this variable to the QPC kernel for your project. Valid values are QV, QK or QXK. Default: QV
*`QPC_CFG_PORT` - STRING: set this variable to reflect the target platform of your project. Default: host system. Valid values are:
+ `arm-cm`, `arm-cr` - Arm CortexM or CortexR micro controllers. Tested with GNU cross compiler environments.
+ `freertos`, `esp-idf`, `emb-os`, `threadx`, `uc-os2` - real time OS
+ `msp430`, `pic32` - TI MSP430 or PIC32 micro controllers
1. Set `QPC_SDK_PATH` or `QPC_FETCH_FROM_GIT` either in your `CMakeLists.txt` file or as an environment variable.
2. Optionally set the configuration variable(s)
3. Include `qpc_sdk_import`__before__ defining the cmake `project()`
4. Define the project
5. Define the cmake target (executable or library)
6. Include `qpc_sdk_init.cmake`
7. configure the qpc SDK
8. call `qpc_sdk_init`
9. Add the qpc library to your cmake target:
`target_link_libraries(<target>> PRIVATE qpc)`
Generate and build your cmake project
## Generation and building hints
* Generate with configuration support
The recommendation is to use a multi-configuration cmake generator like `"Ninja Multi-Config"` and set the cmake variable `CMAKE_CONFIGURATION_TYPES` to `"Debug;Release;Spy"`.
Then you can build with `cmake --build <builddirectory> --config=<config>.
* Use `CMakePresets.json`
Define the build configurations for your projects in a presets definitions file.
Refer to the [CMakePresets.json manual](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) for further details.
Then you generate with `cmake --preset=<preset> .` from your project directory. The build then can be started with `cmake --build --preset=<preset>`.
### QPC configurations support
Many `qpc` examples provide 3 build configurations:
*`Debug` - build with debug support and debug symbols. Most optimizations are turned off
*`Release` - build without debug support. Activate optimizations instead
*`Spy` - build like `Debug`. Additionally activate support for `QSpy`.
These configurations are also supported by qpc with cmake. Different possibilities exist to activate those.
With the release of QP/C V8.0.0 the inclusion of `qp_config.h` is mandatory.
The `cmake` build system of qpc addresses this by providing the configuration variable `QPC_CFG_QPCONFIG_H_INCLUDE_PATH`. Set this to the path of your local project's `qp_config.h` and this will automatically be found by the build system. Do this in your main `CMakeLists.txt` file __before__ calling `qpc_sdk_init()`.
You do not need to set this variable, should the qpc default settings be sufficient for your project. In this case the build system uses the `qp_config.h` file, as it can be found in the directory `${QPC_SDK_PATH}/src/ports/config`.