MBED_CONF_RTOS_PRESENT is defined in mbed-rtos-flags. For libraries which need to distinguish between mbed-os or mbed-bardmetal build, e.g. ESP8266Interface.h, they need to determine to link mbed-rtos-flags to get in MBED_CONF_RTOS_PRESENT (for linking mbed-os) or not (for linking mbed-baremetal). But only application-level CMakeLists.txt knows which of mbed-os and mbed-baremetal is linked, and this information isn't passed to these libraries which rely on MBED_CONF_RTOS_PRESENT. This will generate such error: application linking mbed-baremetal but libraries having MBED_CONF_RTOS_PRESENT definedㄝor conversely.
One rough fix is these libraries all link mbed-core-flags and let application-level CMakeLists.txt determine to link mbed-rtos-flags additionally for these libraries. But this fix isn't compatible and isn't easy to apply.