Revert "Build: fetch_remote_library function to fetch remote libraries."

This reverts commit 2e5af6eb005b6c4e9544bc72e8f4200fbc5651a1.

Reason for revert: git apply logic breaks incremental build.

Change-Id: Iee63ab12f78d76f4f0d21e95d017d7cc6c49d5bb
diff --git a/lib/ext/tf-m-tests/fetch_repo.cmake b/lib/ext/tf-m-tests/fetch_repo.cmake
index a2a12bd..593ff1d 100644
--- a/lib/ext/tf-m-tests/fetch_repo.cmake
+++ b/lib/ext/tf-m-tests/fetch_repo.cmake
@@ -1,12 +1,15 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2020-2022, Arm Limited. All rights reserved.
-# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
-# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
 #-------------------------------------------------------------------------------
 
+# Set to not download submodules if that option is available
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
+    cmake_policy(SET CMP0097 NEW)
+endif()
+
 # If NS app, secure regression test or non-secure regression test is enabled,
 # fetch tf-m-tests repo.
 # The conditiions are actually overlapped but it can make the logic more clear.
@@ -16,15 +19,24 @@
     # Set tf-m-tests repo config
     include(${CMAKE_SOURCE_DIR}/lib/ext/tf-m-tests/repo_config_default.cmake)
 
-    fetch_remote_library(
-        LIB_NAME                tfm_test_repo
-        LIB_SOURCE_PATH_VAR     TFM_TEST_REPO_PATH
-        LIB_BASE_DIR            "${CMAKE_BINARY_DIR}/lib/ext"
-        FETCH_CONTENT_ARGS
-            GIT_REPOSITORY      https://git.trustedfirmware.org/TF-M/tf-m-tests.git
-            GIT_TAG             ${TFM_TEST_REPO_VERSION}
+    include(FetchContent)
+    set(FETCHCONTENT_QUIET FALSE)
+
+    set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/lib/ext CACHE STRING "" FORCE)
+
+    if ("${TFM_TEST_REPO_PATH}" STREQUAL "DOWNLOAD")
+        FetchContent_Declare(tfm_test_repo
+            GIT_REPOSITORY https://git.trustedfirmware.org/TF-M/tf-m-tests.git
+            GIT_TAG ${TFM_TEST_REPO_VERSION}
             GIT_PROGRESS TRUE
-    )
+        )
+
+        FetchContent_GetProperties(tfm_test_repo)
+        if(NOT tfm_test_repo_POPULATED)
+            FetchContent_Populate(tfm_test_repo)
+            set(TFM_TEST_REPO_PATH ${tfm_test_repo_SOURCE_DIR} CACHE PATH "Path to TFM-TEST repo (or DOWNLOAD to fetch automatically" FORCE)
+        endif()
+    endif()
 
     if ("${CMSIS_5_PATH}" STREQUAL DOWNLOAD)
         set(CMSIS_5_PATH ${TFM_TEST_REPO_PATH}/CMSIS CACHE PATH "Path to CMSIS_5 (or DOWNLOAD to fetch automatically" FORCE)