blob: 1a2c7b626339c1d53d88b68144cf4ac12374909d [file] [log] [blame]
Anton Komlevaee4b612023-05-14 17:38:36 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8set(CMAKE_SYSTEM_NAME Generic)
9
10set(CMAKE_C_COMPILER_FORCED TRUE)
11set(CMAKE_CXX_COMPILER_FORCED TRUE)
12
13find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}-gcc)
14find_program(CMAKE_CXX_COMPILER ${CROSS_COMPILE}-g++)
15
16if(CMAKE_C_COMPILER STREQUAL "CMAKE_C_COMPILER-NOTFOUND")
17 message(FATAL_ERROR "Could not find compiler: '${CROSS_COMPILE}-gcc'")
18endif()
19
20if(CMAKE_CXX_COMPILER STREQUAL "CMAKE_CXX_COMPILER-NOTFOUND")
21 message(FATAL_ERROR "Could not find compiler: '${CROSS_COMPILE}-g++'")
22endif()
23
24set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
25
26# Set compiler ID explicitly as it's not detected at this moment
27set(CMAKE_C_COMPILER_ID GNU)
Anton Komlevdd0a7222023-09-19 18:49:39 +010028
29# A platfomr sprecific MCPU and architecture flags for NS side
30include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake)
Anton Komlevaee4b612023-05-14 17:38:36 +010031
32add_compile_options(
33 -specs=nano.specs
34 -Wall
35 -Wno-format
36 -Wno-return-type
37 -Wno-unused-but-set-variable
38 -c
39 -fdata-sections
40 -ffunction-sections
41 -fno-builtin
42 -fshort-enums
43 -funsigned-char
44 -mthumb
45 -nostdlib
46)
47
48add_link_options(
49 --entry=Reset_Handler
50 -specs=nano.specs
51 LINKER:-check-sections
52 LINKER:-fatal-warnings
53 LINKER:--gc-sections
54 LINKER:--no-wchar-size-warning
55 LINKER:--print-memory-usage
56 LINKER:-Map=tfm_ns.map
57 -T $<TARGET_OBJECTS:tfm_ns_scatter>
58)
59
60EXECUTE_PROCESS( COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION )
61if (GCC_VERSION VERSION_LESS 7.3.1)
62 message(FATAL_ERROR "Please use newer GNU Arm compiler version starting from 7.3.1.")
63endif()
64
65macro(target_add_scatter_file)
66
67 add_library(tfm_ns_scatter OBJECT
68 platform/tfm_common_ns.ld
69 )
70
71 set_source_files_properties(platform/tfm_common_ns.ld PROPERTIES
72 LANGUAGE C
73 KEEP_EXTENSION True)
74
75 target_compile_options(tfm_ns_scatter
76 PRIVATE
77 -E
78 -P
79 -xc
80 )
81
82 target_link_libraries(tfm_ns_scatter platform_ns)
83
84 add_dependencies(tfm_ns tfm_ns_scatter)
85
86endmacro()