I am working in a monorepo that utilizes an RTOS for multiple embedded targets. This RTOS project does not use CMake as its build system, so I am providing the integration into CMake. To build a firmware binary, the RTOS sources need to be linked with the application sources to form a single executable.
The challenge I have run into is related to operating within in a monorepo: If I configure the CMake support for this RTOS to use targets, I will not be able to configure the RTOS project multiple times without triggering duplicate target errors (assuming I don’t configure target names using some sort of user-provided namespace).
My first thought is to add a “namespace” component to the target configuration, e.g.
<NS> is, for example, the value of
PROJECT_NAME (though it could also be user-provided). The downside of this is some possible confusion in the
target_link_library call that consumes the library as it would include a namespace provided by the project.
My use case does seem a bit uncommon - needing to configure a set of sources to be built with a project + building multiple of these projects in a monorepo - but I am curious what approaches others would take?