Modify external dependencies to use LazyFetch
Refactor external dependencies use the new module. This gives more
control over how external components is made available and allows
the environment to use pre-build binaries or pre-fetched content.
Moreover, passing parameters to external CMake build systems is made
more robust by using initial cache files.
Signed-off-by: Benedek Tomasik <benedek.tomasik@arm.com>
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
Change-Id: I85d1990fc7697847307b0ca3a91052b35423d823
diff --git a/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake b/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake
index c815e0d..dbc3e28 100644
--- a/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake
+++ b/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -8,47 +8,39 @@
# Find Linux FF-A user space shim repo location.
# It contains a kernel module which exposes FF-A operations to user space using DebugFS.
-# If a CMake variable exists, use it as is.
-# If not, try to copy the value from the environment.
-# If neither is present, try to download.
-if(NOT DEFINED LINUX_FFA_USER_SHIM_DIR)
- if(DEFINED ENV{LINUX_FFA_USER_SHIM_DIR})
- set(LINUX_FFA_USER_SHIM_DIR $ENV{LINUX_FFA_USER_SHIM_DIR}
- CACHE STRING "Linux FF-A user space shim dir")
- else()
- set(LINUX_FFA_USER_SHIM_URL "https://git.gitlab.arm.com/linux-arm/linux-trusted-services.git"
- CACHE STRING "Linux FF-A user space shim repository URL")
- set(LINUX_FFA_USER_SHIM_REFSPEC "v4.0.0"
- CACHE STRING "Linux FF-A user space shim git refspec")
- find_program(GIT_COMMAND "git")
- if (NOT GIT_COMMAND)
- message(FATAL_ERROR "Please install git")
- endif()
+set(LINUX_FFA_USER_SHIM_URL "https://git.gitlab.arm.com/linux-arm/linux-trusted-services.git"
+ CACHE STRING "Linux FF-A user space shim repository URL")
+set(LINUX_FFA_USER_SHIM_REFSPEC "v4.0.0"
+ CACHE STRING "Linux FF-A user space shim git refspec")
- include(FetchContent)
- FetchContent_Declare(linux_ffa_user_shim
- GIT_REPOSITORY ${LINUX_FFA_USER_SHIM_URL}
- GIT_TAG ${LINUX_FFA_USER_SHIM_REFSPEC}
- GIT_SHALLOW TRUE
- )
+set(LINUX_FFA_USER_SHIM_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/linux_ffa_user_shim-src"
+ CACHE PATH "Location of Linux driver source.")
- # FetchContent_GetProperties exports <name>_SOURCE_DIR and <name>_BINARY_DIR variables
- FetchContent_GetProperties(linux_ffa_user_shim)
- if(NOT linux_ffa_user_shim_POPULATED)
- message(STATUS "Fetching Linux FF-A user space shim")
- FetchContent_Populate(linux_ffa_user_shim)
- endif()
-
- set(LINUX_FFA_USER_SHIM_DIR ${linux_ffa_user_shim_SOURCE_DIR}
- CACHE STRING "Linux FF-A user space shim dir")
- endif()
+if (DEFINED ENV{LINUX_FFA_USER_SHIM_SOURCE_DIR})
+ set(LINUX_FFA_USER_SHIM_SOURCE_DIR $ENV{LINUX_FFA_USER_SHIM_SOURCE_DIR}
+ CACHE PATH "Location of Linux driver source." FORCE)
endif()
+set(GIT_OPTIONS
+ GIT_REPOSITORY ${LINUX_FFA_USER_SHIM_URL}
+ GIT_TAG ${LINUX_FFA_USER_SHIM_REFSPEC}
+ GIT_SHALLOW TRUE
+ )
+ include(${TS_ROOT}/tools/cmake/common/LazyFetch.cmake REQUIRED)
+ LazyFetch_MakeAvailable(
+ DEP_NAME linux_ffa_user_shim
+ FETCH_OPTIONS "${GIT_OPTIONS}"
+ SOURCE_DIR ${LINUX_FFA_USER_SHIM_SOURCE_DIR}
+ )
+
find_path(LINUX_FFA_USER_SHIM_INCLUDE_DIR
NAMES arm_ffa_user.h
- PATHS ${LINUX_FFA_USER_SHIM_DIR}
+ PATHS ${LINUX_FFA_USER_SHIM_SOURCE_DIR}
NO_DEFAULT_PATH
REQUIRED
DOC "Linux FF-A user space shim include directory"
)
+
+set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
+ "${LINUX_FFA_USER_SHIM_INCLUDE_DIR}/arm_ffa_user.h")