Skip to content

Commit fc060b6

Browse files
committed
Testing new arm-zephyr-eabi-gcc.cmake file
1 parent f2d053f commit fc060b6

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#
2+
# Copyright (c) 2020-2022 Arm Limited. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the License); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
# Copied this file from core_platform/cmake/toolchain/arm-non-eabi-gcc.cmake And
20+
# modified to align better with cs300 platform
21+
22+
set(TARGET_CPU
23+
"cortex-m55"
24+
CACHE STRING "Target CPU"
25+
)
26+
string(TOLOWER ${TARGET_CPU} CMAKE_SYSTEM_PROCESSOR)
27+
28+
set(CMAKE_SYSTEM_NAME Generic)
29+
set(CMAKE_C_COMPILER "arm-zephyr-eabi-gcc")
30+
set(CMAKE_CXX_COMPILER "arm-zephyr-eabi-g++")
31+
set(CMAKE_ASM_COMPILER "arm-zephyr-eabi-gcc")
32+
set(CMAKE_LINKER "arm-zephyr-eabi-ld")
33+
34+
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
35+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
36+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
37+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
38+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
39+
40+
# Select C/C++ version
41+
set(CMAKE_C_STANDARD 11)
42+
set(CMAKE_CXX_STANDARD 17)
43+
44+
set(GCC_CPU ${CMAKE_SYSTEM_PROCESSOR})
45+
string(REPLACE "cortex-m85" "cortex-m55" GCC_CPU ${GCC_CPU})
46+
47+
# Compile options
48+
add_compile_options(
49+
-mcpu=${GCC_CPU} -mthumb "$<$<CONFIG:DEBUG>:-gdwarf-3>"
50+
"$<$<COMPILE_LANGUAGE:CXX>:-fno-unwind-tables;-fno-rtti;-fno-exceptions>"
51+
-fdata-sections -ffunction-sections
52+
)
53+
54+
# Compile defines
55+
add_compile_definitions("$<$<NOT:$<CONFIG:DEBUG>>:NDEBUG>")
56+
57+
# Link options
58+
add_link_options(-mcpu=${GCC_CPU} -mthumb)
59+
60+
if(SEMIHOSTING)
61+
add_link_options(--specs=rdimon.specs)
62+
else()
63+
add_link_options(--specs=nosys.specs)
64+
endif()
65+
66+
# Set floating point unit
67+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "\\+fp")
68+
set(FLOAT hard)
69+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "\\+nofp")
70+
set(FLOAT soft)
71+
elseif(
72+
CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m33(\\+|$)"
73+
OR CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m55(\\+|$)"
74+
OR CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m85(\\+|$)"
75+
)
76+
set(FLOAT hard)
77+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m4(\\+|$)"
78+
OR CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m7(\\+|$)"
79+
)
80+
set(FLOAT hard)
81+
set(FPU_CONFIG "fpv4-sp-d16")
82+
add_compile_options(-mfpu=${FPU_CONFIG})
83+
add_link_options(-mfpu=${FPU_CONFIG})
84+
else()
85+
set(FLOAT soft)
86+
endif()
87+
88+
if(FLOAT)
89+
add_compile_options(-mfloat-abi=${FLOAT})
90+
add_link_options(-mfloat-abi=${FLOAT})
91+
endif()
92+
93+
add_link_options(LINKER:--nmagic,--gc-sections)
94+
95+
# Compilation warnings
96+
add_compile_options(
97+
# -Wall -Wextra -Wcast-align -Wdouble-promotion -Wformat
98+
# -Wmissing-field-initializers -Wnull-dereference -Wredundant-decls -Wshadow
99+
# -Wswitch -Wswitch-default -Wunused -Wno-redundant-decls
100+
-Wno-error=deprecated-declarations
101+
-Wno-error=shift-count-overflow
102+
-Wno-psabi
103+
)

0 commit comments

Comments
 (0)