Fix: psa-api-test executable names clash

All psa-api-test executables used the same name which resulted in
executables being overwritten when installing to the same location.
As a result, b-test was not running all tests.
This commit changes the CMake project name for psa-arch-test
deployments, and the uses the PROJECT_NAME variable to create and
configure the built executable.

Change-Id: Idd80baf1cf7a9b16ad27b0d94abdb71c3179b169
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
diff --git a/deployments/psa-api-test/crypto/arm-linux/CMakeLists.txt b/deployments/psa-api-test/crypto/arm-linux/CMakeLists.txt
index 40384d6..e97830e 100644
--- a/deployments/psa-api-test/crypto/arm-linux/CMakeLists.txt
+++ b/deployments/psa-api-test/crypto/arm-linux/CMakeLists.txt
@@ -14,9 +14,9 @@
 #  Used for building and running psa arch tests on an Arm based Linux device
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/arm-linux/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-crypto-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/crypto/crypto-api-test.cmake b/deployments/psa-api-test/crypto/crypto-api-test.cmake
index 558d057..9cc97e3 100644
--- a/deployments/psa-api-test/crypto/crypto-api-test.cmake
+++ b/deployments/psa-api-test/crypto/crypto-api-test.cmake
@@ -30,14 +30,14 @@
 #
 #-------------------------------------------------------------------------------
 add_components(
-	TARGET "psa-api-test"
+	TARGET "${PROJECT_NAME}"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
 		"components/service/crypto/include"
 		"components/service/crypto/client/psa"
 )
 
