Build: Support out-of-tree platforms
Allows -DTFM_PLATFORM to be set to paths outside the TFM tree.
e.g.
cmake ... -DTFM_PLATFORM=../../../../tfm_platforms/my_platform
Note: TFM_PLATFORM currently only accepts paths relative from
platform/ext/target
Change-Id: I99d194fdee43ffa29da67b22eb79ef5e450c1559
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 1fcecc7..3deee99 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -8,9 +8,10 @@
# Generate correct filename
string(TOUPPER ${TFM_PLATFORM} TFM_PLATFORM_UPPERCASE)
string(REGEX REPLACE "-" "_" TFM_PLATFORM_UPPERCASE_UNDERSCORE ${TFM_PLATFORM_UPPERCASE})
+string(REGEX REPLACE "^(\\.\\.([\\/\\\\]))+" "EXTERNAL\\2" TFM_PLATFORM_UPPERCASE_UNDERSCORE_NO_PARENT_DIR ${TFM_PLATFORM_UPPERCASE_UNDERSCORE})
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/
- DESTINATION ${CMAKE_BINARY_DIR}/install/outputs/${TFM_PLATFORM_UPPERCASE_UNDERSCORE}
+ DESTINATION ${CMAKE_BINARY_DIR}/install/outputs/${TFM_PLATFORM_UPPERCASE_UNDERSCORE_NO_PARENT_DIR}
)
set(INTERFACE_INC_DIR ${CMAKE_SOURCE_DIR}/interface/include)
diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt
index b03c88e..915307c 100755
--- a/platform/CMakeLists.txt
+++ b/platform/CMakeLists.txt
@@ -23,7 +23,7 @@
set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
-add_subdirectory(ext/target/${TFM_PLATFORM})
+add_subdirectory(ext/target/${TFM_PLATFORM} target)
#========================= Platform Secure ====================================#
diff --git a/platform/ext/target/musca_b1/sse_200/CMakeLists.txt b/platform/ext/target/musca_b1/sse_200/CMakeLists.txt
index 8fac077..d65748f 100644
--- a/platform/ext/target/musca_b1/sse_200/CMakeLists.txt
+++ b/platform/ext/target/musca_b1/sse_200/CMakeLists.txt
@@ -187,7 +187,7 @@
Device/Config
Native_Driver
${MCUBOOT_PATH}/boot/bootutil/include # for fault_injection_hardening.h only
- ${CMAKE_CURRENT_BINARY_DIR}/../../../../../bl2/ext/mcuboot # for mcuboot_config.h only
+ ${CMAKE_BINARY_DIR}/bl2/ext/mcuboot # for mcuboot_config.h only
${CMAKE_MUSCA_B1_COMMON_DIR}/Native_Driver
${CMAKE_MUSCA_B1_COMMON_DIR}/Libraries
)
diff --git a/platform/ext/target/musca_s1/CMakeLists.txt b/platform/ext/target/musca_s1/CMakeLists.txt
index 536b12a..6180be2 100644
--- a/platform/ext/target/musca_s1/CMakeLists.txt
+++ b/platform/ext/target/musca_s1/CMakeLists.txt
@@ -148,6 +148,6 @@
Device/Config
Native_Driver
${MCUBOOT_PATH}/boot/bootutil/include # for fault_injection_hardening.h only
- ${CMAKE_CURRENT_BINARY_DIR}/../../../../bl2/ext/mcuboot # for mcuboot_config.h only
+ ${CMAKE_BINARY_DIR}/bl2/ext/mcuboot # for mcuboot_config.h only
)
endif()