Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Mate Toth-Pal | ef4b26e | 2018-01-17 19:52:35 +0100 | [diff] [blame] | 2 | # Copyright (c) 2017-2018, Arm Limited. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #This file contains settings to specify how ARMCLANG shall be used |
| 9 | |
| 10 | #Include some dependencies |
| 11 | Include(Common/CompilerArmClangCommon) |
| 12 | Include(Common/Utils) |
| 13 | |
| 14 | check_armclang_input_vars("6.7") |
| 15 | |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame^] | 16 | if(NOT DEFINED ARM_CPU_ARCHITECTURE) |
| 17 | set(_NO_ARM_CPU_ARCHITECTURE true) |
| 18 | elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.BASE") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 19 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 20 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 21 | #following is to work around an armclang compiler bug that is fixed in 6.10 |
| 22 | string_append_unique_item(STRING CMAKE_C_FLAGS KEY "-fno-optimize-sibling-calls" VAL "-fno-optimize-sibling-calls") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 23 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 24 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") |
| 25 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") |
| 26 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame^] | 27 | elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 28 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 29 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") |
| 30 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 31 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") |
| 32 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") |
| 33 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame^] | 34 | elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 35 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 36 | string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m") |
| 37 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") |
| 38 | string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") |
| 39 | string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") |
| 40 | string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") |
| 41 | else() |
| 42 | message(FATAL_ERROR "Unknown or unsupported ARM cpu architecture setting.") |
| 43 | endif() |
| 44 | |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame^] | 45 | #Prefer architecture definition over cpu type. |
| 46 | if(NOT DEFINED ARM_CPU_ARCHITECTURE) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 47 | if(NOT DEFINED ARM_CPU_TYPE) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 48 | string_append_unique_item(_NO_ARM_CPU_TYPE true) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 49 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M3") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 50 | string_append_unique_item (CMAKE_C_FLAGS_CPU "--target=arm-arm-none-eabi -mcpu=cortex-m3") |
| 51 | string_append_unique_item (CMAKE_CXX_FLAGS_CPU "--target=arm-arm-none-eabi -mcpu=cortex-m3") |
| 52 | string_append_unique_item (CMAKE_ASM_FLAGS_CPU "--cpu=Cortex-M3") |
| 53 | string_append_unique_item (CMAKE_LINK_FLAGS_CPU "--cpu=Cortex-M3") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 54 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 55 | string_append_unique_item (CMAKE_C_FLAGS_CPU "--target=arm-arm-none-eabi -mcpu=cortex-m33") |
| 56 | string_append_unique_item (CMAKE_CXX_FLAGS_CPU "--target=arm-arm-none-eabi -mcpu=cortex-m33") |
| 57 | string_append_unique_item (CMAKE_ASM_FLAGS_CPU "--cpu=Cortex-M33") |
| 58 | string_append_unique_item (CMAKE_LINK_FLAGS_CPU "--cpu=Cortex-M33") |
Mate Toth-Pal | ef4b26e | 2018-01-17 19:52:35 +0100 | [diff] [blame] | 59 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 60 | #-fno-optimize-sibling-calls is here to work around an armclang compiler |
| 61 | #bug that is fixed in 6.10 |
| 62 | string_append_unique_item (CMAKE_C_FLAGS_CPU "--target=arm-arm-none-eabi -mcpu=cortex-m23 -fno-optimize-sibling-calls") |
| 63 | string_append_unique_item (CMAKE_CXX_FLAGS_CPU "--target=arm-arm-none-eabi -mcpu=cortex-m23 -fno-optimize-sibling-calls") |
| 64 | string_append_unique_item (CMAKE_ASM_FLAGS_CPU "--cpu=Cortex-M23") |
| 65 | string_append_unique_item (CMAKE_LINK_FLAGS_CPU "--cpu=Cortex-M23") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 66 | else() |
| 67 | message(FATAL_ERROR "Unknown ARM cpu setting.") |
| 68 | endif() |
| 69 | endif() |
| 70 | |
Antonio de Angelis | f1f7ebd | 2018-11-23 23:11:41 +0000 | [diff] [blame^] | 71 | if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 72 | message(FATAL_ERROR "Can not set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") |
| 73 | endif() |