Build: Move psa_ns_api build to NS side

Move NS interface source code build to NS side.
NS interface build should be executed during NS build.

Change-Id: I7ac3bbf1a9e975d8a9e2f4fb5cd6f367ff94cc9d
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 3deee99..8d9fe3f 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -19,12 +19,6 @@
 set(EXPORT_INC_DIR    ${CMAKE_BINARY_DIR}/install/export/tfm/include)
 set(EXPORT_SRC_DIR    ${CMAKE_BINARY_DIR}/install/export/tfm/src)
 
-# export NS static lib
-install(TARGETS psa_api_ns
-        ARCHIVE
-        DESTINATION ${CMAKE_BINARY_DIR}/install/export/tfm/lib
-)
-
 # export veneer lib
 if (NOT TFM_MULTI_CORE_TOPOLOGY)
     install(FILES       ${CMAKE_BINARY_DIR}/secure_fw/s_veneers.o
diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt
index 0f7540b..3af7daa 100644
--- a/interface/CMakeLists.txt
+++ b/interface/CMakeLists.txt
@@ -51,6 +51,17 @@
         $<$<BOOL:${FORWARD_PROT_MSG}>:FORWARD_PROT_MSG=${FORWARD_PROT_MSG}>
 )
 
+# A dummy interface library to make sure platform NS build can proceed when NS
+# is disabled, if a platform doesn't use NS flag to control platform NS build.
+if (NOT NS)
+    add_library(tfm_ns_interface INTERFACE)
+
+    target_link_libraries(tfm_ns_interface
+        INTERFACE
+            psa_interface
+    )
+endif()
+
 ###################### PSA api (S lib) #########################################
 
 target_sources(tfm_secure_api
@@ -60,62 +71,3 @@
         $<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/src/psa/psa_lifecycle.c>
         ${CMAKE_CURRENT_SOURCE_DIR}/src/log/tfm_log_raw.c
 )
-
-###################### PSA api (NS lib) ########################################
-
-add_library(psa_api_ns STATIC)
-
-target_sources(psa_api_ns
-    PRIVATE
-        $<$<BOOL:${TFM_NS_CLIENT_IDENTIFICATION}>:src/tfm_nspm_svc_handler.c>
-        $<$<BOOL:${TFM_NS_CLIENT_IDENTIFICATION}>:src/tfm_nspm_api.c>
-)
-
-if (${TFM_PSA_API})
-    target_sources(psa_api_ns PRIVATE
-        $<$<OR:$<BOOL:{$FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PLATFORM}>>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_platform_ipc_api.c>
-        $<$<OR:$<BOOL:{$FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_ps_ipc_api.c>
-        $<$<OR:$<BOOL:{$FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_its_ipc_api.c>
-        $<$<OR:$<BOOL:{$FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_CRYPTO}>>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_crypto_ipc_api.c>
-        $<$<OR:$<BOOL:{$FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_initial_attestation_ipc_api.c>
-    )
-
-    if (TFM_MULTI_CORE_TOPOLOGY)
-        target_sources(psa_api_ns PRIVATE
-            src/tfm_ns_mailbox.c
-            src/tfm_multi_core_api.c
-            src/tfm_multi_core_psa_ns_api.c
-        )
-    else()
-        target_sources(psa_api_ns PRIVATE
-           src/tfm_ns_interface.c
-           src/tfm_psa_ns_api.c
-        )
-    endif()
-else()
-    target_sources(psa_api_ns PRIVATE
-        $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_platform_func_api.c>
-        $<$<BOOL:${TFM_PARTITION_AUDIT_LOG}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_audit_func_api.c>
-        $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_ps_func_api.c>
-        $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_its_func_api.c>
-        $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_crypto_func_api.c>
-        $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_initial_attestation_func_api.c>
-        src/tfm_psa_ns_api.c
-    )
-    if (NOT TFM_MULTI_CORE_TOPOLOGY)
-        target_sources(psa_api_ns PRIVATE
-           src/tfm_ns_interface.c
-        )
-    endif()
-
-endif()
-
-target_link_libraries(psa_api_ns
-    PUBLIC
-        psa_interface
-    PRIVATE
-        platform_ns
-        # CMSIS is currently only required to provide the NS client IDs. In
-        # future, this should probably be made more OS agnostic
-        $<$<BOOL:${TFM_NS_CLIENT_IDENTIFICATION}>:CMSIS_5_tfm_ns>
-)
diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt
index 5009520..f7fd6ef 100755
--- a/platform/CMakeLists.txt
+++ b/platform/CMakeLists.txt
@@ -88,7 +88,7 @@
 target_link_libraries(platform_ns
     PUBLIC
         platform_region_defs
-        psa_interface
+        tfm_ns_interface
 )
 
 target_compile_definitions(platform_ns
diff --git a/platform/ext/target/cypress/psoc64/CMakeLists.txt b/platform/ext/target/cypress/psoc64/CMakeLists.txt
index 03fbb67..a3dd3b7 100644
--- a/platform/ext/target/cypress/psoc64/CMakeLists.txt
+++ b/platform/ext/target/cypress/psoc64/CMakeLists.txt
@@ -204,14 +204,14 @@
 
 # device_cfg.h defines the number of mailbox queue slots to support multiple
 # PSA client calls feature.
-target_include_directories(psa_interface
+target_include_directories(tfm_ns_interface
     INTERFACE
         Device/Config
 )
 
 target_link_libraries(platform_ns
     PRIVATE
-        psa_interface
+        tfm_ns_interface
 )
 
 ########################### export sources #####################################