-target_sources(psa-api-test PRIVATE
+target_sources(${PROJECT_NAME} PRIVATE
 	${TS_ROOT}/deployments/psa-api-test/crypto/crypto_locator.c
 )
 
diff --git a/deployments/psa-api-test/crypto/linux-pc/CMakeLists.txt b/deployments/psa-api-test/crypto/linux-pc/CMakeLists.txt
index 884fc3e..e2dd311 100644
--- a/deployments/psa-api-test/crypto/linux-pc/CMakeLists.txt
+++ b/deployments/psa-api-test/crypto/linux-pc/CMakeLists.txt
@@ -13,12 +13,12 @@
 #  linux-pc
 #
 #  Used for building and running psa arch crypto tests in a native PC enviroment.
-#  Tests can be run by running the built executable called "psa-api-test"
+#  Tests can be run by running the built executable called "psa-crypto-api-test"
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/linux-pc/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-crypto-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/initial_attestation/arm-linux/CMakeLists.txt b/deployments/psa-api-test/initial_attestation/arm-linux/CMakeLists.txt
index 183f121..0dc18f2 100644
--- a/deployments/psa-api-test/initial_attestation/arm-linux/CMakeLists.txt
+++ b/deployments/psa-api-test/initial_attestation/arm-linux/CMakeLists.txt
@@ -14,9 +14,9 @@
 #  Used for building and running psa arch tests on an Arm based Linux device
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/arm-linux/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-iat-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
@@ -28,6 +28,6 @@
 #  Linker option to enable repeated searches for undefined references.
 #  Required to resolve dependencies between arch-test and mbedcrypto libraries.
 #-------------------------------------------------------------------------------
-target_link_options(psa-api-test PRIVATE
+target_link_options(${PROJECT_NAME} PRIVATE
 	-Wl,--start-group
 	)
diff --git a/deployments/psa-api-test/initial_attestation/iat-api-test.cmake b/deployments/psa-api-test/initial_attestation/iat-api-test.cmake
index 5486075..1d2c515 100644
--- a/deployments/psa-api-test/initial_attestation/iat-api-test.cmake
+++ b/deployments/psa-api-test/initial_attestation/iat-api-test.cmake
@@ -29,7 +29,7 @@
 #
 #-------------------------------------------------------------------------------
 add_components(
-	TARGET "psa-api-test"
+	TARGET "${PROJECT_NAME}"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
 		"components/service/attestation/include"
@@ -37,7 +37,7 @@
 		"components/service/attestation/client/provision"
 )
 
-target_sources(psa-api-test PRIVATE
+target_sources(${PROJECT_NAME} PRIVATE
 	${TS_ROOT}/deployments/psa-api-test/initial_attestation/iat_locator.c
 )
 
@@ -53,7 +53,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(psa-api-test PRIVATE mbedcrypto)
+target_link_libraries(${PROJECT_NAME} PRIVATE mbedcrypto)
 
 #-------------------------------------------------------------------------------
 #  Advertise PSA API include paths to PSA Arch tests
diff --git a/deployments/psa-api-test/initial_attestation/linux-pc/CMakeLists.txt b/deployments/psa-api-test/initial_attestation/linux-pc/CMakeLists.txt
index 5da59fa..143012f 100644
--- a/deployments/psa-api-test/initial_attestation/linux-pc/CMakeLists.txt
+++ b/deployments/psa-api-test/initial_attestation/linux-pc/CMakeLists.txt
@@ -12,12 +12,12 @@
 #  The CMakeLists.txt for building the psa-api-test deployment for linux-pc
 #
 #  Used for building and running psa arch tests in a native PC enviroment.
-#  Tests can be run by running the built executable called "psa-api-test"
+#  Tests can be run by running the built executable called "psa-iat-api-test".
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/linux-pc/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-iat-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/internal_trusted_storage/arm-linux/CMakeLists.txt b/deployments/psa-api-test/internal_trusted_storage/arm-linux/CMakeLists.txt
index 27e511a..1c2e4ea 100644
--- a/deployments/psa-api-test/internal_trusted_storage/arm-linux/CMakeLists.txt
+++ b/deployments/psa-api-test/internal_trusted_storage/arm-linux/CMakeLists.txt
@@ -14,9 +14,9 @@
 #  Used for building and running psa arch tests on an Arm based Linux device
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/arm-linux/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-its-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/internal_trusted_storage/its-api-test.cmake b/deployments/psa-api-test/internal_trusted_storage/its-api-test.cmake
index ea6f381..b5d7e48 100644
--- a/deployments/psa-api-test/internal_trusted_storage/its-api-test.cmake
+++ b/deployments/psa-api-test/internal_trusted_storage/its-api-test.cmake
@@ -23,7 +23,7 @@
 #
 #-------------------------------------------------------------------------------
 add_components(
-	TARGET "psa-api-test"
+	TARGET "${PROJECT_NAME}"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
 		"components/service/secure_storage/include"
@@ -31,7 +31,7 @@
 		"components/service/secure_storage/backend/secure_storage_client"
 )
 
-target_sources(psa-api-test PRIVATE
+target_sources(${PROJECT_NAME} PRIVATE
 	${TS_ROOT}/deployments/psa-api-test/internal_trusted_storage/its_locator.c
 )
 
diff --git a/deployments/psa-api-test/internal_trusted_storage/linux-pc/CMakeLists.txt b/deployments/psa-api-test/internal_trusted_storage/linux-pc/CMakeLists.txt
index 941d47f..dd350b2 100644
--- a/deployments/psa-api-test/internal_trusted_storage/linux-pc/CMakeLists.txt
+++ b/deployments/psa-api-test/internal_trusted_storage/linux-pc/CMakeLists.txt
@@ -13,12 +13,12 @@
 #  deployment for linux-pc
 #
 #  Used for building and running psa arch tests in a native PC enviroment.
-#  Tests can be run by running the built executable called "psa-api-test"
+#  Tests can be run by running the built executable called "psa-its-api-test".
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/linux-pc/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-its-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/protected_storage/arm-linux/CMakeLists.txt b/deployments/psa-api-test/protected_storage/arm-linux/CMakeLists.txt
index f1dd4a3..5611d50 100644
--- a/deployments/psa-api-test/protected_storage/arm-linux/CMakeLists.txt
+++ b/deployments/psa-api-test/protected_storage/arm-linux/CMakeLists.txt
@@ -14,9 +14,9 @@
 #  Used for building and running psa arch tests on an Arm based Linux device
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/arm-linux/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-ps-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/protected_storage/linux-pc/CMakeLists.txt b/deployments/psa-api-test/protected_storage/linux-pc/CMakeLists.txt
index 7b8756a..482c3e0 100644
--- a/deployments/psa-api-test/protected_storage/linux-pc/CMakeLists.txt
+++ b/deployments/psa-api-test/protected_storage/linux-pc/CMakeLists.txt
@@ -13,12 +13,12 @@
 #  for linux-pc
 #
 #  Used for building and running psa arch tests in a native PC enviroment.
-#  Tests can be run by running the built executable called "psa-api-test"
+#  Tests can be run by running the built executable called "psa-ps-api-test".
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/environments/linux-pc/env.cmake)
-project(trusted-services LANGUAGES CXX C)
-add_executable(psa-api-test)
-target_include_directories(psa-api-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+project(psa-ps-api-test LANGUAGES CXX C)
+add_executable(${PROJECT_NAME})
+target_include_directories(${PROJECT_NAME} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
 #-------------------------------------------------------------------------------
 #  Extend with components that are common across all deployments of
diff --git a/deployments/psa-api-test/protected_storage/ps-api-test.cmake b/deployments/psa-api-test/protected_storage/ps-api-test.cmake
index fae1161..5a733b8 100644
--- a/deployments/psa-api-test/protected_storage/ps-api-test.cmake
+++ b/deployments/psa-api-test/protected_storage/ps-api-test.cmake
@@ -23,7 +23,7 @@
 #
 #-------------------------------------------------------------------------------
 add_components(
-	TARGET "psa-api-test"
+	TARGET "${PROJECT_NAME}"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
 		"components/service/secure_storage/include"
@@ -31,7 +31,7 @@
 		"components/service/secure_storage/backend/secure_storage_client"
 )
 
-target_sources(psa-api-test PRIVATE
+target_sources(${PROJECT_NAME} PRIVATE
 	${TS_ROOT}/deployments/psa-api-test/protected_storage/ps_locator.c
 )
 
diff --git a/deployments/psa-api-test/psa-api-test.cmake b/deployments/psa-api-test/psa-api-test.cmake
index ecb3a9c..d58620f 100644
--- a/deployments/psa-api-test/psa-api-test.cmake
+++ b/deployments/psa-api-test/psa-api-test.cmake
@@ -16,14 +16,14 @@
 #  deployed.
 #-------------------------------------------------------------------------------
 include(${TS_ROOT}/deployments/libts/libts-import.cmake)
-target_link_libraries(psa-api-test PRIVATE libts)
+target_link_libraries(${PROJECT_NAME} PRIVATE libts)
 
 #-------------------------------------------------------------------------------
 #  Components that are common accross all deployments
 #
 #-------------------------------------------------------------------------------
 add_components(
-	TARGET "psa-api-test"
+	TARGET "${PROJECT_NAME}"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
 		"components/common/tlv"
@@ -34,7 +34,7 @@
 		"components/rpc/common/logging"
 )
 
-target_sources(psa-api-test PRIVATE
+target_sources(${PROJECT_NAME} PRIVATE
 	${TS_ROOT}/deployments/psa-api-test/arch_test_runner.c
 )
 
@@ -42,7 +42,7 @@
 #  Export project header paths for arch tests
 #
 #-------------------------------------------------------------------------------
-get_target_property(_include_paths psa-api-test INCLUDE_DIRECTORIES)
+get_target_property(_include_paths ${PROJECT_NAME} INCLUDE_DIRECTORIES)
 list(APPEND PSA_ARCH_TESTS_EXTERNAL_INCLUDE_PATHS ${_include_paths})
 
 #-------------------------------------------------------------------------------
@@ -52,7 +52,7 @@
 
 # psa-arch-tests
 include(${TS_ROOT}/external/psa_arch_tests/psa_arch_tests.cmake)
-target_link_libraries(psa-api-test PRIVATE val_nspe test_combine pal_nspe)
+target_link_libraries(${PROJECT_NAME} PRIVATE val_nspe test_combine pal_nspe)
 
 #-------------------------------------------------------------------------------
 #  Define install content.
@@ -61,4 +61,4 @@
 if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 	set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
 endif()
-install(TARGETS psa-api-test RUNTIME DESTINATION ${TS_ENV}/bin)
+install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${TS_ENV}/bin)