mbed: Add CMake support and fix files paths

The mbed port should be compatible with a new command-line tool
mbed-tools (Mbed CLI 2) which use cmake build system. This allows build
cmake-base applications.
Fix mbed files paths - it's required for the new version of mbed-os
(v6.15)

Signed-off-by: Artur Tynecki <artur.tynecki@mobica.com>
diff --git a/boot/mbed/CMakeLists.txt b/boot/mbed/CMakeLists.txt
new file mode 100644
index 0000000..8baa262
--- /dev/null
+++ b/boot/mbed/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Copyright (c) 2021 ARM Limited. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+# Mbed-MCUboot Port
+
+cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
+
+get_filename_component(BOOT_UTIL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../bootutil REALPATH)
+
+set(LIB_TARGET mbed-mcuboot)
+set(LIB_BOOTUTIL bootutil)
+
+add_library(${LIB_TARGET} STATIC)
+
+target_include_directories(${LIB_TARGET}
+    PUBLIC
+        include
+        ${BOOT_UTIL_DIR}/include
+        ${BOOT_UTIL_DIR}/src
+)
+
+target_sources(${LIB_TARGET}
+    PRIVATE
+        mcuboot_main.cpp
+        app_enc_keys.c
+        src/flash_map_backend.cpp
+        src/secondary_bd.cpp
+)
+
+target_link_libraries(${LIB_TARGET}
+    PUBLIC
+        bootutil  # Cross-dependency
+        mbed-mbedtls
+        mbed-storage-flashiap
+        mbed-storage-blockdevice
+)
+
+if("_RTE_" IN_LIST MBED_CONFIG_DEFINITIONS)
+    target_link_libraries(${LIB_TARGET}
+    PUBLIC
+        mbed-os
+    )
+else()
+    target_link_libraries(${LIB_TARGET}
+    PUBLIC
+        mbed-baremetal
+    )
+endif()
+
+# The cross-dependency requires that bootutil have access to the mbed port's
+# include directory and is linked with the appropriate mbed-specific libraries.
+target_include_directories(${LIB_BOOTUTIL}
+    PUBLIC
+        include
+)
+
+target_link_libraries(${LIB_BOOTUTIL}
+    PUBLIC
+        mbed-mcuboot
+        mbed-mbedtls
+)
diff --git a/boot/mbed/include/mcuboot_config/mcuboot_logging.h b/boot/mbed/include/mcuboot_config/mcuboot_logging.h
index 8cc92a4..fc5282e 100644
--- a/boot/mbed/include/mcuboot_config/mcuboot_logging.h
+++ b/boot/mbed/include/mcuboot_config/mcuboot_logging.h
@@ -54,7 +54,7 @@
 #endif
 
 #define TRACE_GROUP "MCUb"
-#include "mbed_trace.h"
+#include "mbed-trace/mbed_trace.h"
 #include "bootutil/ignore.h"
 
 #define MCUBOOT_LOG_MODULE_DECLARE(domain)  /* ignore */
diff --git a/boot/mbed/mcuboot_main.cpp b/boot/mbed/mcuboot_main.cpp
index c5f4137..4acb34d 100644
--- a/boot/mbed/mcuboot_main.cpp
+++ b/boot/mbed/mcuboot_main.cpp
@@ -22,7 +22,7 @@
 #include "bootutil/bootutil.h"
 #include "bootutil/image.h"
 #include "hal/serial_api.h"
-#include "mbed_application.h"
+#include "platform/mbed_application.h"
 
 #if (MCUBOOT_CRYPTO_BACKEND == MBEDTLS)
 #include "mbedtls/platform.h"
diff --git a/boot/mbed/src/secondary_bd.cpp b/boot/mbed/src/secondary_bd.cpp
index 40eb4c8..7550a61 100644
--- a/boot/mbed/src/secondary_bd.cpp
+++ b/boot/mbed/src/secondary_bd.cpp
@@ -21,7 +21,7 @@
 
 #include "flash_map_backend/secondary_bd.h"
 #include "platform/mbed_toolchain.h"
-#include "FlashIAPBlockDevice.h"
+#include "FlashIAP/FlashIAPBlockDevice.h"
 
 /**
  * For an XIP build, the secondary BD is provided by mcuboot by default.