libsp: Add build system files.
- Add opteesp deployment.
This deployment builds libsp as a static library targeting aarch64
SPs running under OP-TEE.
- Add inport and export interfaces for OP TEE-OS.
- Add opteesp environment files.
- Add shared CMake scripts including GCC compiler support.
Change-Id: Ie8643756d45d0d96822fd98c4c37e7264a7378a1
Signed-off-by: Gyorgy Szing <gyorgy.szing@arm.com>
diff --git a/tools/cmake/common/AddComponents.cmake b/tools/cmake/common/AddComponents.cmake
new file mode 100644
index 0000000..07978bb
--- /dev/null
+++ b/tools/cmake/common/AddComponents.cmake
@@ -0,0 +1,60 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#[===[.rst:
+Add build components to the current build.
+------------------------------------------
+
+#]===]
+
+
+#[===[.rst:
+.. cmake:command:: add_components
+
+ .. code:: cmake
+
+ add_components(TARGET <target name> COMPONENTS <list of component directories>)
+
+ INPUTS:
+
+ ``BASE_DIR``
+ If defined components are include relative to this directory. If nor paths must be
+ relative to CMAKE_SOURCE_DIR or be absolute.
+
+ ``TARGET``
+ The name of an already defined target to add components to.
+
+ ``COMPONENTS``
+ List of components relative to :cmake:variable:`CMAKE_SOURCE_DIR`
+
+#]===]
+
+function(add_components)
+ set(options )
+ set(oneValueArgs TARGET BASE_DIR)
+ set(multiValueArgs COMPONENTS)
+ cmake_parse_arguments(MY_PARAMS "${options}" "${oneValueArgs}"
+ "${multiValueArgs}" ${ARGN} )
+
+ if(NOT DEFINED MY_PARAMS_TARGET)
+ message(FATAL_ERROR "add_component: mandatory parameter TARGET not defined!")
+ endif()
+ if(NOT DEFINED MY_PARAMS_COMPONENTS)
+ message(FATAL_ERROR "add_component: mandatory parameter COMPONENTS not defined!")
+ endif()
+ if(DEFINED MY_PARAMS_BASE_DIR AND NOT MY_PARAMS_BASE_DIR MATCHES ".*/$")
+ set(MY_PARAMS_BASE_DIR "${MY_PARAMS_BASE_DIR}/")
+ endif()
+
+ set(TGT ${MY_PARAMS_TARGET} CACHE STRING "")
+ foreach(_comp IN ITEMS ${MY_PARAMS_COMPONENTS})
+ set(_file ${MY_PARAMS_BASE_DIR}${_comp}/component.cmake)
+ include(${_file})
+ set(CMAKE_CONFIGURE_DEPENDS ${_file})
+ endforeach()
+ unset(TGT CACHE)
+endfunction()
diff --git a/tools/cmake/common/ExportLibrary.cmake b/tools/cmake/common/ExportLibrary.cmake
new file mode 100644
index 0000000..670f318
--- /dev/null
+++ b/tools/cmake/common/ExportLibrary.cmake
@@ -0,0 +1,72 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#[===[.rst:
+.. cmake:command:: export_library
+
+ .. code:: cmake
+
+ export_library(TARGET LIB_NAME INTERFACE_FILES)
+
+ INPUTS:
+
+ ``TARGET``
+ The name of an already defined target that corresponds to the library.
+
+ ``LIB_NAME``
+ The name of the library.
+
+ ``INTERFACE_FILES``
+ List of header files to declare the library's public interface.
+
+#]===]
+function(export_library)
+ set(options )
+ set(oneValueArgs TARGET LIB_NAME)
+ set(multiValueArgs INTERFACE_FILES)
+ cmake_parse_arguments(MY_PARAMS "${options}" "${oneValueArgs}"
+ "${multiValueArgs}" ${ARGN} )
+
+ if(NOT DEFINED MY_PARAMS_TARGET)
+ message(FATAL_ERROR "export_library: mandatory parameter TARGET not defined!")
+ endif()
+ if(NOT DEFINED MY_PARAMS_LIB_NAME)
+ message(FATAL_ERROR "export_library: mandatory parameter LIB_NAME not defined!")
+ endif()
+
+ # Set default install location if none specified
+ 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()
+
+ # Specify export name and destinations for install
+ install(
+ TARGETS ${MY_PARAMS_TARGET}
+ EXPORT ${MY_PARAMS_LIB_NAME}_targets
+ ARCHIVE
+ DESTINATION lib
+ LIBRARY
+ DESTINATION lib
+ PUBLIC_HEADER
+ DESTINATION include
+ )
+
+ # Install library header files files
+ install(
+ FILES ${MY_PARAMS_INTERFACE_FILES}
+ DESTINATION include
+ )
+
+ # Install the export details
+ install(
+ EXPORT ${MY_PARAMS_LIB_NAME}_targets
+ FILE ${MY_PARAMS_LIB_NAME}_targets.cmake
+ NAMESPACE ${MY_PARAMS_LIB_NAME}::
+ DESTINATION lib/cmake
+ COMPONENT ${MY_PARAMS_LIB_NAME}
+ )
+endfunction()
diff --git a/tools/cmake/common/Utils.cmake b/tools/cmake/common/Utils.cmake
new file mode 100644
index 0000000..c889320
--- /dev/null
+++ b/tools/cmake/common/Utils.cmake
@@ -0,0 +1,51 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#[===[.rst:
+Misc utilities
+--------------
+#]===]
+
+include_guard(DIRECTORY)
+
+#[===[.rst:
+.. cmake:command:: check_args
+
+ .. code-block:: cmake
+
+ check_args(func_name REQ_ARG1 REQ_ARG2)
+
+ Helper macro for argument checking in functions. First argument *func_name* is
+ the name of the function, other arguments are the names of the required
+ arguments to that function. The macro iterates through the list, and prints
+ and error message if not all arguments are defined.
+
+#]===]
+macro(check_args)
+ set(_argv "${ARGV}")
+ list(SUBLIST _argv 0 1 _func)
+ list(SUBLIST _argv 1 -1 _args)
+ foreach(_arg IN LISTS _args)
+ if (NOT DEFINED _MY_PARAMS_${_arg})
+ message(FATAL_ERROR "${_func}(): mandatory parameter '${_arg}' missing.")
+ endif()
+ endforeach()
+endmacro()
+
+# Verify MSYS environment.
+function(ts_verify_build_env)
+ if (WIN32)
+ #On MSYS2 64 bit builds do not work. Verify environment.
+ execute_process(COMMAND uname -s
+ OUTPUT_VARIABLE _os_name)
+ #If uname is present we assume MSYS environment and the os name must
+ #contain MING32.
+ if(_os_name STREQUAL "" AND NOT _os_name MATCHES ".*MINGW32.*")
+ message(FATAL_ERROR "This seems to be a 64 bit MINGW shell, which has issues. Please run the 32bit version.")
+ endif()
+ endif()
+endFunction()