aboutsummaryrefslogtreecommitdiff
path: root/cmake/Common/CompilerIarArm850.cmake
blob: dfa9a36d82c4d5772bb70a8317dd8786611145f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#-------------------------------------------------------------------------------
# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

#This file contains settings to specify how ICCARM shall be used

#Include some dependencies
Include(Common/CompilerIarArmCommon)
Include(Common/Utils)

check_iccarm_input_vars("8.50")

if(NOT DEFINED ARM_CPU_ARCHITECTURE)
	set(_NO_ARM_CPU_ARCHITECTURE true)
elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.BASE")
	string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M23")
	string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M23")
	string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M23")
	string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M23")
elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN")
	string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M33.no_dsp")
	string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M33.no_dsp")
	string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M33.no_dsp")
	string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M33.no_dsp")
elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M")
	string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
	string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
	string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
	string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6-M")
	string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
	string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
	string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
	string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
else()
	message(FATAL_ERROR "Unknown or unsupported ARM cpu architecture setting.")
endif()

#Prefer architecture definition over cpu type.
if(NOT DEFINED ARM_CPU_ARCHITECTURE)
	if(NOT DEFINED ARM_CPU_TYPE)
		string_append_unique_item(_NO_ARM_CPU_TYPE true)
	elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M3")
		string_append_unique_item (CMAKE_C_FLAGS_CPU "--cpu Cortex-M3")
		string_append_unique_item (CMAKE_CXX_FLAGS_CPU "--cpu Cortex-M3")
		string_append_unique_item (CMAKE_ASM_FLAGS_CPU "--cpu Cortex-M3")
		string_append_unique_item (CMAKE_LINK_FLAGS_CPU "--cpu Cortex-M3")
	elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33")
		string_append_unique_item (CMAKE_C_FLAGS_CPU "--cpu Cortex-M33.no_dsp")
		string_append_unique_item (CMAKE_CXX_FLAGS_CPU "--cpu Cortex-M33.no_dsp")
		string_append_unique_item (CMAKE_ASM_FLAGS_CPU "--cpu Cortex-M33.no_dsp")
		string_append_unique_item (CMAKE_LINK_FLAGS_CPU "--cpu Cortex-M33.no_dsp")
	elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23")
		string_append_unique_item (CMAKE_C_FLAGS_CPU "--cpu Cortex-M23")
		string_append_unique_item (CMAKE_CXX_FLAGS_CPU "--cpu Cortex-M23")
		string_append_unique_item (CMAKE_ASM_FLAGS_CPU "--cpu Cortex-M23")
		string_append_unique_item (CMAKE_LINK_FLAGS_CPU "--cpu Cortex-M23")
	elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M4")
		string_append_unique_item (STRING CMAKE_C_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
		string_append_unique_item (STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
		string_append_unique_item (STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
		string_append_unique_item (STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M4")
		set(ARM_CPU_ARCHITECTURE "ARMv7-M")
	elseif (${ARM_CPU_TYPE} STREQUAL "Cortex-M0p")
		string_append_unique_item (STRING CMAKE_C_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
		string_append_unique_item (STRING CMAKE_CXX_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
		string_append_unique_item (STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
		string_append_unique_item (STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu Cortex-M0+")
		set(ARM_CPU_ARCHITECTURE "ARMv6-M")
	else()
		message(FATAL_ERROR "Unknown ARM cpu setting.")
	endif()
endif()

if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE)
	message(FATAL_ERROR "Can not set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.")
endif()