sdk-ng
sdk-ng copied to clipboard
Improve Zephyr SDK CMake with Zephyr.
Initial relocation of Zephyr CMAke toolchain code moved the CMake code into cmake/zephyr/generic.cmake and cmake/zephyr/target.cmake into Zephyr SDK here:
https://github.com/zephyrproject-rtos/sdk-ng/tree/main/cmake/zephyr
and then Zephyr loads this code here: https://github.com/zephyrproject-rtos/zephyr/blob/c764c3423231ad42ec19e07f654517044a40ebfd/cmake/toolchain/zephyr/generic.cmake#L3 https://github.com/zephyrproject-rtos/zephyr/blob/c764c3423231ad42ec19e07f654517044a40ebfd/cmake/toolchain/zephyr/target.cmake#L3
this gives a hard coupling between the Zephyr SDK internal file structure layout and Zephyr itself, as well as making it harder to re-use portion of the Zephyr SDK, such as looking up tools from Zephyr SDK, without the desire for using the Zephyr SDK compiler. For extra details, see: https://github.com/zephyrproject-rtos/zephyr/pull/58329
Proposed improvement:
Update Zephyr SDK to provide functions, alternative specific set of ZEPHYR_SDK_-prefixed variables which caller (Zephyr build system) can then use to set internal toolchain variables.
This will provide a cleaner API which can be propoerly documented.
For backwards compatibility, Zephyr SDK can still provide generic.cmake and target.cmake which will map the new infrastructure to old style for older Zephyr SDK releases. (LTS releases is considered the important once)
Also, Zephyr SDK should not overwrite ZEPHYR_TOOLCHAIN_VARIANT in case it's already defined, as that makes re+use of Zephyr SDK provided tools harder to reuse with another compiler, ref: https://github.com/zephyrproject-rtos/zephyr/pull/58329#discussion_r1219233951