blob: 484892aa474a77213c916209a63669de61f14011 [file] [log] [blame]
Jelle Sels03756662021-05-20 10:41:57 +02001#-------------------------------------------------------------------------------
2# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7#-------------------------------------------------------------------------------
8# The CMakeLists.txt for building the spm-test sp deployment for opteesp
9#
10# Used for building the SPs used in the spm test. The SP can be build twice
11# , to be able to test inter SPs communication. This is done by passing the
12# -DSP_NUMBER=1 parameter.
13#-------------------------------------------------------------------------------
14target_include_directories(spm-test${SP_NUMBER} PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
15
16include(${TS_ROOT}/tools/cmake/common/TargetCompileDefinitions.cmake)
17set_target_uuids(
18 SP_UUID ${SP_UUID_CANON}
19 SP_NAME "spm-test${SP_NUMBER}"
20)
21set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
22set(TRACE_PREFIX "SPM-TEST${SP_NUMBER}" CACHE STRING "Trace prefix")
23
24#-------------------------------------------------------------------------------
25# Extend with components that are common across all deployments of
26# spm-test
27#
28#-------------------------------------------------------------------------------
29target_include_directories(spm-test${SP_NUMBER} PRIVATE
30 ${TS_ROOT}
31 ${TS_ROOT}/components
32)
33
34#-------------------------------------------------------------------------------
35# Set target platform to provide drivers needed by the deployment
36#
37#-------------------------------------------------------------------------------
38add_platform(TARGET spm-test${SP_NUMBER})
39
40#################################################################
41
42target_compile_definitions(spm-test${SP_NUMBER} PRIVATE
43 ARM64=1
44)
45
46target_include_directories(spm-test${SP_NUMBER} PRIVATE
47 ${TS_ROOT}/components/service/spm_test
48)
49
50#-------------------------------------------------------------------------------
51# Deployment specific source files
52#-------------------------------------------------------------------------------
53target_sources(spm-test${SP_NUMBER} PRIVATE
54 ${TS_ROOT}/components/service/spm_test/sp.c
55)
56if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
57 target_compile_options(spm-test${SP_NUMBER} PRIVATE
58 -fdiagnostics-show-option
59 -gdwarf-2
60 -mstrict-align
61 -O0
62 $<$<COMPILE_LANGUAGE:C>:-std=c99>
63 $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
64 )
65
66 # Options for GCC that control linking
67 target_link_options(spm-test${SP_NUMBER} PRIVATE
68 -zmax-page-size=4096
69 )
70 # Options directly for LD, these are not understood by GCC
71 target_link_options(spm-test${SP_NUMBER} PRIVATE
72 -Wl,--as-needed
73 -Wl,--sort-section=alignment
74 # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
75 )
76endif()
77
78compiler_generate_stripped_elf(TARGET spm-test${SP_NUMBER} NAME "${SP_UUID_CANON}.stripped.elf" RES STRIPPED_ELF)
79
80######################################## install
81if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
82 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
83endif()
84
85set_target_properties(spm-test${SP_NUMBER} PROPERTIES OUTPUT_NAME "spm-test${SP_NUMBER}-${SP_UUID_CANON}.elf" )
86
87install(TARGETS spm-test${SP_NUMBER}
88 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
89 RUNTIME DESTINATION ${TS_ENV}/bin
90 )
91install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin)
92
93
94include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake)
95export_sp(
96 SP_UUID_CANON ${SP_UUID_CANON}
97 SP_UUID_LE ${SP_UUID_LE}
98 SP_NAME "spm-test${SP_NUMBER}"
99 MK_IN ${TS_ROOT}/environments/opteesp/sp.mk.in
100 DTS_IN ${TS_ROOT}/deployments/spm-test${SP_NUMBER}/opteesp/default_spm_test${SP_NUMBER}.dts.in
101 JSON_IN ${TS_ROOT}/environments/opteesp/sp_pkg.json.in
102)