blob: 6b763867b14216aa736ff8ef1531508c7e449d3f [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)
28# A platfomr sprecific MCPU and architecture flags for 2 toolchains
29include(${CONFIG_SPE_PATH}/platform/toolchain_ext.cmake)
30
31add_compile_options(
32 -specs=nano.specs
33 -Wall
34 -Wno-format
35 -Wno-return-type
36 -Wno-unused-but-set-variable
37 -c
38 -fdata-sections
39 -ffunction-sections
40 -fno-builtin
41 -fshort-enums
42 -funsigned-char
43 -mthumb
44 -nostdlib
45)
46
47add_link_options(
48 --entry=Reset_Handler
49 -specs=nano.specs
50 LINKER:-check-sections
51 LINKER:-fatal-warnings
52 LINKER:--gc-sections
53 LINKER:--no-wchar-size-warning
54 LINKER:--print-memory-usage
55 LINKER:-Map=tfm_ns.map
56 -T $<TARGET_OBJECTS:tfm_ns_scatter>
57)
58
59EXECUTE_PROCESS( COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION )
60if (GCC_VERSION VERSION_LESS 7.3.1)
61 message(FATAL_ERROR "Please use newer GNU Arm compiler version starting from 7.3.1.")
62endif()
63
64macro(target_add_scatter_file)
65
66 add_library(tfm_ns_scatter OBJECT
67 platform/tfm_common_ns.ld
68 )
69
70 set_source_files_properties(platform/tfm_common_ns.ld PROPERTIES
71 LANGUAGE C
72 KEEP_EXTENSION True)
73
74 target_compile_options(tfm_ns_scatter
75 PRIVATE
76 -E
77 -P
78 -xc
79 )
80
81 target_link_libraries(tfm_ns_scatter platform_ns)
82
83 add_dependencies(tfm_ns tfm_ns_scatter)
84
85endmacro()