Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Imre Kis | eeee964 | 2021-12-17 13:59:46 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved. |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Gyorgy Szing | b8d6f26 | 2023-06-05 12:36:02 +0200 | [diff] [blame] | 8 | # Check mandatory variables. |
| 9 | foreach(_var IN ITEMS TGT) |
| 10 | if (NOT DEFINED ${_var}) |
| 11 | message(FATAL_ERROR "Mandatory parameter '${_var}' missing.") |
| 12 | endif() |
| 13 | endforeach() |
| 14 | |
Gyorgy Szing | 3e3db70 | 2023-07-21 14:18:19 +0200 | [diff] [blame] | 15 | # Ensure elf output naming is symbolize.py compatible. |
| 16 | # If binary UUID is not defined, fall back to using the SP UUID value. |
| 17 | if (NOT SP_BIN_UUID_CANON) |
| 18 | set(SP_BIN_UUID_CANON "${SP_UUID_CANON}") |
| 19 | endif() |
| 20 | ts_add_uuid_to_exe_name(TGT "${TGT}" UUID "${SP_BIN_UUID_CANON}" ) |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 21 | |
Gyorgy Szing | 6a0d992 | 2023-07-20 14:55:42 +0200 | [diff] [blame^] | 22 | get_target_property(_tgt_type ${TGT} TYPE) |
| 23 | if ("${_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) |
| 26 | endif() |
| 27 | |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 28 | target_sources(${TGT} PRIVATE |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 29 | "${CMAKE_CURRENT_LIST_DIR}/optee_sp_header.c" |
Imre Kis | ef5c264 | 2021-12-17 14:07:35 +0100 | [diff] [blame] | 30 | "${CMAKE_CURRENT_LIST_DIR}/sp_assert.c" |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 31 | "${CMAKE_CURRENT_LIST_DIR}/sp_entry.c" |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 32 | "${CMAKE_CURRENT_LIST_DIR}/sp_trace.c" |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 33 | ) |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 34 | |
| 35 | target_include_directories(${TGT} |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 36 | PUBLIC |
| 37 | "${CMAKE_CURRENT_LIST_DIR}/include" |
| 38 | ) |
| 39 | |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 40 | # Default trace configuration, can be overwritten by setting the same variables |
| 41 | # in the deployment specific file before including this file. |
| 42 | set(TRACE_PREFIX "SP" CACHE STRING "Trace prefix") |
| 43 | set(TRACE_LEVEL "TRACE_LEVEL_ERROR" CACHE STRING "Trace level") |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 44 | |
Imre Kis | eeee964 | 2021-12-17 13:59:46 +0100 | [diff] [blame] | 45 | if (NOT DEFINED SP_HEAP_SIZE) |
| 46 | message(FATAL_ERROR "SP_HEAP_SIZE is not defined") |
| 47 | endif() |
| 48 | |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 49 | target_compile_definitions(${TGT} PRIVATE |
| 50 | TRACE_LEVEL=${TRACE_LEVEL} |
| 51 | TRACE_PREFIX="${TRACE_PREFIX}" |
Imre Kis | eeee964 | 2021-12-17 13:59:46 +0100 | [diff] [blame] | 52 | SP_HEAP_SIZE=${SP_HEAP_SIZE} |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 53 | ) |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 54 | |
Julian Hall | 8ad6043 | 2022-08-15 14:11:47 +0100 | [diff] [blame] | 55 | include(${TS_ROOT}/external/newlib/newlib.cmake) |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 56 | |
| 57 | target_link_libraries(${TGT} PRIVATE |
Gyorgy Szing | 693877e | 2021-12-12 02:51:10 +0100 | [diff] [blame] | 58 | stdlib::c |
Imre Kis | e6d7341 | 2021-10-18 14:01:47 +0200 | [diff] [blame] | 59 | ) |
| 60 | |
| 61 | target_link_options(${TGT} PRIVATE |
| 62 | -Wl,--hash-style=sysv |
| 63 | -Wl,--as-needed |
| 64 | -Wl,--gc-sections |
| 65 | ) |
| 66 | |
| 67 | compiler_set_linker_script(TARGET ${TGT} FILE ${CMAKE_CURRENT_LIST_DIR}/sp.ld.S DEF ARM64=1) |