Migrate Mbed TLS to use LazyFetch

In Mbed TLS 3.2 the necessary functionality was implemented to support
adding Mbed TLS as a CMake package. This makes it possible to use the
FetchContent feature of CMake (and in turn the LazyFetch module of TS)
to download and build Mbed TLS. All of the other external CMake projects
in TS already use the LazyFetch module, which reduces code duplication
by introducing functions that encapsulate the standard "fetch, patch,
configure, build" steps that are necessary for building CMake projects.

This commit replaces the existing Mbed TLS build procedure to use
LazyFetch instead. It also moves the config options of Mbed TLS from
command line arguments in the MbedTLS.cmake file into a dedicated config
file (or in CMake terminology, an "initial CMake cache" file).

Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: I0aa32f0f847abc3045db4031fefd2cd4e4b684e7
diff --git a/deployments/component-test/component-test.cmake b/deployments/component-test/component-test.cmake
index f8ffe9f..e80b766 100644
--- a/deployments/component-test/component-test.cmake
+++ b/deployments/component-test/component-test.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -199,7 +199,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(component-test PRIVATE mbedcrypto)
+target_link_libraries(component-test PRIVATE MbedTLS::mbedcrypto)
 
 # Qcbor
 include(${TS_ROOT}/external/qcbor/qcbor.cmake)
diff --git a/deployments/crypto/crypto.cmake b/deployments/crypto/crypto.cmake
index 9ca26cd..5b7b58e 100644
--- a/deployments/crypto/crypto.cmake
+++ b/deployments/crypto/crypto.cmake
@@ -46,7 +46,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(crypto PRIVATE mbedcrypto)
+target_link_libraries(crypto PRIVATE MbedTLS::mbedcrypto)
 
 #################################################################
 
diff --git a/deployments/env-test/suites/baremetal-tests.cmake b/deployments/env-test/suites/baremetal-tests.cmake
index 6baf1f6..325e238 100644
--- a/deployments/env-test/suites/baremetal-tests.cmake
+++ b/deployments/env-test/suites/baremetal-tests.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -39,7 +39,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(env-test PRIVATE mbedcrypto)
+target_link_libraries(env-test PRIVATE MbedTLS::mbedcrypto)
 
 #-------------------------------------------------------------------------------
 #  This test suite depends on platform specific drivers
diff --git a/deployments/libts/linux-pc/CMakeLists.txt b/deployments/libts/linux-pc/CMakeLists.txt
index ecc72ef..515fd71 100644
--- a/deployments/libts/linux-pc/CMakeLists.txt
+++ b/deployments/libts/linux-pc/CMakeLists.txt
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -153,7 +153,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(ts PRIVATE mbedcrypto)
+target_link_libraries(ts PRIVATE MbedTLS::mbedcrypto)
 
 # Qcbor
 include(${TS_ROOT}/external/qcbor/qcbor.cmake)
@@ -212,4 +212,4 @@
 protobuf_generate_all(TGT "libts-test" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
 
 # Mbedcrypto
-target_link_libraries(libts-test PRIVATE mbedcrypto)
+target_link_libraries(libts-test PRIVATE MbedTLS::mbedcrypto)
diff --git a/deployments/platform-inspect/platform-inspect.cmake b/deployments/platform-inspect/platform-inspect.cmake
index 01328b6..77d441a 100644
--- a/deployments/platform-inspect/platform-inspect.cmake
+++ b/deployments/platform-inspect/platform-inspect.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -50,7 +50,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(../../../external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(platform-inspect PRIVATE mbedcrypto)
+target_link_libraries(platform-inspect PRIVATE MbedTLS::mbedcrypto)
 
 # Qcbor
 include(${TS_ROOT}/external/qcbor/qcbor.cmake)
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 1d2c515..0d8c5ac 100644
--- a/deployments/psa-api-test/initial_attestation/iat-api-test.cmake
+++ b/deployments/psa-api-test/initial_attestation/iat-api-test.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -53,7 +53,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(${PROJECT_NAME} PRIVATE mbedcrypto)
+target_link_libraries(${PROJECT_NAME} PRIVATE MbedTLS::mbedcrypto)
 
 #-------------------------------------------------------------------------------
 #  Advertise PSA API include paths to PSA Arch tests
diff --git a/deployments/ts-demo/ts-demo.cmake b/deployments/ts-demo/ts-demo.cmake
index 9fd8585..f276ca1 100644
--- a/deployments/ts-demo/ts-demo.cmake
+++ b/deployments/ts-demo/ts-demo.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -52,7 +52,7 @@
 
 # Mbed TLS provides libmbedcrypto
 include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(ts-demo PRIVATE mbedcrypto)
+target_link_libraries(ts-demo PRIVATE MbedTLS::mbedcrypto)
 
 #-------------------------------------------------------------------------------
 #  Define install content.