blob: f05b12aeff2e87820ca14ed6bb84862f381018f4 [file] [log] [blame]
Gyorgy Szing49091802020-11-24 00:33:09 +01001#-------------------------------------------------------------------------------
Imre Kiseeee9642021-12-17 13:59:46 +01002# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
Gyorgy Szing49091802020-11-24 00:33:09 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Gyorgy Szingb8d6f262023-06-05 12:36:02 +02008# Check mandatory variables.
9foreach(_var IN ITEMS TGT)
10 if (NOT DEFINED ${_var})
11 message(FATAL_ERROR "Mandatory parameter '${_var}' missing.")
12 endif()
13endforeach()
14
Gyorgy Szing3e3db702023-07-21 14:18:19 +020015# Ensure elf output naming is symbolize.py compatible.
16# If binary UUID is not defined, fall back to using the SP UUID value.
17if (NOT SP_BIN_UUID_CANON)
18 set(SP_BIN_UUID_CANON "${SP_UUID_CANON}")
19endif()
20ts_add_uuid_to_exe_name(TGT "${TGT}" UUID "${SP_BIN_UUID_CANON}" )
Gyorgy Szing49091802020-11-24 00:33:09 +010021
Gyorgy Szing6a0d9922023-07-20 14:55:42 +020022get_target_property(_tgt_type ${TGT} TYPE)
23if ("${_tgt_type}" STREQUAL "EXECUTABLE")
24 compiler_generate_stripped_elf(TARGET ${TGT} NAME "${SP_BIN_UUID_CANON}.stripped.elf" RES STRIPPED_ELF)
25 install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin)
26endif()
27
Gyorgy Szing49091802020-11-24 00:33:09 +010028target_sources(${TGT} PRIVATE
Imre Kise6d73412021-10-18 14:01:47 +020029 "${CMAKE_CURRENT_LIST_DIR}/optee_sp_header.c"
Imre Kisef5c2642021-12-17 14:07:35 +010030 "${CMAKE_CURRENT_LIST_DIR}/sp_assert.c"
Imre Kise6d73412021-10-18 14:01:47 +020031 "${CMAKE_CURRENT_LIST_DIR}/sp_entry.c"
Imre Kis2ccd8e82021-10-08 11:21:14 +020032 "${CMAKE_CURRENT_LIST_DIR}/sp_trace.c"
Imre Kise6d73412021-10-18 14:01:47 +020033)
Andrew Beggs97a00d42021-06-15 15:45:46 +000034
35target_include_directories(${TGT}
Imre Kis2ccd8e82021-10-08 11:21:14 +020036 PUBLIC
37 "${CMAKE_CURRENT_LIST_DIR}/include"
38 )
39
Imre Kise6d73412021-10-18 14:01:47 +020040# Default trace configuration, can be overwritten by setting the same variables
41# in the deployment specific file before including this file.
42set(TRACE_PREFIX "SP" CACHE STRING "Trace prefix")
43set(TRACE_LEVEL "TRACE_LEVEL_ERROR" CACHE STRING "Trace level")
Imre Kis2ccd8e82021-10-08 11:21:14 +020044
Imre Kiseeee9642021-12-17 13:59:46 +010045if (NOT DEFINED SP_HEAP_SIZE)
46 message(FATAL_ERROR "SP_HEAP_SIZE is not defined")
47endif()
48
Imre Kis2ccd8e82021-10-08 11:21:14 +020049target_compile_definitions(${TGT} PRIVATE
50 TRACE_LEVEL=${TRACE_LEVEL}
51 TRACE_PREFIX="${TRACE_PREFIX}"
Imre Kiseeee9642021-12-17 13:59:46 +010052 SP_HEAP_SIZE=${SP_HEAP_SIZE}
Imre Kis2ccd8e82021-10-08 11:21:14 +020053)
Imre Kise6d73412021-10-18 14:01:47 +020054
Julian Hall8ad60432022-08-15 14:11:47 +010055include(${TS_ROOT}/external/newlib/newlib.cmake)
Imre Kise6d73412021-10-18 14:01:47 +020056
57target_link_libraries(${TGT} PRIVATE
Gyorgy Szing693877e2021-12-12 02:51:10 +010058 stdlib::c
Imre Kise6d73412021-10-18 14:01:47 +020059)
60
61target_link_options(${TGT} PRIVATE
62 -Wl,--hash-style=sysv
63 -Wl,--as-needed
64 -Wl,--gc-sections
65)
66
67compiler_set_linker_script(TARGET ${TGT} FILE ${CMAKE_CURRENT_LIST_DIR}/sp.ld.S DEF ARM64=1)