Satish Kumar | 427923c | 2021-10-05 07:21:53 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | set(CMAKE_C_COMPILER_FORCED true) |
| 9 | set(CROSS_COMPILE arm-none-eabi CACHE STRING "Cross-compilation triplet") |
| 10 | |
| 11 | if (NOT (COMPILER)) |
| 12 | set(COMPILER "GNUARM") |
| 13 | endif () |
| 14 | |
| 15 | if (COMPILER STREQUAL "GNUARM") |
| 16 | |
| 17 | include(${PSA_ADAC_ROOT}/cmake/toolchain_GNUARM.cmake) |
| 18 | |
| 19 | if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
| 20 | add_compile_options(-flto -Os) |
| 21 | add_link_options(-Wl,--as-needed -flto -flto-partition=none -Os -ffunction-sections -fuse-linker-plugin) |
| 22 | add_compile_options($<$<COMPILE_LANGUAGE:C>:-DNDEBUG>) |
| 23 | endif () |
| 24 | |
| 25 | elseif(COMPILER STREQUAL "ARMCLANG") |
| 26 | |
| 27 | include(${PSA_ADAC_ROOT}/cmake/toolchain_ARMCLANG.cmake) |
| 28 | |
| 29 | if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
| 30 | add_compile_options($<$<COMPILE_LANGUAGE:C>:-Oz>) |
| 31 | # # Can't enable LTO for all targets because static libraries (like mbedcrypto) |
| 32 | # # are not supported. |
| 33 | # add_compile_options(-flto) |
| 34 | # add_link_options(--lto) |
| 35 | add_compile_options($<$<COMPILE_LANGUAGE:C>:-DNDEBUG>) |
| 36 | endif () |
| 37 | |
| 38 | elseif(COMPILER STREQUAL "IARARM") |
| 39 | |
| 40 | include(${PSA_ADAC_ROOT}/cmake/toolchain_IARARM.cmake) |
| 41 | |
| 42 | if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") |
| 43 | add_compile_options(--mfc) |
| 44 | add_link_options(--vfe) |
| 45 | add_compile_options($<$<COMPILE_LANGUAGE:C>:-DNDEBUG>) |
| 46 | endif() |
| 47 | |
| 48 | else() |
| 49 | |
| 50 | message(FATAL_ERROR "\nValid values for COMPILER are 'GNUARM' (default), 'ARMCLANG' and 'IARARM'\n") |
| 51 | |
| 52 | endif() |