Joakim Bech | 6e44d8b | 2018-02-13 17:21:19 +0100 | [diff] [blame^] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2017-2018, Arm Limited. All rights reserved. |
| 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.9") |
| 15 | |
| 16 | if(NOT DEFINED ARM_CPU_ARHITECTURE) |
| 17 | set(_NO_ARM_CPU_ARHITECTURE true) |
| 18 | elseif (${ARM_CPU_ARHITECTURE} STREQUAL "ARM8-M-BASE") |
| 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") |
| 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") |
| 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") |
| 27 | elseif(${ARM_CPU_ARHITECTURE} STREQUAL "ARM8-M-MAIN") |
| 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") |
| 34 | elseif(${ARM_CPU_ARHITECTURE} STREQUAL "V7-M") |
| 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 | |
| 45 | #Prefer arhitecture definition over cpu type. |
| 46 | if(NOT DEFINED ARM_CPU_ARHITECTURE) |
| 47 | if(NOT DEFINED ARM_CPU_TYPE) |
| 48 | string_append_unique_item(_NO_ARM_CPU_TYPE true) |
| 49 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M3") |
| 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") |
| 54 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") |
| 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") |
| 59 | elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") |
| 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") |
| 66 | else() |
| 67 | message(FATAL_ERROR "Unknown ARM cpu setting.") |
| 68 | endif() |
| 69 | endif() |
| 70 | |
| 71 | if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARHITECTURE) |
| 72 | message(FATAL_ERROR "Can not set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") |
| 73 | endif() |