Build: Support passing absolute paths to TFM_PLATFORM

For convenience when using out-of-tree platforms.

Change-Id: I6783eabe9e13c0bdc2412cebd1ff25277cd5dda0
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 735586c..fc9605e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,13 @@
 
 ############################ CONFIGURATION #####################################
 
+if (IS_ABSOLUTE "${TFM_PLATFORM}")
+    file(RELATIVE_PATH TFM_PLATFORM_RELATIVE_PATH
+        "${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target"
+        ${TFM_PLATFORM})
+    set(TFM_PLATFORM "${TFM_PLATFORM_RELATIVE_PATH}" CACHE STRING "Target platform set as an absolute path." FORCE)
+endif()
+
 # Some compiler flags depend on the CPU / platform config. This include should
 # be run before the toolchain file so the compiler can be configured properly.
 if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)