blob: 526d8c84458d24acb139dd1e615e39883e947dde [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
22target_sources(${TGT} PRIVATE
Imre Kise6d73412021-10-18 14:01:47 +020023 "${CMAKE_CURRENT_LIST_DIR}/optee_sp_header.c"
Imre Kisef5c2642021-12-17 14:07:35 +010024 "${CMAKE_CURRENT_LIST_DIR}/sp_assert.c"
Imre Kise6d73412021-10-18 14:01:47 +020025 "${CMAKE_CURRENT_LIST_DIR}/sp_entry.c"
Imre Kis2ccd8e82021-10-08 11:21:14 +020026 "${CMAKE_CURRENT_LIST_DIR}/sp_trace.c"
Imre Kise6d73412021-10-18 14:01:47 +020027)
Andrew Beggs97a00d42021-06-15 15:45:46 +000028
29target_include_directories(${TGT}
Imre Kis2ccd8e82021-10-08 11:21:14 +020030 PUBLIC
31 "${CMAKE_CURRENT_LIST_DIR}/include"
32 )
33
Imre Kise6d73412021-10-18 14:01:47 +020034# Default trace configuration, can be overwritten by setting the same variables
35# in the deployment specific file before including this file.
36set(TRACE_PREFIX "SP" CACHE STRING "Trace prefix")
37set(TRACE_LEVEL "TRACE_LEVEL_ERROR" CACHE STRING "Trace level")
Imre Kis2ccd8e82021-10-08 11:21:14 +020038
Imre Kiseeee9642021-12-17 13:59:46 +010039if (NOT DEFINED SP_HEAP_SIZE)
40 message(FATAL_ERROR "SP_HEAP_SIZE is not defined")
41endif()
42
Imre Kis2ccd8e82021-10-08 11:21:14 +020043target_compile_definitions(${TGT} PRIVATE
44 TRACE_LEVEL=${TRACE_LEVEL}
45 TRACE_PREFIX="${TRACE_PREFIX}"
Imre Kiseeee9642021-12-17 13:59:46 +010046 SP_HEAP_SIZE=${SP_HEAP_SIZE}
Imre Kis2ccd8e82021-10-08 11:21:14 +020047)
Imre Kise6d73412021-10-18 14:01:47 +020048
Julian Hall8ad60432022-08-15 14:11:47 +010049include(${TS_ROOT}/external/newlib/newlib.cmake)
Imre Kise6d73412021-10-18 14:01:47 +020050
51target_link_libraries(${TGT} PRIVATE
Gyorgy Szing693877e2021-12-12 02:51:10 +010052 stdlib::c
Imre Kise6d73412021-10-18 14:01:47 +020053)
54
55target_link_options(${TGT} PRIVATE
56 -Wl,--hash-style=sysv
57 -Wl,--as-needed
58 -Wl,--gc-sections
59)
60
61compiler_set_linker_script(TARGET ${TGT} FILE ${CMAKE_CURRENT_LIST_DIR}/sp.ld.S DEF ARM64=1)