Build: Enable linking with PSA FF compliance tests in NS and S ELF

This change modifies the build system to support linking
the PSA FF compliance test static libraries at secure and
non-secure side both.

Signed-off-by: Jaykumar Pitambarbhai Patel <jaykumar.pitambarbhaipatel@arm.com>
Change-Id: I5ba925752afbe9f5a15f8df4ae12e44e712435a9
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 7550ae3..c34ee5a 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -324,6 +324,15 @@
 	if (NOT DEFINED PSA_API_TEST_ATTESTATION)
 		set(PSA_API_TEST_ATTESTATION OFF)
 	endif()
+	if (NOT DEFINED PSA_API_TEST_IPC)
+		set(PSA_API_TEST_IPC OFF)
+	endif()
+
+	#Set PSA API compliance test build path
+	if(NOT DEFINED PSA_API_TEST_BUILD_PATH)
+		#If not specified, assume it's the default build folder checked out at the same level of TFM root dir
+		set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD")
+	endif()
 endif()
 
 # The config for enable secure context management in TF-M
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index a9723f6..6decb14 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -275,10 +275,6 @@
 	target_link_libraries(${EXE_NAME} "${RTX_LIB_PATH}")
 
 	#Add the PSA API compliance test libraries
-	if(NOT DEFINED PSA_API_TEST_BUILD_PATH)
-		#If not specified, assume it's the default build folder checked out at the same level of TFM root dir
-		set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD")
-	endif()
 	if(PSA_API_TEST_NS)
 		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/val/val_nspe.a")
 		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/platform/pal_nspe.a")
@@ -295,6 +291,9 @@
 	if(PSA_API_TEST_NS AND PSA_API_TEST_ATTESTATION)
 		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/initial_attestation/test_combine.a")
 	endif()
+	if(PSA_API_TEST_NS AND PSA_API_TEST_IPC)
+		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/ff/ipc/test_combine.a")
+	endif()
 
 	if(NOT DEFINED PLATFORM_LINK_INCLUDES)
 		message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index 73a14da..d3da2ab 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -262,6 +262,15 @@
 		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_PLATFORM")
 	endif()
 
+	#Add the PSA API compliance test secure libraries
+	if(PSA_API_TEST_IPC)
+		add_definitions(-DPSA_API_TEST_IPC)
+		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/partition/client_partition.a")
+		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/partition/server_partition.a")
+		target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/partition/driver_partition.a")
+		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "PSA_API_TEST_IPC")
+	endif()
+
 	target_link_libraries(${EXE_NAME} libtfmsprt)
 
 	embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_LVL=${TFM_LVL}")