Arm Mbed OS support forum

Mbed cli 2: adding new library

I am trying to add code as new library which uses mbed os objects, i.e. it has to include mbed-os.h. I am struggling with how to set up a proper CMakeList.txt in this library so that the lib gets smoothly build along with the application.

Following the (somehow very condensed) mbed cli 2 migration guide I have to

  1. Create a “folder” and “and adding it to git version control”
  2. create a reponame.lib in the application

I interpret item 1. as requirement of 2.: The new library code has to be stored somewhere in a clonable git repository. Item 2. means just referencing to this new git repository.

Questions:

Which changes are now supposed to be done to the CMakeLists.txt of the (a) application and (b) of the new library? I suppose the new library must have a CMakeLists.txt as well, correct?

Is the mbed configure .. supposed to clone the library, i.e. it evaluates the .lib or must the library be connected to the application by git submodules for checking out?

Maybe a stupid general question, but how to inherit the mbed-os and target include paths of the application in the library? Is there a standard way in CMake (I am not a CMake expert…)