-
Notifications
You must be signed in to change notification settings - Fork 23
MbedOS configuration
Is good for...
//TODO
(Note: Legacy Mbed configs have a .json extension. Mbed CE moved to .json5 mainly for comment support)
In top level CMakeLists.txt there has to be the line
target_link_libraries(YourApplication mbed-os)
via this line you can switch between full profile mbed-os
to mbed-baremetal
profile or add components what are not part of that profile in default.
For example USB is component what is not included in full MbedOS profile so you have to add it like this
target_link_libraries(YourApplication mbed-os mbed-usb)
Another example is block devices. These were split out from the main Mbed library, and have to be linked separately. For example, if you need FlashIAPBlockDevice.h, you have to link mbed-storage-flashiap
, like this:
target_link_libraries(YourApplication mbed-os mbed-storage-flashiap)
If you need to make a library within your own code, you can use CMake's add_library() command. This library can then be linked to multiple different applications, and the code inside only gets compiled once.
Example:
add_library(SomeLibrary STATIC LibSource1.cpp LibSource2.cpp)
target_link_libraries(SomeLibrary PUBLIC mbed-core-flags) # This is needed so that the library can access Mbed includes
add_executable(MyMbedOSExe)
target_link_libraries(MyMbedOSExe SomeLibrary mbed-os)
mbed_set_post_build(MyMbedOSExe)
add_executable(MyMbedBaremetalExe)
target_link_libraries(MyMbedOSExe SomeLibrary mbed-baremetal)
mbed_set_post_build(MyMbedOSExe)
Note that the library is linked to mbed-core-flags
, not mbed-os
. This is a limitation of CMake object libraries; only the executable should be linked to mbed-os
, NOT the libraries. Note that if the library needs to use RTOS features, it should like to mbed-rtos-flags
as well to get access to the RTOS.
mbed-usb
(can be also manually enabled in baremetal profile)
mbed-netsocket
mbed-storage
(can be also manually enabled in baremetal profile)
mbed-mbedtls
//TODO