blob: a9bdd89f520d0781516c7f9e40d11266e2f7ae0d [file] [log] [blame]
Mate Toth-Pal76867262018-03-09 13:15:36 +01001#-------------------------------------------------------------------------------
Sverteczky, Marcelld3321192019-06-03 14:13:36 +02002# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
Mate Toth-Pal76867262018-03-09 13:15:36 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#This file contains settings to specify how GCC shall be used
9
10#Include some dependencies
11Include(Common/CompilerGNUARMCommon)
12Include(Common/Utils)
13
14check_gnuarm_input_vars("6.3")
15
Antonio de Angelisf1f7ebd2018-11-23 23:11:41 +000016if(NOT DEFINED ARM_CPU_ARCHITECTURE)
17 set(_NO_ARM_CPU_ARCHITECTURE true)
18elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.BASE")
Mate Toth-Pal76867262018-03-09 13:15:36 +010019 string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base")
20 string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base")
21 string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base")
22 string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base")
Antonio de Angelisf1f7ebd2018-11-23 23:11:41 +000023elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN")
Mate Toth-Pal76867262018-03-09 13:15:36 +010024 string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main")
25 string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main")
26 string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main")
27 string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main")
Antonio de Angelisf1f7ebd2018-11-23 23:11:41 +000028elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M")
Mate Toth-Pal76867262018-03-09 13:15:36 +010029 string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m")
30 string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m")
31 string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m")
32 string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m")
33else()
34 message(FATAL_ERROR "Unknown or unsupported ARM cpu architecture setting.")
35endif()
36
Antonio de Angelisf1f7ebd2018-11-23 23:11:41 +000037#Prefer architecture definition over cpu type.
38if(NOT DEFINED ARM_CPU_ARCHITECTURE)
Mate Toth-Pal76867262018-03-09 13:15:36 +010039 if(NOT DEFINED ARM_CPU_TYPE)
40 string_append_unique_item(_NO_ARM_CPU_TYPE true)
41 elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M3")
Sverteczky, Marcelld3321192019-06-03 14:13:36 +020042 string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3")
43 string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3")
44 string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3")
45 string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3")
Mate Toth-Pal76867262018-03-09 13:15:36 +010046 elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33")
Sverteczky, Marcelld3321192019-06-03 14:13:36 +020047 string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33")
48 string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33")
49 string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33")
50 string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33")
Mate Toth-Pal76867262018-03-09 13:15:36 +010051 elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23")
Sverteczky, Marcelld3321192019-06-03 14:13:36 +020052 string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23")
53 string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23")
54 string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M23")
55 string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M23")
Mate Toth-Pal76867262018-03-09 13:15:36 +010056 else()
57 message(FATAL_ERROR "Unknown ARM cpu setting.")
58 endif()
59endif()
60
Antonio de Angelisf1f7ebd2018-11-23 23:11:41 +000061if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE)
Mate Toth-Pal76867262018-03-09 13:15:36 +010062 message(FATAL_ERROR "Cannot set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.")
63endif()