diff options
author | Raef Coles <raef.coles@arm.com> | 2020-07-10 09:58:55 +0100 |
---|---|---|
committer | Tamas Ban <tamas.ban@arm.com> | 2020-09-24 12:49:54 +0000 |
commit | a1f504ce992acda82705b358beb932bebebcfec7 (patch) | |
tree | 0f00330cb0c5b83e92aa710a1cbc6bb737aa7e66 /cmake | |
parent | 1cb0ecc33a59c041bf649b71acb264fe1af34c65 (diff) | |
download | trusted-firmware-m-a1f504ce992acda82705b358beb932bebebcfec7.tar.gz |
Build: Convert cmake dir to modern cmake
Remove unneeded cmake files inside the cmake directory. Add some new
utility files.
WARNING: This change will not build in isolation, it requires _all_
other cmake changes to successfully build. It is split out only for
clarity of changes.
Change-Id: I07dfb1c1e8f8346ae10e7cd891df700e5dd0d827
Signed-off-by: Raef Coles <raef.coles@arm.com>
Diffstat (limited to 'cmake')
41 files changed, 26 insertions, 3727 deletions
diff --git a/cmake/Common/BuildSys.cmake b/cmake/Common/BuildSys.cmake deleted file mode 100644 index 741042c143..0000000000 --- a/cmake/Common/BuildSys.cmake +++ /dev/null @@ -1,756 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file defines project-specific overrides to cmake default behaviour for: -# * compiler detection -# * target system detection -cmake_minimum_required(VERSION 3.3) #IN_LIST was introduced in 3.3 -cmake_policy(SET CMP0057 NEW) - -Include(CMakeParseArguments) - -#The CMAKE_SYSTEM_XXX settings make cmake to stop applying some target system specific settings. -#Tell cmake we are compiling for ARM chips. -set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE INTERNAL "Set target processor type to force cmake include some of our scripts." FORCE) -#Tell cmake this is an "Embedded" system -set(CMAKE_SYSTEM_NAME "Embedded" CACHE INTERNAL "Set target system name to force cmake include some of our scripts." FORCE) - -#Stop built in CMakeDetermine<lang>.cmake scripts to run. -set (CMAKE_CXX_COMPILER_ID_RUN 1) -#Stop cmake run compiler tests. -set (CMAKE_CXX_COMPILER_FORCED true) -#Stop built in CMakeDetermine<lang>.cmake scripts to run. -set (CMAKE_C_COMPILER_ID_RUN 1) -#Stop cmake run compiler tests. -set (CMAKE_C_COMPILER_FORCED true) - -#This macro is used to enforce the ARM project structure. -#Inputs: (This macro uses some "global" variables) -# global variable PROJ_CONFIG - a global configuration file to be used by all projects. -# It overrides value of CONFIG parameter. -# CONFIG - the configuration file which shall be used -#Examples -# To use global project config: -# embedded_project_start() -# To use config file relative to the top level CmakeLists.txt: -# embedded_project_start(./configs/ConfigDefault.cmake) -# To use config file relative to the CmakeLists.txt file where this macro is used: -# embedded_project_start(${TFM_ROOT_DIR}/configs/ConfigDefault.cmake) -macro(embedded_project_start) - #Default project configuration file - if (DEFINED PROJ_CONFIG) #Take the global setting as default value - set(_PROJ_CONFIG ${PROJ_CONFIG}) - endif() - - set( _OPTIONS_ARGS ) #No option (on/off) arguments - set( _ONE_VALUE_ARGS CONFIG) #Single option arguments (e.g. PROJ_NAME "bubu_project") - set( _MULTI_VALUE_ARGS ) #One list argument (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_CONFIG) - if(NOT DEFINED _PROJ_CONFIG) - set(_PROJ_CONFIG "${TFM_ROOT_DIR}/configs/ConfigDefault.cmake") - message(STATUS "embedded_project_start: no project configuration file defined, falling back to default.") - endif() - elseif(NOT DEFINED PROJ_CONFIG) - set(_PROJ_CONFIG ${_MY_PARAMS_CONFIG}) - endif() - - get_filename_component(_ABS_PROJ_CONFIG ${_PROJ_CONFIG} ABSOLUTE) - message(STATUS "embedded_project_start: using project specific config file (PROJ_CONFIG = ${_ABS_PROJ_CONFIG})") - include("${_PROJ_CONFIG}") -endmacro() - -#Override CMake default behaviour -macro(embedded_project_fixup) - get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) - - #Merge CPU and configuration specific compiler and linker flags. - foreach(LNG ${languages}) - include(Common/CompilerDetermine${LNG}) - #since all CMake "built in" scripts already executed, we need fo fix up some things here. - embedded_fixup_build_type_vars(${LNG}) - - #Apply CPU specific and configuration specific compile flags. - if(NOT CMAKE_${LNG}_FLAGS MATCHES ".*${CMAKE_${LNG}_FLAGS_CPU}.*") - set(CMAKE_${LNG}_FLAGS "${CMAKE_${LNG}_FLAGS} ${CMAKE_${LNG}_FLAGS_CPU}") - endif() - #Fix output file extension. - set (CMAKE_EXECUTABLE_SUFFIX_${LNG} ".axf") - unset(ALL_SRC_${LNG}) - unset(ALL_SRC_${LNG}_S) - unset(ALL_SRC_${LNG}_NS) - endforeach() - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LINK_FLAGS_CPU}") -endmacro() - -#Allow project specific script to do configuration after all targets are specified; it has to be done for each target defined -macro (embedded_project_end TARGET) - get_property(_MAC DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY MACROS) - if ("embedded_project_build_config_apply" IN_LIST _MAC) - message(WARNING "embedded_project_end(): macro embedded_project_build_config_apply() is defined. Your build config file may be out-dated.") - endif() - - #Apply compile flags. - _embedded_apply_compile_flags(${TARGET}) - #Apply macro definitions - _embedded_apply_compile_defines(${TARGET}) - #Apply include paths - _embedded_apply_include_directories(${TARGET}) - #Apply linker flags. - _embedded_apply_link_flags(${TARGET}) - #If target is executable, apply linker command file setting. - get_property(_TGT_TYPE TARGET ${TARGET} PROPERTY TYPE) - if(_TGT_TYPE STREQUAL "EXECUTABLE") - _embedded_apply_linker_cmd_file_setting(${TARGET}) - endif() -endmacro() - -macro(embedded_fixup_build_type_vars LANG) - #since all CMake "built in" scripts already executed, we need fo fix up some things here. - set (CMAKE_${LANG}_FLAGS_DEBUG "${CMAKE_${LANG}_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds." FORCE) - set (CMAKE_${LANG}_FLAGS_MINSIZEREL "${CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT}" CACHE STRING "Flags used by the compiler during release builds for minimum size." FORCE) - set (CMAKE_${LANG}_FLAGS_RELEASE "${CMAKE_${LANG}_FLAGS_RELEASE_INIT}" CACHE STRING "Flags used by the compiler during release builds." FORCE) - set (CMAKE_${LANG}_FLAGS_RELWITHDEBINFO "${CMAKE_${LANG}_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE) -endmacro() - - -#Convert a CMake list to a string -# -#Examples: -# list_to_string(my_string 1 2 3 4) -# list_to_string(my_string ${CMAKE_C_FLAGS}) -# -#INPUTS: -# RES - (mandatory) - name of variable to put result in -# The list to be converted. -# -#OUTPUTS -# List items concatenated to a string. -# -function(list_to_string RES) - foreach(_ITEM ${ARGN}) - set(_RES "${_RES} ${_ITEM}") - endforeach() - set(${RES} "${_RES}" PARENT_SCOPE) -endfunction() - -#Ensure current generator is supported. -# -# This function takes a list of supported generators (e.g. "Unix Makefiles") and -# exits with fatal error is the current generator is not on the list. -#Examples: -# assert_generator_is("MSYS Makefiles" "MinGW Makefiles") -# -#INPUTS: -# The list of supported generators. -# -#OUTPUTS -# n/a -# -function(assert_generator_is) - if (NOT CMAKE_GENERATOR IN_LIST ARGN) - message(FATAL_ERROR "assert_generator_is(): Generator '${CMAKE_GENERATOR}' is not on the list of supported generators.") - endif() -endfunction() - -#Check the value of a cache variable whether it is valid. -# -# This function currently only supports 'STRING' type variables and uses -# the 'STRINGS' cache entry property as the validation list. -# -#Examples: -# validate_cache_value(MCUBOOT_SIGNATURE_TYPE) -# -#INPUTS: -# variable_name - (mandatory) - Name of the cache variable to be checked. -# -#OUTPUTS: -# n/a -# -function(validate_cache_value variable_name) - #Check if the type of the variable is STRING. - get_property(_type CACHE ${variable_name} PROPERTY TYPE) - if(NOT ${_type} STREQUAL "STRING") - message(FATAL_ERROR "validate_cache_value: type of CACHE variable must be 'STRING', the type of '${variable_name}' variable is '${_type}'.") - endif() - get_property(_validation_list CACHE ${variable_name} PROPERTY STRINGS) - #Check if validation list is set. - if (NOT _validation_list) - message(FATAL_ERROR "validate_cache_value: CACHE variable '${variable_name}' has no 'STRINGS' validation list set.") - endif() - #See if the value of the variable is in the list. - if (NOT ${${variable_name}} IN_LIST _validation_list) - message(FATAL_ERROR "validate_cache_value: variable value '${${variable_name}}' of variable '${variable_name}' is not matching the validation list ${_validation_list}.") - endif() -endfunction() - -#Specify an include path for the compiler -# -# Specify a global include directory for all non external targets in the current -# build. -# The parameter ABSOLUTE can be set to true to ask CMake to convert the PATH to -# absolute. This gives better looking command line arguments, and also helps -# removing duplicates. -# -#Examples: -# embedded_include_directories(PATH "C:/fo/bar/include") -# embedded_include_directories(PATH "C:/fo/bar/include" ABSOLUTE) -# -#INPUTS: -# PATH - (mandatory) - the include path to add -# ABSOLUTE - (optional) - whether the path shall be converted to absolute -# -#OUTPUTS -# Modified list of include directories. -# -function (embedded_include_directories) - #Parse our arguments - set( _OPTIONS_ARGS ABSOLUTE) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS PATH) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check mandatory parameters - if(NOT _MY_PARAMS_PATH) - failure("embedded_include_directories(): Missing PATH parameter!") - endif() - - if(DEFINED _MY_PARAMS_ABSOLUTE AND ${_MY_PARAMS_ABSOLUTE}) - get_filename_component(_MY_PARAMS_PATH ${_MY_PARAMS_PATH} ABSOLUTE) - endif() - - include_directories(${_MY_PARAMS_PATH}) -endfunction() - -#Return the language of a source file. -# -# Language is either specified by the LANGUAGE property of the source file or -# determined based on the extension of the file. -# Search is limited for languages enabled in the current project. -# -#Examples: -# To get language of "foo/bar.c" written into _LNG: -# embedded_get_source_language("foo/bar.c" _LNG) -# -#INPUTS: -# FILE - (mandatory) - The file to determine language of. -# RES - (mandatory) - Name of the variable to write the result into. -# -#OUTPUTS -# ${RES} - language string (e.g. "C", "CXX", "ASM"). empty string for files -# with no language. -# -function(embedded_get_source_language FILE RES) - if (ARGN) - message(FATAL_ERROR "embedded_get_source_language(): too many parameters passed.") - endif() - #If language property is set, use that. - get_property(_LNG SOURCE ${_SRC} PROPERTY LANGUAGE) - if (NOT ${_LNG} STREQUAL "") - set(${RES} ${_LNG} PARENT_SCOPE) - else() - #Set empty return value. - set(${RES} "" PARENT_SCOPE) - #Property not set, use extension of the file to determine - #language. - string(REGEX MATCH "[^.]*$" _EXT "${_SRC}") - #Get list of enabled languages. - get_property(_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(_LNG ${_LANGUAGES}) - #See if the extension is contained in the list of file extensions - #of this language. - if(_EXT IN_LIST CMAKE_${_LNG}_SOURCE_FILE_EXTENSIONS) - set(${RES} ${_LNG} PARENT_SCOPE) - break() - endif() - endforeach() - endif() -endfunction() - -#Set compilation flags for the specified target. -# -# Store compilation flags for the specified target and language pair. Flags are -# stored in a global property and will -# be applied to source files in the current directory and sub-directories. -# Property name must follow a specific scheme (see outputs). -# See: _embedded_apply_compile_flags() -# -#Examples: -# embedded_set_target_compile_flags(my_app C "-fchar-unsigned") -# embedded_set_target_compile_flags(my_lib CXX "-fchar-unsigned") -# embedded_set_target_compile_flags(my_app ASM "-fchar-unsigned") -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# LANGUAGE - (mandatory) - Programming language of source files settings shall -# be applied to. -# FLAGS - (mandatory) - List with the compiler flags. -# APPEND - (optional) - True if FLAGS shall be appended. -# -#OUTPUTS -# Directory property EMBEDDED_COMPILE_FLAGS_TTT_LLL is set, where TTT is the -# target name, and LLL is the language. -# -function (embedded_set_target_compile_flags) - set( _OPTIONS_ARGS APPEND) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS TARGET LANGUAGE) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS FLAGS) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - if (NOT DEFINED _MY_PARAMS_TARGET) - message(FATAL_ERROR "embedded_set_target_compile_flags(): mandatory parameter 'TARGET' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_LANGUAGE) - message(FATAL_ERROR "embedded_set_target_compile_flags(): mandatory parameter 'LANGUAGE' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_FLAGS) - message(FATAL_ERROR "embedded_set_target_compile_flags(): mandatory parameter 'FLAGS' missing.") - endif() - - if (_MY_PARAMS_APPEND) - set_property(GLOBAL APPEND PROPERTY EMBEDDED_COMPILE_FLAGS_${_MY_PARAMS_TARGET}_${_MY_PARAMS_LANGUAGE} ${_MY_PARAMS_FLAGS}) - else() - set_property(GLOBAL PROPERTY EMBEDDED_COMPILE_FLAGS_${_MY_PARAMS_TARGET}_${_MY_PARAMS_LANGUAGE} ${_MY_PARAMS_FLAGS}) - endif() -endfunction() - -#Apply compilation flag settings for the specified target. -# -# Compilation flags stored in a global property and are applied to source files. -# Note: -# - Directory property name must follow a specific scheme. -# - This is an internal function. -# - This function only supports make and ninja generators. -# -# See: embedded_set_target_compile_flags() -# -#Examples: -# _embedded_apply_compile_flags(my_app) -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# Directory property - (optional) - Flags to apply. -# -#OUTPUTS -# n/a -# -function(_embedded_apply_compile_flags TARGET) - #Check if the parameter is a target. - if(NOT TARGET ${TARGET}) - message(FATAL_ERROR "_embedded_apply_compile_flags(): target '${TARGET}' is not defined.") - endif() - #Get list of enabled languages. - get_property(_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(_LNG ${_LANGUAGES}) - #Get the flags for this language. - get_property(_FLAGS GLOBAL PROPERTY EMBEDDED_COMPILE_FLAGS_${TARGET}_${_LNG}) - - #The generator expression below is only supported by the make and ninja - #generators. - assert_generator_is(_GENERATORS_OK "MSYS Makefiles" "MinGW Makefiles" "NMake Makefiles" "NMake Makefiles JOM" "Unix Makefiles" "Watcom WMake" "Ninja") - target_compile_options(${TARGET} PRIVATE $<$<COMPILE_LANGUAGE:${_LNG}>:${_FLAGS}>) - endforeach() -endfunction() - -#Set compilation defines for the specified target. -# -# Store compilation defines for the specified target and language pair. Macros -# are stored in a global property and will -# be applied to source files in the current directory and sub-directories. -# Property name must follow a specific scheme (see outputs). -# See: _embedded_apply_compile_defines() -# -#Examples: -# embedded_set_target_compile_defines(my_app C "FOO BAR=1") -# embedded_set_target_compile_defines(my_lib CXX "FOO BAR=1") -# embedded_set_target_compile_defines(my_app ASM "FOO BAR=1") -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# LANGUAGE - (mandatory) - Programming language of source files settings shall -# be applied to. -# DEFINES - (mandatory) - List with the compiler flags. -# APPEND - (optional) - Present if FLAGS shall be appended. -# -#OUTPUTS -# Directory property EMBEDDED_COMPILE_DEFINES_TTT_LLL is set, where TTT is the -# target name, and LLL is the language. -# -function (embedded_set_target_compile_defines) - set( _OPTIONS_ARGS APPEND) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS TARGET LANGUAGE) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - if (NOT DEFINED _MY_PARAMS_TARGET) - message(FATAL_ERROR "embedded_set_target_compile_defines(): mandatory parameter 'TARGET' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_LANGUAGE) - message(FATAL_ERROR "embedded_set_target_compile_defines(): mandatory parameter 'LANGUAGE' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_DEFINES) - message(FATAL_ERROR "embedded_set_target_compile_defines(): mandatory parameter 'DEFINES' missing.") - endif() - - if (_MY_PARAMS_APPEND) - set_property(GLOBAL APPEND PROPERTY EMBEDDED_COMPILE_DEFINES_${_MY_PARAMS_TARGET}_${_MY_PARAMS_LANGUAGE} ${_MY_PARAMS_DEFINES}) - else() - set_property(GLOBAL PROPERTY EMBEDDED_COMPILE_DEFINES_${_MY_PARAMS_TARGET}_${_MY_PARAMS_LANGUAGE} ${_MY_PARAMS_DEFINES}) - endif() -endfunction() - -#Apply compilation defines for the specified target. -# -# Macro definitions are stored in a global property and are applied to -# source files. -# -# Note: -# - Directory property name must follow a specific scheme. -# - This is an internal function. -# - This function only supports make and ninja generators. -# -# See: embedded_set_target_compile_defines() -# -#Examples: -# _embedded_apply_compile_defines(my_app) -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# Directory property - (optional) - Flags to apply. -# -#OUTPUTS -# n/a -# -function(_embedded_apply_compile_defines TARGET) - #Check if the parameter is a target. - if(NOT TARGET ${TARGET}) - message(FATAL_ERROR "_embedded_apply_compile_defines(): target '${TARGET}' is not defined.") - endif() - #Get list of enabled languages. - get_property(_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(_LNG ${_LANGUAGES}) - #Get the flags for this language. - get_property(_FLAGS GLOBAL PROPERTY EMBEDDED_COMPILE_DEFINES_${TARGET}_${_LNG}) - #The generator expression below is only supported by the make and ninja - #generators. - assert_generator_is(_GENERATORS_OK "MSYS Makefiles" "MinGW Makefiles" "NMake Makefiles" "NMake Makefiles JOM" "Unix Makefiles" "Watcom WMake" "Ninja") - target_compile_definitions(${TARGET} PRIVATE $<$<COMPILE_LANGUAGE:${_LNG}>:${_FLAGS}>) - endforeach() -endfunction() - -#Specify an include path for the compiler affecting a specific build target (all -# languages). -# -# Store include paths for the specified target. PATH is stored in a global -# property. The property name must follow a specific scheme (see outputs). -# See: _embedded_apply_include_directories() -# -#Examples: -# embedded_target_include_directories(TARGET foo PATH "C:/fo/bar/include") -# embedded_target_include_directories(TARGET foo PATH "C:/fo/bar/include" APPEND) -# embedded_target_include_directories(TARGET foo PATH "C:/fo/bar/include" ABSOLUTE) -# -#INPUTS: -# ABSOLUTE - (optional)- whether the path shall be converted to absolute -# APPEND - (optional) - if set append path to existing values -# PATH - (mandatory) - the include path to add -# TARGET - (mandatory) - name of target to apply settings to -# -#OUTPUTS -# Directory property EMBEDDED_COMPILE_INCLUDES_TTT is set, where TTT is -# the target name. -# -function (embedded_target_include_directories) - #Parse our arguments - set( _OPTIONS_ARGS ABSOLUTE APPEND) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS PATH TARGET) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check mandatory parameters - if(NOT _MY_PARAMS_PATH) - failure("embedded_target_include_directories(): Missing PATH parameter!") - endif() - - if(NOT _MY_PARAMS_TARGET) - failure("embedded_target_include_directories(): Missing TARGET parameter!") - endif() - - if(DEFINED _MY_PARAMS_ABSOLUTE AND ${_MY_PARAMS_ABSOLUTE}) - get_filename_component(_MY_PARAMS_PATH ${_MY_PARAMS_PATH} ABSOLUTE) - endif() - - if (_MY_PARAMS_APPEND) - set_property(GLOBAL APPEND PROPERTY EMBEDDED_COMPILE_INCLUDES_${_MY_PARAMS_TARGET} ${_MY_PARAMS_PATH}) - else() - set_property(GLOBAL PROPERTY EMBEDDED_COMPILE_INCLUDES_${_MY_PARAMS_TARGET} ${_MY_PARAMS_PATH}) - endif() -endfunction() - -#Apply include path settings for the specified target. -# -# Include paths are stored in a global property and are applied to source files. -# Note: -# - Directory property name must follow a specific scheme. -# - This is an internal function. -# -# See: embedded_target_include_directories() -# -#Examples: -# _embedded_apply_include_directories(my_app) -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# Directory property - (optional) - Flags to apply. -# -#OUTPUTS -# n/a -# -function(_embedded_apply_include_directories TARGET) - #Check if the parameter is a target. - if(NOT TARGET ${TARGET}) - message(FATAL_ERROR "_embedded_apply_include_directories(): target '${TARGET}' is not defined.") - endif() - #Get the flags for this language. - get_property(_FLAGS GLOBAL PROPERTY EMBEDDED_COMPILE_INCLUDES_${TARGET}) - #If we have flags to apply for this language. - if (NOT _FLAGS STREQUAL "") - target_include_directories(${TARGET} PRIVATE ${_FLAGS}) - endif() -endfunction() - -#Set linker flags for the specified target. -# -# Store linker flags for the specified target in a global property. -# See: _embedded_apply_link_flags() -# -#Examples: -# embedded_set_target_link_flags(my_app "-M my_map_file.map") -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# FLAGS - (mandatory) - List with the compiler flags. -# APPEND - (optional) - True if FLAGS shall be appended. -# -#OUTPUTS -# Directory property EMBEDDED_LINKER_FLAGS_TTT is set, where TTT is the -# target name. -# -function(embedded_set_target_link_flags) - set( _OPTIONS_ARGS APPEND) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS TARGET) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS FLAGS) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - if (NOT DEFINED _MY_PARAMS_TARGET) - message(FATAL_ERROR "embedded_set_target_link_flags(): mandatory parameter 'TARGET' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_FLAGS) - message(FATAL_ERROR "embedded_set_target_link_flags(): mandatory parameter 'FLAGS' missing.") - endif() - - if (_MY_PARAMS_APPEND) - set_property(GLOBAL APPEND PROPERTY EMBEDDED_LINKER_FLAGS_${_MY_PARAMS_TARGET} ${_MY_PARAMS_FLAGS}) - else() - set_property(GLOBAL PROPERTY EMBEDDED_LINKER_FLAGS_${_MY_PARAMS_TARGET} ${_MY_PARAMS_FLAGS}) - endif() -endfunction() - -#Apply linker flags for the specified target. -# -# Linker flags stored in a global property are applied. -# -# Note: -# - Directory property name must follow a specific scheme. -# - This is an internal function. -# -# See: embedded_set_target_link_flags() -# -#Examples: -# _embedded_apply_link_flags(my_app) -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# Directory property - (optional) - Flags to apply. -# -#OUTPUTS -# n/a -# -function(_embedded_apply_link_flags TARGET) - #Check if the parameter is a target. - if(NOT TARGET ${TARGET}) - message(FATAL_ERROR "_embedded_apply_link_flags(): target '${TARGET}' is not defined.") - endif() - #Get the stored flags. - get_property(_FLAGS GLOBAL PROPERTY EMBEDDED_LINKER_FLAGS_${TARGET}) - #Apply flags if defined. - if (NOT _FLAGS STREQUAL "") - list_to_string(_STR_FLAGS ${_FLAGS}) - set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS ${_STR_FLAGS}) - endif() -endfunction() - -#Set linker command file for the specified target. -# -# Store path to linker command file for the specified target in a global -# property. -# -# See: _embedded_apply_linker_cmd_file_setting() -# -#Examples: -# embedded_set_target_linker_file(TARGET my_app PATH "foo/my_linker_cmd.sct") -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# PATH - (mandatory) - Path to linker script. -# -#OUTPUTS -# Directory property EMBEDDED_LINKER_CMD_FILE_TTT is set, where TTT is the -# target name. -# -function(embedded_set_target_linker_file) - set( _OPTIONS_ARGS ) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS TARGET PATH) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - if (NOT DEFINED _MY_PARAMS_TARGET) - message(FATAL_ERROR "embedded_set_target_linker_file(): mandatory parameter 'TARGET' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_PATH) - message(FATAL_ERROR "embedded_set_target_linker_file(): mandatory parameter 'PATH' missing.") - endif() - - set_property(GLOBAL PROPERTY EMBEDDED_LINKER_CMD_FILE_${_MY_PARAMS_TARGET} ${_MY_PARAMS_PATH}) -endfunction() - -#Set pre-processor defines for the linker command file. -# -# Store preprocessor defines for the linker command file of the specified target -# in a global property. -# -# See: _embedded_apply_linker_cmd_file_setting() -# -#Examples: -# embedded_set_target_link_defines(my_app "BL2=1" "USE_TLS=1") -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# DEFINES - (mandatory) - List of macro value definitions. -# -#OUTPUTS -# Directory property EMBEDDED_LINKER_DEFINES_TTT is set, where TTT is the -# target name. -# -function(embedded_set_target_link_defines) - set( _OPTIONS_ARGS ) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS TARGET) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - if (NOT DEFINED _MY_PARAMS_TARGET) - message(FATAL_ERROR "embedded_set_target_link_defines(): mandatory parameter 'TARGET' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_DEFINES) - message(FATAL_ERROR "embedded_set_target_link_defines(): mandatory parameter 'DEFINES' missing.") - endif() - - set_property(GLOBAL APPEND PROPERTY EMBEDDED_LINKER_DEFINES_${_MY_PARAMS_TARGET} ${_MY_PARAMS_DEFINES}) -endfunction() - - -#Set pre-processor include paths for the linker command file. -# -# Store preprocessor include paths for the linker command file of the specified -# target in a global property. -# -# See: _embedded_apply_linker_cmd_file_setting() -# -#Examples: -# embedded_set_target_link_includes(my_app "c:/foo" "../bar") -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# INCLUDES - (mandatory) - List of include paths. -# -#OUTPUTS -# Directory property EMBEDDED_LINKER_INCLUDES_TTT is set, where TTT is the -# target name. -# -function(embedded_set_target_link_includes) - set( _OPTIONS_ARGS ) #Option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS TARGET) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS INCLUDES) #List arguments (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - if (NOT DEFINED _MY_PARAMS_TARGET) - message(FATAL_ERROR "embedded_set_target_link_includes(): mandatory parameter 'TARGET' missing.") - endif() - - if (NOT DEFINED _MY_PARAMS_INCLUDES) - message(FATAL_ERROR "embedded_set_target_link_includes(): mandatory parameter 'INCLUDES' missing.") - endif() - - set_property(GLOBAL APPEND PROPERTY EMBEDDED_LINKER_INCLUDES_${_MY_PARAMS_TARGET} ${_MY_PARAMS_INCLUDES}) -endfunction() - - -#Apply linker linker command file setting for the specified target. -# -# Path to linker command file, macro definitions and include paths stored in -# global properties are applied. -# -# Note: -# - Directory property names must follow a specific scheme. -# - This is an internal function. -# -# See: embedded_set_target_linker_file(), embedded_set_target_link_includes() -# embedded_set_target_link_defines() -# -#Examples: -# _embedded_apply_linker_cmd_file_setting(my_app) -# -#INPUTS: -# TARGET - (mandatory) - The target to apply settings to. -# Directory properties -# -#OUTPUTS -# n/a -# -function(_embedded_apply_linker_cmd_file_setting TARGET) - #Check if the parameter is a target. - if(NOT TARGET ${TARGET}) - message(FATAL_ERROR "_embedded_apply_linker_cmd_file_setting(): target '${TARGET}' is not defined.") - endif() - #Check if target is an executable. - get_property(_TGT_TYPE TARGET ${TARGET} PROPERTY TYPE) - if(NOT _TGT_TYPE STREQUAL "EXECUTABLE") - message(FATAL_ERROR "_embedded_apply_linker_cmd_file_setting(): target '${TARGET}' is not an executable.") - endif() - - #Check if executable has a linker command file set. - get_property(_LINKER_CMD_FILE GLOBAL PROPERTY EMBEDDED_LINKER_CMD_FILE_${TARGET} SET) - if (NOT _LINKER_CMD_FILE) - message(FATAL_ERROR "_embedded_apply_linker_cmd_file_setting(): Please set linker command file for target '${TARGET}' using embedded_set_target_linker_file().") - endif() - #Get the path to the linker command file. - get_property(_LINKER_CMD_FILE GLOBAL PROPERTY EMBEDDED_LINKER_CMD_FILE_${TARGET}) - - #Get macro defines and include paths set for the target. - get_property(_LINKER_DEFINES GLOBAL PROPERTY EMBEDDED_LINKER_DEFINES_${TARGET}) - get_property(_LINKER_INCLUDES GLOBAL PROPERTY EMBEDDED_LINKER_INCLUDES_${TARGET}) - compiler_set_linkercmdfile(TARGET ${TARGET} PATH ${_LINKER_CMD_FILE} DEFINES ${_LINKER_DEFINES} INCLUDES ${_LINKER_INCLUDES}) -endfunction() diff --git a/cmake/Common/CompilerArmClang610.cmake b/cmake/Common/CompilerArmClang610.cmake deleted file mode 100644 index af9b7a5d18..0000000000 --- a/cmake/Common/CompilerArmClang610.cmake +++ /dev/null @@ -1,98 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2018-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how ARMCLANG shall be used - -#Include some dependencies -Include(Common/CompilerArmClangCommon) -Include(Common/Utils) - -check_armclang_input_vars("6.10") - -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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") -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(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - 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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - 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() diff --git a/cmake/Common/CompilerArmClang611.cmake b/cmake/Common/CompilerArmClang611.cmake deleted file mode 100644 index 0e8cefb464..0000000000 --- a/cmake/Common/CompilerArmClang611.cmake +++ /dev/null @@ -1,98 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2018-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how ARMCLANG shall be used - -#Include some dependencies -Include(Common/CompilerArmClangCommon) -Include(Common/Utils) - -check_armclang_input_vars("6.11") - -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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") -elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") -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(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - 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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - 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() diff --git a/cmake/Common/CompilerArmClang612.cmake b/cmake/Common/CompilerArmClang612.cmake deleted file mode 100644 index d5bd3d339c..0000000000 --- a/cmake/Common/CompilerArmClang612.cmake +++ /dev/null @@ -1,98 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how ARMCLANG shall be used - -#Include some dependencies -Include(Common/CompilerArmClangCommon) -Include(Common/Utils) - -check_armclang_input_vars("6.12") - -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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") -elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") -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(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - 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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - 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() diff --git a/cmake/Common/CompilerArmClang613.cmake b/cmake/Common/CompilerArmClang613.cmake deleted file mode 100644 index b74e1e45b4..0000000000 --- a/cmake/Common/CompilerArmClang613.cmake +++ /dev/null @@ -1,127 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how ARMCLANG shall be used - -#Include some dependencies -Include(Common/CompilerArmClangCommon) -Include(Common/Utils) - -check_armclang_input_vars("6.13") - -if(NOT DEFINED ARM_CPU_ARCHITECTURE) - set(_NO_ARM_CPU_ARCHITECTURE true) -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8.1-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8.1-m.main+mve") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8.1-m.main+mve") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8.1-M.Main.dsp") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8.1-M.Main.dsp") - -# FIXME -# When compiling for a given architecture, compilers define a flag identifying -# the architecture like __ARM_ARCH_7M__ or __ARM_ARCH_8M_MAIN__ or -# __ARM_ARCH_8_1M_MAIN__. Those flags are used in CMSIS headers like -# cmsis_armclang.h or cmsis_gcc.h to restrict the definition of some symbols -# to particular architectures. For the new Armv8.1-M.Main architecture, some -# CMSIS headers like cmsis_armclang.h or cmsis_gcc.h have not been updated yet -# to use __ARM_ARCH_8_1M_MAIN__. To mitigate this, core_armv81mml.h header -# defines __ARM_ARCH_8M_MAIN__: #define __ARM_ARCH_8M_MAIN__ 1. Concerning -# cmsis_armclang.h or cmsis_gcc.h includes, for this solution to work, wherever -# cmsis_compiler.h (which includes cmsis_armclang.h or cmsis_gcc.h) is included -# core_armv81mml.h has to be included as well. This is not the case in several -# places in TF-M code leading to compilation failures for some C files for -# Armv8.1-M architecture. When the CMSIS headers are updated to fully support -# the __ARM_ARCH_8_1M_MAIN__ flag, the compilation issues should disappear thus -# we don't want to change the header inclusions in TF-M code. Thus the below -# definition as a compile parameter of _ARM_ARCH_8M_MAIN__ that must be removed -# in the future. - - add_definitions(-D__ARM_ARCH_8M_MAIN__=1) - -elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.BASE") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=8-M.Main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=7-M") -elseif (${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=6-M") -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(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - 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 "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "--target=" VAL "--target=arm-arm-none-eabi") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M0plus") - 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() diff --git a/cmake/Common/CompilerArmClangCommon.cmake b/cmake/Common/CompilerArmClangCommon.cmake deleted file mode 100644 index 1f7acf95b2..0000000000 --- a/cmake/Common/CompilerArmClangCommon.cmake +++ /dev/null @@ -1,285 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how ARMCLANG shall be used - -function(check_armclang_input_vars MY_VERSION) - #Specify where armclang is - if (NOT DEFINED ARMCLANG_PATH) - message(FATAL_ERROR "Please set ARMCLANG_PATH to the root directory of the armclang installation. e.g. set(ARMCLANG_PATH \"C:/Program Files/ARMCompiler${MY_VERSION}\")") - endif() - - STRING(REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1.\\2" _MY_MAJOR_MINOR "${MY_VERSION}") - STRING(REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1.\\2" _ARMCLANG_MAJOR_MINOR "${ARMCLANG_VER}") - - #Check armclang version. - if (NOT "${_MY_MAJOR_MINOR}" VERSION_EQUAL "${_ARMCLANG_MAJOR_MINOR}") - message(FATAL_ERROR "ARMClang version (ARMCLANG_VER=${ARMCLANG_VER}) does not match ${MY_VERSION}") - endif() - - if (NOT DEFINED ARM_CPU_ARCHITECTURE AND NOT DEFINED ARM_CPU_TYPE) - message(FATAL_ERROR "ARM_CPU_TYPE and ARM_CPU_ARCHITECTURE is not defined! Please include the CPU specific config file before this one.") - endif() - -endfunction() - -message(STATUS "Using armclang compiler package v${ARMCLANG_VER} from ${ARMCLANG_PATH}") - - -#Tell cmake which compiler we use -if (EXISTS "c:/") - set (CMAKE_C_COMPILER "${ARMCLANG_PATH}/bin/armclang.exe") - set (CMAKE_CXX_COMPILER "${ARMCLANG_PATH}/bin/armclang.exe") - set (CMAKE_ASM_COMPILER "${ARMCLANG_PATH}/bin/armasm.exe") -else() - set (CMAKE_C_COMPILER "${ARMCLANG_PATH}/bin/armclang") - set (CMAKE_CXX_COMPILER "${ARMCLANG_PATH}/bin/armclang") - set (CMAKE_ASM_COMPILER "${ARMCLANG_PATH}/bin/armasm") -endif() - -if("CXX" IN_LIST languages) - set(CMAKE_CXX_COMPILER_ID "ARMCLANG" CACHE INTERNAL "CXX compiler ID" FORCE) - include(Compiler/ARMClang-CXX) -endif() - -if("C" IN_LIST languages) - set(CMAKE_C_COMPILER_ID "ARMCLANG" CACHE INTERNAL "C compiler ID" FORCE) - include(Compiler/ARMClang-C) -endif() - -if("ASM" IN_LIST languages) - set(CMAKE_C_COMPILER_ID "ARMCLANG" CACHE INTERNAL "ASM compiler ID" FORCE) - include(Compiler/ARMClang-ASM) -endif() - -function(compiler_get_preinclude_option_string INCLUDE RES) - set(${RES} "-include ${INCLUDE}" PARENT_SCOPE) -endfunction() - -function(compiler_set_preinclude_file) - #Option (on/off) arguments. - set( _OPTIONS_ARGS GLOBAL) - #Single option arguments. - set( _ONE_VALUE_ARGS INCLUDE) - #List arguments - set( _MULTI_VALUE_ARGS TARGETS FILES) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - if(NOT DEFINED _MY_PARAMS) - message(FATAL_ERROR "compiler_set_preinclude_file: missing mandatory parameter INCLUDE.") - endif() - compiler_get_preinclude_option_string(${INCLUDE} _OPTION_STRING) - #If include is to be set globally, we ignore TARGETS and FILES - if(_MY_PARAMS_GLOBAL) - set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_OPTIONS "${_OPTION_STRING}") - else() - #If GLOBAL was not passed, then either TARGETS or FILES must be present - if(NOT DEFINED _MY_PARAM_TARGETS AND NOT DEFINED _MY_PARAM_FILES) - message(FATAL_ERROR "compiler_set_preinclude_file: missing mandatory parameter. Either TARGETS and/or FILES must be specified.") - endif() - #Iterate over targets. Note: call embedded_set_target_compile_flags to - #allow the target to be defined after this function call. This helps - #modularisation - foreach(_TGT IN_LISTS _MY_PARAM_TARGETS) - embedded_set_target_compile_flags(TARGET ${_TGT} LANGUAGE "C" APPEND FLAGS "${_OPTION_STRING}") - endforeach() - #Iterate over files - foreach(_FILE IN_LISTS _MY_PARAM_FILES) - set_property(FILE ${_FILE} APPEND PROPERTY COMPILE_OPTIONS "${_OPTION_STRING}") - endforeach() - endif() -endfunction() - -function(compiler_set_linkercmdfile) - set( _OPTIONS_ARGS ) #Option (on/off) arguments. - set( _ONE_VALUE_ARGS TARGET PATH) #Single option arguments. - set( _MULTI_VALUE_ARGS DEFINES INCLUDES) #List arguments - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_TARGET) - message(FATAL_ERROR "compiler_set_linkercmdfile: mandatory parameter 'TARGET' is missing.") - endif() - if (NOT TARGET ${_MY_PARAMS_TARGET}) - message(FATAL_ERROR "compiler_set_linkercmdfile: value of parameter 'TARGET' is invalid.") - endif() - - if(NOT _MY_PARAMS_PATH) - message(FATAL_ERROR "compiler_set_linkercmdfile: mandatory parameter 'PATH' is missing.") - endif() - set(_FILE_PATH ${_MY_PARAMS_PATH}) - - #Compose additional command line switches from macro definitions. - set(_FLAGS "") - if (_MY_PARAMS_DEFINES) - foreach(_DEFINE IN LISTS _MY_PARAMS_DEFINES) - string(APPEND _FLAGS " --predefine=\"-D${_DEFINE}\"") - endforeach() - endif() - #Compose additional command line switches from include paths. - if (_MY_PARAMS_INCLUDES) - foreach(_INCLUDE_P IN LISTS _MY_PARAMS_INCLUDES) - string(APPEND _FLAGS " --predefine=\"-I${_INCLUDE_P}\"") - endforeach() - endif() - - #Note: the space before the option is important! - set_property(TARGET ${_MY_PARAMS_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${_FLAGS} --scatter=${_FILE_PATH}") - set_property(TARGET ${_MY_PARAMS_TARGET} APPEND PROPERTY LINK_DEPENDS ${_FILE_PATH}) - #Tell cmake .map files shall be removed when project is cleaned (make clean) - get_filename_component(_TARGET_BASE_NAME ${_MY_PARAMS_TARGET} NAME_WE) - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${_TARGET_BASE_NAME}.map") -endfunction() - -function(compiler_set_cmse_output TARGET FILE_PATH) - #Note: the space before the option is important! - set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --import_cmse_lib_out=${FILE_PATH}") - #Tell cmake cmse output is a generated object file. - SET_SOURCE_FILES_PROPERTIES("${FILE_PATH}" PROPERTIES EXTERNAL_OBJECT true GENERATED true) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "" BYPRODUCTS ${FILE_PATH}) - #Tell cmake cmse output shall be removed by clean target. - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${FILE_PATH}") -endfunction() - -function(compiler_merge_library) - set( _OPTIONS_ARGS ) #Option (on/off) arguments. - set( _ONE_VALUE_ARGS DEST) #Single option arguments. - set( _MULTI_VALUE_ARGS LIBS) #List arguments - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_DEST) - message(FATAL_ERROR "embedded_merge_library: no destination library target specified.") - endif() - #Check if destination is a target - if(NOT TARGET ${_MY_PARAMS_DEST}) - message(FATAL_ERROR "embedded_merge_library: parameter DEST must be a target already defined.") - endif() - #Check if destination is a library - get_target_property(_tmp ${_MY_PARAMS_DEST} TYPE) - if(NOT "${_tmp}" STREQUAL "STATIC_LIBRARY") - message(FATAL_ERROR "embedded_merge_library: parameter DEST must be a static library target.") - endif() - - #Check list if libraries to be merged - if(NOT _MY_PARAMS_LIBS) - message(FATAL_ERROR "embedded_merge_library: no source libraries specified. Please see the LIBS parameter.") - endif() - - #Mark each library file as a generated external object. This is needed to - #avoid error because CMake has no info how these can be built. - SET_SOURCE_FILES_PROPERTIES( - ${_MY_PARAMS_LIBS} - PROPERTIES - EXTERNAL_OBJECT true - GENERATED true) - - #Add additional input to target - target_sources(${_MY_PARAMS_DEST} PRIVATE ${_MY_PARAMS_LIBS}) -endfunction() - -function(compiler_generate_binary_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_ARMCCLANG_FROMELF} ARGS --bincombined --output=$<TARGET_FILE_DIR:${TARGET}>/${TARGET}.bin $<TARGET_FILE:${TARGET}>) -endfunction() - -function(compiler_generate_hex_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_ARMCCLANG_FROMELF} ARGS --i32combined --output=$<TARGET_FILE_DIR:${TARGET}>/${TARGET}.hex $<TARGET_FILE:${TARGET}>) -endfunction() - -function(compiler_generate_elf_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_ARMCCLANG_FROMELF} ARGS --elf --output=$<TARGET_FILE_DIR:${TARGET}>/${TARGET}.elf $<TARGET_FILE:${TARGET}>) -endfunction() - -# Function for creating a new target that preprocesses a .c file -#INPUTS: -# SRC - (mandatory) - file to be preprocessed -# DST - (mandatory) - output file for the preprocessing -# TARGET_PREFIX - (optional) - prefix for the target that this function creates and which manages the preprocessing -# BEFORE_TARGET - (optional) - target which is dependent on the preprocessing target in the below function -# DEFINES - (optional) - additional command line switches from macro definitions for preprocessing -# INCLUDES - (optional) - additional command line switches from include paths for preprocessing -function(compiler_preprocess_file) - #Option (on/off) arguments. - set( _OPTIONS_ARGS) - #Single option arguments. - set( _ONE_VALUE_ARGS SRC DST TARGET_PREFIX BEFORE_TARGET) - #List arguments - set( _MULTI_VALUE_ARGS DEFINES INCLUDES) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT DEFINED _MY_PARAMS_SRC) - message(FATAL_ERROR "compiler_preprocess_file: mandatory parameter 'SRC' is missing.") - endif() - - if(NOT DEFINED _MY_PARAMS_DST) - message(FATAL_ERROR "compiler_preprocess_file: mandatory parameter 'DST' is missing.") - endif() - - if(DEFINED _MY_PARAMS_BEFORE_TARGET) - if(NOT TARGET ${_MY_PARAMS_BEFORE_TARGET}) - message(FATAL_ERROR "compiler_preprocess_file: optional parameter 'BEFORE_TARGET' is not target.") - endif() - endif() - - #Compose additional command line switches from macro definitions. - set(_FLAGS "") - if (_MY_PARAMS_DEFINES) - foreach(_DEFINE IN LISTS _MY_PARAMS_DEFINES) - list(APPEND _FLAGS "-D${_DEFINE}") - endforeach() - endif() - - #Compose additional command line switches from include paths. - if (_MY_PARAMS_INCLUDES) - foreach(_INCLUDE IN LISTS _MY_PARAMS_INCLUDES) - list(APPEND _FLAGS "-I${_INCLUDE}") - endforeach() - endif() - - #The compiler flag might contain leading spaces which can fail the preprocess operation, these are removed - STRING(STRIP ${CMAKE_C_FLAGS_CPU} _MY_TEMP_CMAKE_C_FLAGS_CPU) - #If a string contains spaces, then it is inserted amongst quotation marks. Furthermore the compiler fails if it is - #called with multiple switches included in one quotation mark. If the extra spaces are replaced by semicolons, - #then the insertion will be advantageous for the compiler. - STRING(REPLACE " " ";" _MY_TEMP2_CMAKE_C_FLAGS_CPU ${_MY_TEMP_CMAKE_C_FLAGS_CPU}) - set(_LOCAL_CMAKE_C_FLAGS_CPU "") - foreach(_C_FLAG IN LISTS _MY_TEMP2_CMAKE_C_FLAGS_CPU) - list(APPEND _LOCAL_CMAKE_C_FLAGS_CPU "${_C_FLAG}") - endforeach() - - add_custom_command(OUTPUT ${_MY_PARAMS_DST} - COMMAND ${CMAKE_C_COMPILER} ${_LOCAL_CMAKE_C_FLAGS_CPU} -E -P -xc ${_FLAGS} ${_MY_PARAMS_SRC} -o ${_MY_PARAMS_DST} - DEPENDS ${_MY_PARAMS_SRC} - COMMENT "Preprocess the ${_MY_PARAMS_SRC} file" - ) - - set(_MY_TARGET_PREFIX "") - if(TARGET ${_MY_PARAMS_TARGET_PREFIX}) - set(_MY_TARGET_PREFIX "${_MY_PARAMS_TARGET_PREFIX}") - endif() - #The preprocessing related target name is obtained by indexing the file's name that is to be preprocessed - get_filename_component(_MY_FILENAME_TO_BE_INDEXED ${_MY_PARAMS_SRC} NAME_WE) - foreach(_SUFFIX RANGE 1 100) - if (NOT TARGET ${_MY_TARGET_PREFIX}_pp_${_MY_FILENAME_TO_BE_INDEXED}_${_SUFFIX}) - set(_PREPROCESS_TARGET_NAME "${_MY_TARGET_PREFIX}_pp_${_MY_FILENAME_TO_BE_INDEXED}_${_SUFFIX}") - break() - endif() - if (_SUFFIX EQUAL 100) - message(FATAL_ERROR "You have called 'compiler_preprocess_file' too many times (${_SUFFIX} function calls).") - endif() - endforeach() - - #Make the original target depend on the new one. - if(TARGET ${_MY_PARAMS_BEFORE_TARGET}) - add_custom_target(${_PREPROCESS_TARGET_NAME} DEPENDS ${_MY_PARAMS_DST}) - add_dependencies(${_MY_PARAMS_BEFORE_TARGET} ${_PREPROCESS_TARGET_NAME}) - else() - add_custom_target(${_PREPROCESS_TARGET_NAME} ALL DEPENDS ${_MY_PARAMS_DST}) - endif() -endfunction() diff --git a/cmake/Common/CompilerDetermineASM.cmake b/cmake/Common/CompilerDetermineASM.cmake deleted file mode 100644 index e38bce53f7..0000000000 --- a/cmake/Common/CompilerDetermineASM.cmake +++ /dev/null @@ -1,32 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Built in compiler identification does not work for embedded targets, so -#override it here. - -if(NOT DEFINED CMAKE_ASM_COMPILER) - message(FATAL_ERROR "Please set CMAKE_ASM_COMPILER to hold the full path of\ - your compiler executable") -endif() - -get_filename_component(_ASM_COMPILER_NAME ${CMAKE_ASM_COMPILER} NAME) - -#Based on the name of the compiler executable select which tool we use. -if (_ASM_COMPILER_NAME MATCHES "^.*armclang(\\.exe)?$") - set(ARM_TOOLCHAIN_FILE "Compiler/ARMClang-ASM") -elseif(_ASM_COMPILER_NAME MATCHES "^.*armasm(\\.exe)?$") - set(ARM_TOOLCHAIN_FILE "Compiler/ARMCC-ASM") -elseif (_ASM_COMPILER_NAME MATCHES "^.*gcc(\\.exe)?$") - set(ARM_TOOLCHAIN_FILE "Compiler/GNUARM-ASM") -elseif (_ASM_COMPILER_NAME MATCHES "^.*iasmarm(\\.exe)?$") - set(ARM_TOOLCHAIN_FILE "Compiler/IARARM-ASM") -else() - message(FATAL_ERROR "ASM Compiler executable ${_ASM_COMPILER_NAME} is \ -unknown. Please add needed settings to ${CMAKE_CURRENT_LIST_FILE}") -endif () - -include(${ARM_TOOLCHAIN_FILE}) diff --git a/cmake/Common/CompilerDetermineC.cmake b/cmake/Common/CompilerDetermineC.cmake deleted file mode 100644 index 7d363d721c..0000000000 --- a/cmake/Common/CompilerDetermineC.cmake +++ /dev/null @@ -1,38 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Built in compiler identification does not work for embedded targets, so -#override it here. - -#Stop built in CMakeDetermine<lang>.cmake scripts to run. -set (CMAKE_C_COMPILER_ID_RUN 1) -#Stop cmake run compiler tests. -set (CMAKE_C_COMPILER_FORCED true) - -if(NOT DEFINED CMAKE_C_COMPILER) - message(FATAL_ERROR "Please set CMAKE_C_COMPILER to hold the full path of \ -your compiler executable") -endif(NOT DEFINED CMAKE_C_COMPILER) - -get_filename_component(_C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME) - -#Based on the name of the compiler executable select which tool we use. -if (_C_COMPILER_NAME MATCHES "^.*armclang(\\.exe)?$") - set(CMAKE_C_COMPILER_ID "ARMCLANG" CACHE INTERNAL "C compiler ID" FORCE) - set(ARM_TOOLCHAIN_FILE "Compiler/ARMClang-C") -elseif (_C_COMPILER_NAME MATCHES "^.*gcc(\\.exe)?$") - set(CMAKE_C_COMPILER_ID "GNUARM" CACHE INTERNAL "C compiler ID" FORCE) - set(ARM_TOOLCHAIN_FILE "Compiler/GNUARM-C") -elseif (_C_COMPILER_NAME MATCHES "^.*iccarm(\\.exe)?$") - set(CMAKE_C_COMPILER_ID "IARARM" CACHE INTERNAL "C compiler ID" FORCE) - set(ARM_TOOLCHAIN_FILE "Compiler/IARARM-C") -else() - message(FATAL_ERROR "C Compiler executable ${_C_COMPILER_NAME} is unknown.\ -Please add needed settings to ${CMAKE_CURRENT_LIST_FILE}") -endif () - -include(${ARM_TOOLCHAIN_FILE}) diff --git a/cmake/Common/CompilerDetermineCXX.cmake b/cmake/Common/CompilerDetermineCXX.cmake deleted file mode 100644 index bf23367593..0000000000 --- a/cmake/Common/CompilerDetermineCXX.cmake +++ /dev/null @@ -1,38 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Built in compiler identification does not work for embedded targets, so -#override it here. - -#Stop built in CMakeDetermine<lang>.cmake scripts to run. -set (CMAKE_CXX_COMPILER_ID_RUN 1) -#Stop cmake run compiler tests. -set (CMAKE_CXX_COMPILER_FORCED true) - -if(NOT DEFINED CMAKE_CXX_COMPILER) - message(FATAL_ERROR "Please set CMAKE_CXX_COMPILER to hold the full path \ -of your compiler executable") -endif(NOT DEFINED CMAKE_CXX_COMPILER) - -get_filename_component(_CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME) - -if (_CXX_COMPILER_NAME MATCHES "^.*armclang(\\.exe)?$") - set(CMAKE_CXX_COMPILER_ID "ARMCLANG" CACHE INTERNAL "C++ compiler ID" FORCE) - set(ARM_TOOLCHAIN_FILE "Compiler/ARMClang-CXX") -elseif (_CXX_COMPILER_NAME MATCHES "^.*gcc(\\.exe)?$") - set(CMAKE_CXX_COMPILER_ID "GNUARM" CACHE INTERNAL "C++ compiler ID" FORCE) - set(ARM_TOOLCHAIN_FILE "Compiler/GNUARM-CXX") -elseif (_CXX_COMPILER_NAME MATCHES "^.*iccarm(\\.exe)?$") - set(CMAKE_CXX_COMPILER_ID "IARARM" CACHE INTERNAL "C++ compiler ID" FORCE) - set(ARM_TOOLCHAIN_FILE "Compiler/IARARM-CXX") -else() - message(FATAL_ERROR "C++ Compiler executable ${_C_COMPILER_NAME} is \ -unknown. Please add needed settings to ${CMAKE_CURRENT_LIST_FILE}") -endif () - -include(${ARM_TOOLCHAIN_FILE}) - diff --git a/cmake/Common/CompilerGNUARM63.cmake b/cmake/Common/CompilerGNUARM63.cmake deleted file mode 100644 index affeabb58d..0000000000 --- a/cmake/Common/CompilerGNUARM63.cmake +++ /dev/null @@ -1,80 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how GCC shall be used - -#Include some dependencies -Include(Common/CompilerGNUARMCommon) -Include(Common/Utils) - -check_gnuarm_input_vars("6.3") - -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 "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6S-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") -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(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - set(ARM_CPU_ARCHITECTURE "ARMv7-M") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M0p") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-M0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-M0plus") - set(ARM_CPU_ARCHITECTURE "ARMv6S-M") - else() - message(FATAL_ERROR "Unknown ARM cpu setting.") - endif() -endif() - -if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) - message(FATAL_ERROR "Cannot set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") -endif() diff --git a/cmake/Common/CompilerGNUARM73.cmake b/cmake/Common/CompilerGNUARM73.cmake deleted file mode 100644 index 37b94ae336..0000000000 --- a/cmake/Common/CompilerGNUARM73.cmake +++ /dev/null @@ -1,80 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2018-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how GCC shall be used - -#Include some dependencies -Include(Common/CompilerGNUARMCommon) -Include(Common/Utils) - -check_gnuarm_input_vars("7.3") - -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 "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6S-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") -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(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - set(ARM_CPU_ARCHITECTURE "ARMv7-M") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M0p") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-M0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-M0plus") - set(ARM_CPU_ARCHITECTURE "ARMv6S-M") - else() - message(FATAL_ERROR "Unknown ARM cpu setting.") - endif() -endif() - -if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) - message(FATAL_ERROR "Cannot set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") -endif() diff --git a/cmake/Common/CompilerGNUARM83.cmake b/cmake/Common/CompilerGNUARM83.cmake deleted file mode 100644 index 57007a4f48..0000000000 --- a/cmake/Common/CompilerGNUARM83.cmake +++ /dev/null @@ -1,80 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how GCC shall be used - -#Include some dependencies -Include(Common/CompilerGNUARMCommon) -Include(Common/Utils) - -check_gnuarm_input_vars("8.3") - -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 "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6S-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") -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(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - set(ARM_CPU_ARCHITECTURE "ARMv7-M") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M0p") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-m0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-m0plus") - set(ARM_CPU_ARCHITECTURE "ARMv6S-M") - else() - message(FATAL_ERROR "Unknown ARM cpu setting.") - endif() -endif() - -if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) - message(FATAL_ERROR "Cannot set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") -endif() diff --git a/cmake/Common/CompilerGNUARM92.cmake b/cmake/Common/CompilerGNUARM92.cmake deleted file mode 100644 index ac69d5dfbb..0000000000 --- a/cmake/Common/CompilerGNUARM92.cmake +++ /dev/null @@ -1,80 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how GCC shall be used - -#Include some dependencies -Include(Common/CompilerGNUARMCommon) -Include(Common/Utils) - -check_gnuarm_input_vars("9.2") - -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 "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6S-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") -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(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - set(ARM_CPU_ARCHITECTURE "ARMv7-M") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M0p") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-m0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-m0plus") - set(ARM_CPU_ARCHITECTURE "ARMv6S-M") - else() - message(FATAL_ERROR "Unknown ARM cpu setting.") - endif() -endif() - -if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) - message(FATAL_ERROR "Cannot set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") -endif() diff --git a/cmake/Common/CompilerGNUARM93.cmake b/cmake/Common/CompilerGNUARM93.cmake deleted file mode 100644 index 9ab14d2877..0000000000 --- a/cmake/Common/CompilerGNUARM93.cmake +++ /dev/null @@ -1,80 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how GCC shall be used - -#Include some dependencies -Include(Common/CompilerGNUARMCommon) -Include(Common/Utils) - -check_gnuarm_input_vars("9.3") - -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 "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.base") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv8-M.MAIN") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv8-m.main") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv7-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") -elseif(${ARM_CPU_ARCHITECTURE} STREQUAL "ARMv6S-M") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv6s-m") -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(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m3") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M3") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M33") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m33") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "--cpu=" VAL "--cpu=Cortex-M33") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M23") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m23") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=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_TYPE} STREQUAL "Cortex-M4") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-march=" VAL "-march=armv7-m") - set(ARM_CPU_ARCHITECTURE "ARMv7-M") - elseif(${ARM_CPU_TYPE} STREQUAL "Cortex-M0p") - string_append_unique_item(STRING CMAKE_C_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_CXX_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=cortex-m0plus") - string_append_unique_item(STRING CMAKE_ASM_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-m0plus") - string_append_unique_item(STRING CMAKE_LINK_FLAGS_CPU KEY "-mcpu=" VAL "-mcpu=Cortex-m0plus") - set(ARM_CPU_ARCHITECTURE "ARMv6S-M") - else() - message(FATAL_ERROR "Unknown ARM cpu setting.") - endif() -endif() - -if (_NO_ARM_CPU_TYPE AND _NO_ARM_CPU_ARCHITECTURE) - message(FATAL_ERROR "Cannot set CPU specific compiler flags: neither the ARM CPU type nor the architecture is set.") -endif() diff --git a/cmake/Common/CompilerGNUARMCommon.cmake b/cmake/Common/CompilerGNUARMCommon.cmake deleted file mode 100644 index 32e805bbe7..0000000000 --- a/cmake/Common/CompilerGNUARMCommon.cmake +++ /dev/null @@ -1,289 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how GNUARM shall be used - -function(check_gnuarm_input_vars MY_VERSION) - #Specify where gnuarm is - if (NOT DEFINED GNUARM_PATH) - message(FATAL_ERROR "Please set GNUARM_PATH to the root directory of the gnuarm installation. e.g. set(GNUARM_PATH \"C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/\"") - endif() - - STRING(REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1.\\2" _MY_MAJOR_MINOR "${MY_VERSION}") - STRING(REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1.\\2" _GNUARM_MAJOR_MINOR "${GNUARM_VER}") - - #Check gnuarm version. - if (NOT "${_MY_MAJOR_MINOR}" VERSION_EQUAL "${_GNUARM_MAJOR_MINOR}") - message(FATAL_ERROR "GNUARM version (GNUARM_VER=${GNUARM_VER}) does not match ${MY_VERSION}") - endif() - - if (NOT DEFINED ARM_CPU_ARCHITECTURE AND NOT DEFINED ARM_CPU_TYPE) - message(FATAL_ERROR "ARM_CPU_TYPE and ARM_CPU_ARCHITECTURE is not defined! Please include the CPU specific config file before this one.") - endif() - -endfunction() - -message(STATUS "Using gcc compiler package v${GNUARM_VER} from ${GNUARM_PATH}") - - -#Tell cmake which compiler we use -if (EXISTS "c:/") - set (CMAKE_C_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc.exe") - set (CMAKE_CXX_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-g++.exe") - set (CMAKE_ASM_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc.exe") -else() - set (CMAKE_C_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc") - set (CMAKE_CXX_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-g++") - set (CMAKE_ASM_COMPILER "${GNUARM_PATH}/bin/${GNUARM_PREFIX}-gcc") -endif() - -if("CXX" IN_LIST languages) - set(CMAKE_CXX_COMPILER_ID "GNUARM" CACHE INTERNAL "CXX compiler ID" FORCE) - include(Compiler/GNUARM-CXX) -endif() - -if("C" IN_LIST languages) - set(CMAKE_C_COMPILER_ID "GNUARM" CACHE INTERNAL "C compiler ID" FORCE) - include(Compiler/GNUARM-C) -endif() - -if("ASM" IN_LIST languages) - set(CMAKE_C_COMPILER_ID "GNUARM" CACHE INTERNAL "ASM compiler ID" FORCE) - include(Compiler/GNUARM-ASM) -endif() - -function(compiler_get_preinclude_option_string INCLUDE RES) - set(${RES} "-include ${INCLUDE}" PARENT_SCOPE) -endfunction() - -function(compiler_set_preinclude_file) - #Option (on/off) arguments. - set( _OPTIONS_ARGS GLOBAL) - #Single option arguments. - set( _ONE_VALUE_ARGS INCLUDE) - #List arguments - set( _MULTI_VALUE_ARGS TARGETS FILES) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - if(NOT DEFINED _MY_PARAMS) - message(FATAL_ERROR "compiler_set_preinclude_file: missing mandatory parameter INCLUDE.") - endif() - compiler_get_preinclude_option_string(${INCLUDE} _OPTION_STRING) - #If include is to be set globally, we ignore TARGETS and FILES - if(_MY_PARAMS_GLOBAL) - set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_OPTIONS "${_OPTION_STRING}") - else() - #If GLOBAL was not passed, then either TARGETS or FILES must be present - if(NOT DEFINED _MY_PARAM_TARGETS AND NOT DEFINED _MY_PARAM_FILES) - message(FATAL_ERROR "compiler_set_preinclude_file: missing mandatory parameter. Either TARGETS and/or FILES must be specified.") - endif() - #Iterate over targets. Note: call embedded_set_target_compile_flags to - #allow the target to be defined after this function call. This helps - #modularisation - foreach(_TGT IN_LISTS _MY_PARAM_TARGETS) - embedded_set_target_compile_flags(TARGET ${_TGT} LANGUAGE "C" APPEND FLAGS "${_OPTION_STRING}") - endforeach() - #Iterate over files - foreach(_FILE IN_LISTS _MY_PARAM_FILES) - set_property(FILE ${_FILE} APPEND PROPERTY COMPILE_OPTIONS "${_OPTION_STRING}") - endforeach() - endif() -endfunction() - -function(compiler_set_linkercmdfile) - set( _OPTIONS_ARGS ) #Option (on/off) arguments. - set( _ONE_VALUE_ARGS TARGET PATH) #Single option arguments. - set( _MULTI_VALUE_ARGS DEFINES INCLUDES) #List arguments - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_TARGET) - message(FATAL_ERROR "compiler_set_linkercmdfile: mandatory parameter 'TARGET' is missing.") - endif() - if (NOT TARGET ${_MY_PARAMS_TARGET}) - message(FATAL_ERROR "compiler_set_linkercmdfile: value of parameter 'TARGET' is invalid.") - endif() - - if(NOT _MY_PARAMS_PATH) - message(FATAL_ERROR "compiler_set_linkercmdfile: mandatory parameter 'PATH' is missing.") - endif() - set(_FILE_PATH ${_MY_PARAMS_PATH}) - - #Create additional target if linker script needs to be pre-processed. - if (_MY_PARAMS_DEFINES OR _MY_PARAMS_INCLUDES) - #Name of pre-processed linker script file. - set(FINAL_LD_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${_MY_PARAMS_TARGET}.ld.i") - #Name of the target doing the pre-processing - set(LD_PP_TARGET_NAME "${_MY_PARAMS_TARGET}_ldpp") - compiler_preprocess_file(SRC ${_MY_PARAMS_PATH} - DST ${FINAL_LD_FILE_NAME} - TARGET_PREFIX ${_MY_PARAMS_TARGET} - BEFORE_TARGET ${_MY_PARAMS_TARGET} - DEFINES ${_MY_PARAMS_DEFINES} - INCLUDES ${_MY_PARAMS_INCLUDES}) - - #Tell cmake to delete the intermediate linker script when the clean rule is executed. - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${FINAL_LD_FILE_NAME}") - #Set the path to linker script point to the intermediate file. - set(_FILE_PATH ${FINAL_LD_FILE_NAME}) - endif() - - #Note: the space before the option is important! - set_property(TARGET ${_MY_PARAMS_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -T${_FILE_PATH}") - set_property(TARGET ${_MY_PARAMS_TARGET} APPEND PROPERTY LINK_DEPENDS ${_FILE_PATH}) - #Tell cmake .map files shall be removed when project is cleaned (make clean) - get_filename_component(_TARGET_BASE_NAME ${_MY_PARAMS_TARGET} NAME_WE) - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${_TARGET_BASE_NAME}.map") -endfunction() - -function(compiler_set_cmse_output TARGET FILE_PATH) - #Note: the space before the option is important! - set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--cmse-implib,--out-implib=${FILE_PATH}") - #Tell cmake cmse output is a generated object file. - SET_SOURCE_FILES_PROPERTIES("${FILE_PATH}" PROPERTIES EXTERNAL_OBJECT true GENERATED true) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "" BYPRODUCTS ${FILE_PATH}) - #Tell cmake cmse output shall be removed by clean target. - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${FILE_PATH}") -endfunction() - -function(compiler_merge_library) - set( _OPTIONS_ARGS ) #Option (on/off) arguments. - set( _ONE_VALUE_ARGS DEST) #Single option arguments. - set( _MULTI_VALUE_ARGS LIBS) #List arguments - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_DEST) - message(FATAL_ERROR "compiler_merge_library: no destination target specified. Please see the DEST parameter.") - endif() - #Check if destination is a library - get_target_property(_tmp ${_MY_PARAMS_DEST} TYPE) - if(NOT "${_tmp}" STREQUAL "STATIC_LIBRARY") - message(FATAL_ERROR "compiler_merge_library: parameter DEST must be a static library target.") - endif() - set(_DEST ${_MY_PARAMS_DEST}) - - if(NOT _MY_PARAMS_LIBS) - message(FATAL_ERROR "compiler_merge_library: no source libraries specified. Please see the LIBS parameter.") - endif() - set(_LIBS ${_MY_PARAMS_LIBS}) - - ##Find the cmake script doing the merge. - find_file(_MERGE_SCRIPT "GNUArMerge.cmake" PATHS ${CMAKE_MODULE_PATH} PATH_SUFFIXES Common NO_DEFAULT_PATH) - - #Now add a custom command for each source library to our custom target to - #merge into the destination. - foreach(SRC_LIB ${_LIBS}) - get_filename_component(_SRC_LIB_NAME "${SRC_LIB}" NAME) - add_custom_command(TARGET ${_DEST} POST_BUILD - COMMAND ${CMAKE_COMMAND} -DCMAKE_AR=${CMAKE_AR} -DSOURCE=${SRC_LIB} -DDESTINATION=$<TARGET_FILE:${_DEST}> -P ${_MERGE_SCRIPT} - COMMENT "\t\tmerging objects from ${_SRC_LIB_NAME}") - endforeach() -endfunction() - -function(compiler_generate_binary_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_GNUARM_OBJCOPY} ARGS -O binary $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.bin) -endfunction() - -function(compiler_generate_hex_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_GNUARM_OBJCOPY} ARGS -O ihex $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.hex) -endfunction() - -function(compiler_generate_elf_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_GNUARM_OBJCOPY} ARGS -O elf32-little $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.elf) -endfunction() - -# Function for creating a new target that preprocesses a .c file -#INPUTS: -# SRC - (mandatory) - file to be preprocessed -# DST - (mandatory) - output file for the preprocessing -# TARGET_PREFIX - (optional) - prefix for the target that this function creates and which manages the preprocessing -# BEFORE_TARGET - (optional) - target which is dependent on the preprocessing target in the below function -# DEFINES - (optional) - additional command line switches from macro definitions for preprocessing -# INCLUDES - (optional) - additional command line switches from include paths for preprocessing -function(compiler_preprocess_file) - #Option (on/off) arguments. - set( _OPTIONS_ARGS) - #Single option arguments. - set( _ONE_VALUE_ARGS SRC DST TARGET_PREFIX BEFORE_TARGET) - #List arguments - set( _MULTI_VALUE_ARGS DEFINES INCLUDES) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT DEFINED _MY_PARAMS_SRC) - message(FATAL_ERROR "compiler_preprocess_file: mandatory parameter 'SRC' is missing.") - endif() - - if(NOT DEFINED _MY_PARAMS_DST) - message(FATAL_ERROR "compiler_preprocess_file: mandatory parameter 'DST' is missing.") - endif() - - if(DEFINED _MY_PARAMS_BEFORE_TARGET) - if(NOT TARGET ${_MY_PARAMS_BEFORE_TARGET}) - message(FATAL_ERROR "compiler_preprocess_file: optional parameter 'BEFORE_TARGET' is not target.") - endif() - endif() - - #Compose additional command line switches from macro definitions. - set(_FLAGS "") - if (_MY_PARAMS_DEFINES) - foreach(_DEFINE IN LISTS _MY_PARAMS_DEFINES) - list(APPEND _FLAGS "-D${_DEFINE}") - endforeach() - endif() - - #Compose additional command line switches from include paths. - if (_MY_PARAMS_INCLUDES) - foreach(_INCLUDE IN LISTS _MY_PARAMS_INCLUDES) - list(APPEND _FLAGS "-I${_INCLUDE}") - endforeach() - endif() - - #The compiler flag might contain leading spaces which can fail the preprocess operation, these are removed - STRING(STRIP ${CMAKE_C_FLAGS_CPU} _MY_TEMP_CMAKE_C_FLAGS_CPU) - #If a string contains spaces, then it is inserted amongst quotation marks. Furthermore the compiler fails if it is - #called with multiple switches included in one quotation mark. If the extra spaces are replaced by semicolons, - #then the insertion will be advantageous for the compiler. - STRING(REPLACE " " ";" _MY_TEMP2_CMAKE_C_FLAGS_CPU ${_MY_TEMP_CMAKE_C_FLAGS_CPU}) - set(_LOCAL_CMAKE_C_FLAGS_CPU "") - foreach(_C_FLAG IN LISTS _MY_TEMP2_CMAKE_C_FLAGS_CPU) - list(APPEND _LOCAL_CMAKE_C_FLAGS_CPU "${_C_FLAG}") - endforeach() - - add_custom_command(OUTPUT ${_MY_PARAMS_DST} - COMMAND ${CMAKE_C_COMPILER} ${_LOCAL_CMAKE_C_FLAGS_CPU} -E -P -xc ${_FLAGS} ${_MY_PARAMS_SRC} -o ${_MY_PARAMS_DST} - DEPENDS ${_MY_PARAMS_SRC} - COMMENT "Preprocess the ${_MY_PARAMS_SRC} file" - ) - - set(_MY_TARGET_PREFIX "") - if(TARGET ${_MY_PARAMS_TARGET_PREFIX}) - set(_MY_TARGET_PREFIX "${_MY_PARAMS_TARGET_PREFIX}") - endif() - #The preprocessing related target name is obtained by indexing the file's name that is to be preprocessed - get_filename_component(_MY_FILENAME_TO_BE_INDEXED ${_MY_PARAMS_SRC} NAME_WE) - foreach(_SUFFIX RANGE 1 100) - if (NOT TARGET ${_MY_TARGET_PREFIX}_pp_${_MY_FILENAME_TO_BE_INDEXED}_${_SUFFIX}) - set(_PREPROCESS_TARGET_NAME "${_MY_TARGET_PREFIX}_pp_${_MY_FILENAME_TO_BE_INDEXED}_${_SUFFIX}") - break() - endif() - if (_SUFFIX EQUAL 100) - message(FATAL_ERROR "You have called 'compiler_preprocess_file' too many times (${_SUFFIX} function calls).") - endif() - endforeach() - - #Make the original target depend on the new one. - if(TARGET ${_MY_PARAMS_BEFORE_TARGET}) - add_custom_target(${_PREPROCESS_TARGET_NAME} DEPENDS ${_MY_PARAMS_DST}) - add_dependencies(${_MY_PARAMS_BEFORE_TARGET} ${_PREPROCESS_TARGET_NAME}) - else() - add_custom_target(${_PREPROCESS_TARGET_NAME} ALL DEPENDS ${_MY_PARAMS_DST}) - endif() -endfunction() diff --git a/cmake/Common/CompilerIarArm842.cmake b/cmake/Common/CompilerIarArm842.cmake deleted file mode 100644 index 378774d5cb..0000000000 --- a/cmake/Common/CompilerIarArm842.cmake +++ /dev/null @@ -1,80 +0,0 @@ -#------------------------------------------------------------------------------- -# 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.42") - -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() diff --git a/cmake/Common/CompilerIarArm850.cmake b/cmake/Common/CompilerIarArm850.cmake deleted file mode 100644 index e68568d915..0000000000 --- a/cmake/Common/CompilerIarArm850.cmake +++ /dev/null @@ -1,86 +0,0 @@ -#------------------------------------------------------------------------------- -# 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 "ARMv8.1-M.MAIN") -# Treat v8.1-m as v8-m until we get full v8.1-m/Cortex-M55 support in iccarm - 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() diff --git a/cmake/Common/CompilerIarArmCommon.cmake b/cmake/Common/CompilerIarArmCommon.cmake deleted file mode 100644 index 6d9bdf6e13..0000000000 --- a/cmake/Common/CompilerIarArmCommon.cmake +++ /dev/null @@ -1,284 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file contains settings to specify how IARARM shall be used - -function(check_iccarm_input_vars MY_VERSION) - #Specify where IARARM is - if (NOT DEFINED IARARM_PATH) - message(FATAL_ERROR "Please set IARARM_PATH to the root directory of the IARARM installation. e.g. set(IARARM_PATH \"C:/Program Files (x86)/IAR Systems/Embedded Workbench ${MY_VERSION}\")") - endif() - - STRING(REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1.\\2" _MY_MAJOR_MINOR "${MY_VERSION}") - STRING(REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1.\\2" _IARARM_MAJOR_MINOR "${IARARM_VER}") - - #Check iccarm version. - if (NOT "${_MY_MAJOR_MINOR}" VERSION_EQUAL "${_IARARM_MAJOR_MINOR}") - message(FATAL_ERROR "IARARM version (IARARM_VER=${IARARM_VER}) does not match ${MY_VERSION}") - endif() - - if (NOT DEFINED ARM_CPU_ARCHITECTURE AND NOT DEFINED ARM_CPU_TYPE) - message(FATAL_ERROR "ARM_CPU_TYPE and ARM_CPU_ARCHITECTURE is not defined! Please include the CPU specific config file before this one.") - endif() - -endfunction() - -message(STATUS "Using IARARM compiler package v${IARARM_VER} from ${IARARM_PATH}") - - -#Tell cmake which compiler we use -if (EXISTS "c:/") - set (CMAKE_C_COMPILER "${IARARM_PATH}/bin/iccarm.exe") - set (CMAKE_CXX_COMPILER "${IARARM_PATH}/bin/iccarm.exe") - set (CMAKE_ASM_COMPILER "${IARARM_PATH}/bin/iasmarm.exe") -else() - set (CMAKE_C_COMPILER "${IARARM_PATH}/bin/iccarm") - set (CMAKE_CXX_COMPILER "${IARARM_PATH}/bin/iccarm") - set (CMAKE_ASM_COMPILER "${IARARM_PATH}/bin/iasmarm") -endif() - -if("CXX" IN_LIST languages) - set(CMAKE_CXX_COMPILER_ID "IARARM" CACHE INTERNAL "CXX compiler ID" FORCE) - include(Compiler/IARARM-CXX) -endif() - -if("C" IN_LIST languages) - set(CMAKE_C_COMPILER_ID "IARARM" CACHE INTERNAL "C compiler ID" FORCE) - include(Compiler/IARARM-C) -endif() - -function(compiler_get_preinclude_option_string INCLUDE RES) - set(${RES} "--preinclude ${INCLUDE}" PARENT_SCOPE) -endfunction() - -function(compiler_set_preinclude_file) - #Option (on/off) arguments. - set( _OPTIONS_ARGS GLOBAL) - #Single option arguments. - set( _ONE_VALUE_ARGS INCLUDE) - #List arguments - set( _MULTI_VALUE_ARGS TARGETS FILES) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - if(NOT DEFINED _MY_PARAMS) - message(FATAL_ERROR "compiler_set_preinclude_file: missing mandatory parameter INCLUDE.") - endif() - compiler_get_preinclude_option_string(${INCLUDE} _OPTION_STRING) - #If include is to be set globally, we ignore TARGETS and FILES - if(_MY_PARAMS_GLOBAL) - set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_OPTIONS "${_OPTION_STRING}") - else() - #If GLOBAL was not passed, then either TARGETS or FILES must be present - if(NOT DEFINED _MY_PARAM_TARGETS AND NOT DEFINED _MY_PARAM_FILES) - message(FATAL_ERROR "compiler_set_preinclude_file: missing mandatory parameter. Either TARGETS and/or FILES must be specified.") - endif() - #Iterate over targets. Note: call embedded_set_target_compile_flags to - #allow the target to be defined after this function call. This helps - #modularisation - foreach(_TGT IN_LISTS _MY_PARAM_TARGETS) - embedded_set_target_compile_flags(TARGET ${_TGT} LANGUAGE "C" FLAGS "${_OPTION_STRING}") - endforeach() - #Iterate over files - foreach(_FILE IN_LISTS _MY_PARAM_FILES) - set_property(FILE ${_FILE} APPEND PROPERTY COMPILE_OPTIONS "${_OPTION_STRING}") - endforeach() - endif() -endfunction() - -function(compiler_set_linkercmdfile) - set( _OPTIONS_ARGS ) #Option (on/off) arguments. - set( _ONE_VALUE_ARGS TARGET PATH) #Single option arguments. - set( _MULTI_VALUE_ARGS DEFINES INCLUDES) #List arguments - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_TARGET) - message(FATAL_ERROR "compiler_set_linkercmdfile: mandatory parameter 'TARGET' is missing.") - endif() - if (NOT TARGET ${_MY_PARAMS_TARGET}) - message(FATAL_ERROR "compiler_set_linkercmdfile: value of parameter 'TARGET' is invalid.") - endif() - - if(NOT _MY_PARAMS_PATH) - message(FATAL_ERROR "compiler_set_linkercmdfile: mandatory parameter 'PATH' is missing.") - endif() - set(_FILE_PATH ${_MY_PARAMS_PATH}) - - #Create additional target if linker script needs to be pre-processed. - if (_MY_PARAMS_DEFINES OR _MY_PARAMS_INCLUDES) - #Name of pre-processed linker script file. - set(FINAL_LD_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${_MY_PARAMS_TARGET}.icf.i") - #Name of the target doing the pre-processing - set(LD_PP_TARGET_NAME "${_MY_PARAMS_TARGET}_ldpp") - compiler_preprocess_file(SRC ${_MY_PARAMS_PATH} - DST ${FINAL_LD_FILE_NAME} - TARGET_PREFIX ${_MY_PARAMS_TARGET} - BEFORE_TARGET ${_MY_PARAMS_TARGET} - DEFINES ${_MY_PARAMS_DEFINES} - INCLUDES ${_MY_PARAMS_INCLUDES}) - - #Tell cmake to delete the intermediate linker script when the clean rule is executed. - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${FINAL_LD_FILE_NAME}") - #Set the path to linker script point to the intermediate file. - set(_FILE_PATH ${FINAL_LD_FILE_NAME}) - endif() - - #Note: the space before the option is important! - set_property(TARGET ${_MY_PARAMS_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${_FLAGS} --config=${_FILE_PATH}") - set_property(TARGET ${_MY_PARAMS_TARGET} APPEND PROPERTY LINK_DEPENDS ${_FILE_PATH}) - #Tell cmake .map files shall be removed when project is cleaned (make clean) - get_filename_component(_TARGET_BASE_NAME ${_MY_PARAMS_TARGET} NAME_WE) - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${_TARGET_BASE_NAME}.map") -endfunction() - -function(compiler_set_cmse_output TARGET FILE_PATH) - #Note: the space before the option is important! - set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " --import_cmse_lib_out=${FILE_PATH}") - #Tell cmake cmse output is a generated object file. - SET_SOURCE_FILES_PROPERTIES("${FILE_PATH}" PROPERTIES EXTERNAL_OBJECT true GENERATED true) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "" BYPRODUCTS ${FILE_PATH}) - #Tell cmake cmse output shall be removed by clean target. - get_directory_property(_ADDITIONAL_MAKE_CLEAN_FILES DIRECTORY "./" ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_ADDITIONAL_MAKE_CLEAN_FILES} ${FILE_PATH}") -endfunction() - -function(compiler_merge_library) - set( _OPTIONS_ARGS ) #Option (on/off) arguments. - set( _ONE_VALUE_ARGS DEST) #Single option arguments. - set( _MULTI_VALUE_ARGS LIBS) #List arguments - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT _MY_PARAMS_DEST) - message(FATAL_ERROR "compiler_merge_library: no destination target specified. Please see the DEST parameter.") - endif() - #Check if destination is a library - get_target_property(_tmp ${_MY_PARAMS_DEST} TYPE) - if(NOT "${_tmp}" STREQUAL "STATIC_LIBRARY") - message(FATAL_ERROR "compiler_merge_library: parameter DEST must be a static library target.") - endif() - set(_DEST ${_MY_PARAMS_DEST}) - - if(NOT _MY_PARAMS_LIBS) - message(FATAL_ERROR "compiler_merge_library: no source libraries specified. Please see the LIBS parameter.") - endif() - set(_LIBS ${_MY_PARAMS_LIBS}) - - ##Find the cmake script doing the merge. - find_file(_MERGE_SCRIPT "IARArMerge.cmake" PATHS ${CMAKE_MODULE_PATH} PATH_SUFFIXES Common NO_DEFAULT_PATH) - - #Now add a custom command for each source library to our custom target to - #merge into the destination. - foreach(SRC_LIB ${_LIBS}) - get_filename_component(_SRC_LIB_NAME "${SRC_LIB}" NAME) - add_custom_command(TARGET ${_DEST} POST_BUILD - COMMAND ${CMAKE_COMMAND} -DCMAKE_AR=${CMAKE_AR} -DSOURCE=${SRC_LIB} -DDESTINATION=$<TARGET_FILE:${_DEST}> -P ${_MERGE_SCRIPT} - COMMENT "\t\tmerging objects from ${_SRC_LIB_NAME}") - endforeach() -endfunction() - -function(compiler_generate_binary_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_IARARM_IELFTOOL} ARGS --silent --bin $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.bin) -endfunction() - -function(compiler_generate_hex_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_IARARM_IELFTOOL} ARGS --silent --ihex $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.hex) -endfunction() - -function(compiler_generate_elf_output TARGET) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_IARARM_IELFTOOL} ARGS --silent $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.elf) -endfunction() - -# Function for creating a new target that preprocesses a .c file -#INPUTS: -# SRC - (mandatory) - file to be preprocessed -# DST - (mandatory) - output file for the preprocessing -# TARGET_PREFIX - (optional) - prefix for the target that this function creates and which manages the preprocessing -# BEFORE_TARGET - (optional) - target which is dependent on the preprocessing target in the below function -# DEFINES - (optional) - additional command line switches from macro definitions for preprocessing -# INCLUDES - (optional) - additional command line switches from include paths for preprocessing -function(compiler_preprocess_file) - #Option (on/off) arguments. - set( _OPTIONS_ARGS) - #Single option arguments. - set( _ONE_VALUE_ARGS SRC DST TARGET_PREFIX BEFORE_TARGET) - #List arguments - set( _MULTI_VALUE_ARGS DEFINES INCLUDES) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check passed parameters - if(NOT DEFINED _MY_PARAMS_SRC) - message(FATAL_ERROR "compiler_preprocess_file: mandatory parameter 'SRC' is missing.") - endif() - - if(NOT DEFINED _MY_PARAMS_DST) - message(FATAL_ERROR "compiler_preprocess_file: mandatory parameter 'DST' is missing.") - endif() - - if(DEFINED _MY_PARAMS_BEFORE_TARGET) - if(NOT TARGET ${_MY_PARAMS_BEFORE_TARGET}) - message(FATAL_ERROR "compiler_preprocess_file: optional parameter 'BEFORE_TARGET' is not target.") - endif() - endif() - - #Compose additional command line switches from macro definitions. - set(_FLAGS "") - if (_MY_PARAMS_DEFINES) - foreach(_DEFINE IN LISTS _MY_PARAMS_DEFINES) - list(APPEND _FLAGS "-D${_DEFINE}") - endforeach() - endif() - - #Compose additional command line switches from include paths. - if (_MY_PARAMS_INCLUDES) - foreach(_INCLUDE IN LISTS _MY_PARAMS_INCLUDES) - list(APPEND _FLAGS "-I${_INCLUDE}") - endforeach() - endif() - - #The compiler flag might contain leading spaces which can fail the preprocess operation, these are removed - STRING(STRIP ${CMAKE_C_FLAGS_CPU} _MY_TEMP_CMAKE_C_FLAGS_CPU) - #If a string contains spaces, then it is inserted amongst quotation marks. Furthermore the compiler fails if it is - #called with multiple switches included in one quotation mark. If the extra spaces are replaced by semicolons, - #then the insertion will be advantageous for the compiler. - STRING(REPLACE " " ";" _MY_TEMP2_CMAKE_C_FLAGS_CPU ${_MY_TEMP_CMAKE_C_FLAGS_CPU}) - set(_LOCAL_CMAKE_C_FLAGS_CPU "") - foreach(_C_FLAG IN LISTS _MY_TEMP2_CMAKE_C_FLAGS_CPU) - list(APPEND _LOCAL_CMAKE_C_FLAGS_CPU "${_C_FLAG}") - endforeach() - - add_custom_command(OUTPUT ${_MY_PARAMS_DST} - COMMAND ${CMAKE_C_COMPILER} ${_LOCAL_CMAKE_C_FLAGS_CPU} ${_FLAGS} ${_MY_PARAMS_SRC} --silent --preprocess=ns ${_MY_PARAMS_DST} - DEPENDS ${_MY_PARAMS_SRC} - COMMENT "Preprocess the ${_MY_PARAMS_SRC} file" - ) - - set(_MY_TARGET_PREFIX "") - if(TARGET ${_MY_PARAMS_TARGET_PREFIX}) - set(_MY_TARGET_PREFIX "${_MY_PARAMS_TARGET_PREFIX}") - endif() - #The preprocessing related target name is obtained by indexing the file's name that is to be preprocessed - get_filename_component(_MY_FILENAME_TO_BE_INDEXED ${_MY_PARAMS_SRC} NAME_WE) - foreach(_SUFFIX RANGE 1 100) - if (NOT TARGET ${_MY_TARGET_PREFIX}_pp_${_MY_FILENAME_TO_BE_INDEXED}_${_SUFFIX}) - set(_PREPROCESS_TARGET_NAME "${_MY_TARGET_PREFIX}_pp_${_MY_FILENAME_TO_BE_INDEXED}_${_SUFFIX}") - break() - endif() - if (_SUFFIX EQUAL 100) - message(FATAL_ERROR "You have called 'compiler_preprocess_file' too many times (${_SUFFIX} function calls).") - endif() - endforeach() - - #Make the original target depend on the new one. - if(TARGET ${_MY_PARAMS_BEFORE_TARGET}) - add_custom_target(${_PREPROCESS_TARGET_NAME} DEPENDS ${_MY_PARAMS_DST}) - add_dependencies(${_MY_PARAMS_BEFORE_TARGET} ${_PREPROCESS_TARGET_NAME}) - else() - add_custom_target(${_PREPROCESS_TARGET_NAME} ALL DEPENDS ${_MY_PARAMS_DST}) - endif() -endfunction() diff --git a/cmake/Common/CpuArmv81mml.cmake b/cmake/Common/CpuArmv81mml.cmake deleted file mode 100644 index 024c7ef8fd..0000000000 --- a/cmake/Common/CpuArmv81mml.cmake +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -set(ARM_CPU_ARCHITECTURE "ARMv8.1-M.MAIN") diff --git a/cmake/Common/CpuM0p.cmake b/cmake/Common/CpuM0p.cmake deleted file mode 100644 index b6d1ceade7..0000000000 --- a/cmake/Common/CpuM0p.cmake +++ /dev/null @@ -1,15 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file gathers Cortex-M0p specific settings which control the build system. - -#If Armv6-M architecture type is specified here, the compiler cmake files will -#set generic Armv6-M CPU type flags as building options directly, instead of the -#dedicated ones for Cortex-M0plus. It may break building on Cortex-M0plus. Thus -#skip the setting of architecture type and leave it to compiler cmake files. - -set(ARM_CPU_TYPE "Cortex-M0p") diff --git a/cmake/Common/CpuM23.cmake b/cmake/Common/CpuM23.cmake deleted file mode 100644 index d903e0cbb1..0000000000 --- a/cmake/Common/CpuM23.cmake +++ /dev/null @@ -1,11 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file gatrhers Cortex-M23 specific settings which control the build system. -set(ARM_CPU_ARCHITECTURE "ARMv8-M.BASE") - -set(ARM_CPU_TYPE "Cortex-M23") diff --git a/cmake/Common/CpuM33.cmake b/cmake/Common/CpuM33.cmake deleted file mode 100644 index 646b98e520..0000000000 --- a/cmake/Common/CpuM33.cmake +++ /dev/null @@ -1,11 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file gathers Cortex-M33 specific settings which control the build system. -set(ARM_CPU_ARCHITECTURE "ARMv8-M.MAIN") - -set(ARM_CPU_TYPE "Cortex-M33") diff --git a/cmake/Common/CpuM4.cmake b/cmake/Common/CpuM4.cmake deleted file mode 100644 index 92b3c0af8d..0000000000 --- a/cmake/Common/CpuM4.cmake +++ /dev/null @@ -1,15 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#This file gathers Cortex-M4 specific settings which control the build system. - -#If Armv7-M architecture type is specified here, the compiler cmake files will -#set generic Armv7-M CPU type flags as building options directly, instead of the -#dedicated ones for Cortex-M4. It may break building on Cortex-M4. Thus skip the -#setting of architecture type and leave it to compiler cmake files. - -set(ARM_CPU_TYPE "Cortex-M4") diff --git a/cmake/Common/FindArmClang.cmake b/cmake/Common/FindArmClang.cmake deleted file mode 100644 index 08d743e88a..0000000000 --- a/cmake/Common/FindArmClang.cmake +++ /dev/null @@ -1,116 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Find the location of the ARMClang C/C++ compiler. -# -# Find armclang on the specified location or on the PATH and optionally validate its version. -# -#Inputs: -# ARMCLANG_PATH - (optional)- install path of armclang compiler to use. If not set the -# compiler on the PATH is used. -# ARMCLANG_VER - (optional)- version number. If set the module will validate the compiler version. -# -#outputs: -# ARMCLANG_PATH - will be set to the root directory of the compiler. Only set if undefined. -# ARMCLANG_VER - will be set to the version number found. Only set if undefined. -# ARMCLANG_MODULE - set to the name of the cmake module to be included for this ARMClang version. -# - -#Include some dependencies -Include(Common/Utils) - -#Get the version of armasm. -# -# Execute armasm and extract its version number for its output. -# -#Exmaples: -# Get the version reported by armasm at location c:/foo/bin/armasm to variable VER -# get_armasm_version(ARMASM "c:/foo/bin/armasm" RES VER) -# -#INPUTS: -# ARMASM - (mandatory) - armasm executable -# RES - (mandatory) - variable name to put result to -# -#OUTPUTS -# The variable named after "RES" will be set to the version number matches -# -function(get_armasm_version) - #Parse our arguments - set( _OPTIONS_ARGS ) #No option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS ARMASM RES) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS ) #One list argument (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check mandatory parameters - if(NOT _MY_PARAMS_RES) - message (FATAL_ERROR "get_armasm_version(): Missing result parameter!") - endif() - set (_RES ${_MY_PARAMS_RES}) - - if(NOT _MY_PARAMS_ARMASM) - message (FATAL_ERROR "get_armasm_version(): Missing ARMASM parameter!") - endif() - set (_ARMASM ${_MY_PARAMS_ARMASM}) - - #Call specified executable - execute_process(COMMAND "${_ARMASM}" - OUTPUT_VARIABLE _OUTPUT - ERROR_VARIABLE _OUTPUT - ) - #Cut off version number. Just the numbers ignore anything after. - STRING(REGEX REPLACE ".*ARM Compiler (([0-9]+\.)+[0-9]+).*" "\\1" _VER "${_OUTPUT}") - - if (NOT _VER) - message (FATAL_ERROR "get_armasm_version(): Failed to extract version number from armasm output.") - endif() - - set(${_RES} ${_VER} PARENT_SCOPE) -endfunction() - -#If the install location needs to be found. -if(NOT DEFINED ARMCLANG_PATH) - #Set ARMCLANG_PATH to default value. - set (ARMCLANG_PATH "ARMCLANG_PATH-NOTFOUND") - - #First check if armclang is on the PATH - #find_program puts() its output to the cmake cache. We don't want that, so we use a local variable, which - #is unset later. - find_program ( - _ARMCLANG_PATH - armclang - PATHS env PATH - DOC "ARMCLANG compiler location." - ) - - #Yes, check the version number if it is specified. - if(_ARMCLANG_PATH STREQUAL "_ARMCLANG_PATH-NOTFOUND") - message (FATAL_ERROR "armclang install location is unset. Either put armclang on the PATH or set ARMCLANG_PATH.") - endif() - - #Cut off executable name directory name to get install location. - STRING(REGEX REPLACE "(.*)/bin/armclang.*" "\\1" ARMCLANG_PATH "${_ARMCLANG_PATH}") - - #Remove unwanted junk from CMake cache. - unset(_ARMCLANG_PATH CACHE) -endif() - -get_armasm_version(ARMASM "${ARMCLANG_PATH}/bin/armasm" RES _VER) - -#Check the version if needed -if(NOT DEFINED ARMCLANG_VER) - set(ARMCLANG_VER ${_VER}) -endif() - -if(NOT "${ARMCLANG_VER}" VERSION_EQUAL "${_VER}") - message (FATAL_ERROR "FindArmClang.cmake: armclang compiler version ${_VER} does not match ${ARMCLANG_VER}.") -endif() - -STRING(REGEX REPLACE "([0-9]+)\.([0-9]+)(\.[0-9]+)*.*" "CompilerArmClang\\1\\2" ARMCLANG_MODULE "${ARMCLANG_VER}") - -if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${ARMCLANG_MODULE}.cmake") - message(FATAL_ERROR "ERROR: Unsupported ARMCLANG compiler version found on PATH.") -endif() diff --git a/cmake/Common/FindGNUARM.cmake b/cmake/Common/FindGNUARM.cmake deleted file mode 100644 index d178716606..0000000000 --- a/cmake/Common/FindGNUARM.cmake +++ /dev/null @@ -1,157 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Find the location of the GNUARM C/C++ compiler. -# -# Find gnuarm on the specified location or on the PATH and optionally validate -# its version. -# -#Inputs: -# GNUARM_PATH - (optional)- install path of GNUARM compiler to use. If not set -# the compiler on the PATH is used. -# GNUARM_VER - (optional)- version number. If set the module will validate -# the compiler version. -# GNUARM_PREFIX (optional)- execute prefix for toolchain, allow for vendor -# toolchains, default to arm-none-eabi -# -#outputs: -# GNUARM_PATH - will be set to the root directory of the compiler. Only set -# if undefined. -# GNUARM_VER - will be set to the version number found. Only set if -# undefined. -# GNUARM_MODULE - set to the name of the cmake module to be included for this -# GNUARM version. -# - -#Include some dependencies -Include(Common/Utils) - -if(NOT DEFINED GNUARM_PREFIX) - set(GNUARM_PREFIX "arm-none-eabi") -endif() -set(_GCC_BINARY_NAME "${GNUARM_PREFIX}-gcc") - -#Get the version of armgcc. -# -# Execute gcc and extract the version number for its output. -# -#Examples: -# Get the version reported by gcc at location c:/foo/bin/ to -# variable VER get_armgcc_version(GCC "c:/foo/bin/arm-none-eabi-gcc" RES VER) -# -#INPUTS: -# GCC - (mandatory) - gcc executable -# RES - (mandatory) - variable name to put result to -# -#OUTPUTS -# The variable named after "RES" will be set to the version number -# -function(get_armgcc_version) - ###Parse our arguments - #No option (on/off) arguments (e.g. IGNORE_CASE) - set( _OPTIONS_ARGS ) - #Single option arguments (e.g. PATH "./foo/bar") - set( _ONE_VALUE_ARGS GCC RES) - #List arguments (e.g. LANGUAGES C ASM CXX) - set( _MULTI_VALUE_ARGS ) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" - "${_ONE_VALUE_ARGS}" - "${_MULTI_VALUE_ARGS}" - ${ARGN} ) - - #Check mandatory parameters - if(NOT _MY_PARAMS_RES) - message (FATAL_ERROR "get_armgcc_version(): Missing result parameter!") - endif() - set (_RES ${_MY_PARAMS_RES}) - - if(NOT _MY_PARAMS_GCC) - message (FATAL_ERROR "get_armgcc_version(): Missing GCC parameter!") - endif() - set (_GCC ${_MY_PARAMS_GCC}) - - #Call specified executable - execute_process(COMMAND "${_GCC}" -v - OUTPUT_VARIABLE _OUTPUT - ERROR_VARIABLE _OUTPUT - ) - #Cut off version number. Just the numbers ignore anything after. - STRING(REGEX REPLACE ".*gcc version ([0-9.]+) .*" "\\1" _VER "${_OUTPUT}") - - if (NOT _VER) - string(CONCAT _msg "get_armgcc_version(): Failed to extract version" - " number from ${_GCC_BINARY_NAME} output.") - message (FATAL_ERROR "${_msg}") - endif() - - set(${_RES} ${_VER} PARENT_SCOPE) -endfunction() - -#Check if the executable is present -if(NOT DEFINED GNUARM_PATH) - #If the location is not set, try to find executable on PATH. - #Set GNUARM_PATH to default value. - set (GNUARM_PATH "GNUARM_PATH-NOTFOUND") - - #First check if gcc is on the PATH - #find_program puts() its output to the cmake cache. We don't want that, so - # we use a local variable, which is unset later. - find_program ( - _GNUARM_PATH - ${_GCC_BINARY_NAME} - PATHS env PATH - DOC "GNUARM compiler location." - ) -else() - #Check executable is available on the specified path. - #find_program puts() its output to the cmake cache. We don't want that, so - # we use a local variable, which is unset later. - find_program ( - _GNUARM_PATH - ${_GCC_BINARY_NAME} - PATHS ${GNUARM_PATH}/bin NO_DEFAULT_PATH - DOC "GNUARM compiler location." - ) -endif() - -#Is executable present? -if(_GNUARM_PATH STREQUAL "_GNUARM_PATH-NOTFOUND") - string(CONCAT _msg "${_GCC_BINARY_NAME} can not be found. Either put" - " ${_GCC_BINARY_NAME} on the PATH or set GNUARM_PATH" - " properly.") - message (FATAL_ERROR ${_msg}) -endif() - -#Cut off executable and directory name to get install location. -STRING(REGEX REPLACE "(.*)/bin/${_GCC_BINARY_NAME}.*" - "\\1" GNUARM_PATH "${_GNUARM_PATH}") - -#Remove unwanted junk from CMake cache. -unset(_GNUARM_PATH CACHE) - -get_armgcc_version(GCC "${GNUARM_PATH}/bin/${_GCC_BINARY_NAME}" RES _VER) - -#Check the version if needed -if(NOT DEFINED GNUARM_VER) - set(GNUARM_VER ${_VER}) -endif() - -if(NOT "${GNUARM_VER}" VERSION_EQUAL "${_VER}") - string(CONCAT _msg "FindGNUARM.cmake: ${_GCC_BINARY_NAME} compiler version" - " ${_VER} does not match ${GNUARM_VER}.") - message (FATAL_ERROR "${_msg}") -endif() - - -STRING(REGEX REPLACE "([0-9]+)\.([0-9]+)(\.[0-9]+)*.*" "CompilerGNUARM\\1\\2" - GNUARM_MODULE "${GNUARM_VER}") - -if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${GNUARM_MODULE}.cmake") - string(CONCAT _msg "ERROR: Unsupported GNUARM compiler version found on" - " PATH.") - message(FATAL_ERROR "${_msg}") -endif() diff --git a/cmake/Common/FindIARARM.cmake b/cmake/Common/FindIARARM.cmake deleted file mode 100644 index 4ace90b4c7..0000000000 --- a/cmake/Common/FindIARARM.cmake +++ /dev/null @@ -1,118 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Find the location of the IAR C/C++ compiler. -# -# Find iccarm on the specified location or on the PATH and optionally validate its version. -# -#Inputs: -# IARARM_PATH - (optional)- install path of iccarm compiler to use. If not set the -# compiler on the PATH is used. -# IARARM_VER - (optional)- version number. If set the module will validate the compiler version. -# -#outputs: -# IARARM_PATH - will be set to the root directory of the compiler. Only set if undefined. -# IARARM_VER - will be set to the version number found. Only set if undefined. -# IARARM_MODULE - set to the name of the cmake module to be included for this iccarm version. -# - -#Include some dependencies -Include(Common/Utils) - -#Get the version of iccarm. -# -# Execute iccarm and extract its version number for its output. -# -#Exmaples: -# Get the version reported by iccarm at location c:/foo/bin/iccarm to variable VER -# get_iccarm_version(ICCARM "c:/foo/bin/iccarm" RES VER) -# -#INPUTS: -# ICCARM - (mandatory) - iccarm executable -# RES - (mandatory) - variable name to put result to -# -#OUTPUTS -# The variable named after "RES" will be set to the version number matches -# -function(get_iccarm_version) - #Parse our arguments - set( _OPTIONS_ARGS ) #No option (on/off) arguments (e.g. IGNORE_CASE) - set( _ONE_VALUE_ARGS ICCARM RES) #Single option arguments (e.g. PATH "./foo/bar") - set( _MULTI_VALUE_ARGS ) #One list argument (e.g. LANGUAGES C ASM CXX) - cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) - - #Check mandatory parameters - if(NOT _MY_PARAMS_RES) - message (FATAL_ERROR "get_iccarm_version(): Missing result parameter!") - endif() - set (_RES ${_MY_PARAMS_RES}) - - if(NOT _MY_PARAMS_ICCARM) - message (FATAL_ERROR "get_iccarm_version(): Missing ICCARM parameter!") - endif() - set (_ICCARM ${_MY_PARAMS_ICCARM}) - - #Call specified executable - execute_process(COMMAND "${_ICCARM}" --version - OUTPUT_VARIABLE _OUTPUT - ERROR_VARIABLE _OUTPUT - ) - #Cut off version number. Just the numbers ignore anything after. - STRING(REGEX REPLACE "IAR.* Compiler V(([0-9]+\.)+[0-9]+).*" "\\1" _VER "${_OUTPUT}") - - if (NOT _VER) - message (FATAL_ERROR "get_iccarm_version(): Failed to extract version number from iccarm output.") - endif() - - set(${_RES} ${_VER} PARENT_SCOPE) -endfunction() - -#If the install location needs to be found. -if(NOT DEFINED IARARM_PATH) - #Set IARARM_PATH to default value. - set (IARARM_PATH "IARARM_PATH-NOTFOUND") - - #First check if iccarm is on the PATH - #find_program puts() its output to the cmake cache. We don't want that, so we use a local variable, which - #is unset later. - find_program ( - _IARARM_PATH - iccarm - PATHS env PATH - DOC "IARARM compiler location." - ) - - #Yes, check the version number if it is specified. - if(_IARARM_PATH STREQUAL "_IARARM_PATH-NOTFOUND") - message (FATAL_ERROR "iccarm install location is unset. Either put iccarm on the PATH or set IARARM_PATH.") - endif() - - #Cut off executable name directory name to get install location. - STRING(REGEX REPLACE "(.*)/bin/iccarm.*" "\\1" IARARM_PATH "${_IARARM_PATH}") - - #Remove unwanted junk from CMake cache. - unset(_IARARM_PATH CACHE) -endif() - -get_iccarm_version(ICCARM "${IARARM_PATH}/bin/iccarm" RES _VER) - -#Check the version if needed -if(NOT DEFINED IARARM_VER) - set(IARARM_VER ${_VER}) -endif() - -if(NOT "${IARARM_VER}" VERSION_EQUAL "${_VER}") - message (FATAL_ERROR "FindIARArm.cmake: iccarm compiler version ${_VER} does not match ${IARARM_VER}.") -endif() - -STRING(REGEX REPLACE "([0-9]+)\.([0-9]+)(\.[0-9]+)*.*" "CompilerIarArm\\1\\2" IARARM_MODULE "${IARARM_VER}") - -message(STATUS "Version: ${IARARM_VER}/${IARARM_MODULE}") - -if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${IARARM_MODULE}.cmake") - message(FATAL_ERROR "ERROR: Unsupported IARARM compiler version found on PATH.") -endif() diff --git a/cmake/Common/GNUArMerge.cmake b/cmake/Common/GNUArMerge.cmake deleted file mode 100644 index 8631e6c7a1..0000000000 --- a/cmake/Common/GNUArMerge.cmake +++ /dev/null @@ -1,120 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#A cmake script to merge two archives using GNU AR. -# -# The script will first run AR to get the list of files in the source archive. -# Then each file is: -# -extracted -# -added to the target archive -# -deleted -# -# The loop is needed to avoid losing files with matching name in the source -# archive. -# The destination archive is updated in a way not to overwrite existing files -# with matching names. -# -#Examples: -# cmake -DCMAKE_AR=arm-none-eabi-ar -DDESTINATION=new_lib.a -DSOURCE=/foo/bar/old_lib.a -P ./GNUArMerge.cmake -# -#Parameters: -# SOURCE - archive file to copy all members from -# DESTINATION - archive file to copy members to. If file exists, then new -# members are added without overwriting existing ones. -# CMAKE_AR - GNU AR executable -# - -#Execute AR and capture its output -# -# Script execution will stop with a fatal error if AR execution fails. -# -#Examples: -# List content of archive: -# run_ar(RESULT t /foo/bar/my_lib.a) -# Add object file to archive -# run_ar(RESULT q /foo/bar/my_lib.a new_obj.o) -# -#INPUTS: -# RESULT - (mandatory) - name of variable to put result in -# All remaining parameters will be command line options to AR -# -#OUTPUTS -# RESULT - text output of AR command -# -function(run_ar OUTPUT ) - execute_process(COMMAND ${CMAKE_AR} ${ARGN} - TIMEOUT 120 - OUTPUT_VARIABLE _RES - RESULT_VARIABLE _STATUS_CODE - OUTPUT_STRIP_TRAILING_WHITESPACE) - - if (STATUS_CODE GREATER 0) - message(FATAL_ERROR "ERROR: Failed to execute \"${CMAKE_AR} ${ARGN}\".") - endif() - set(${OUTPUT} ${_RES} PARENT_SCOPE) -endfunction() - -#Delete a file -# -# Function to delete a file. No error will be reported if file is missing. -# Script execution will stop with a fatal error if AR execution fails. -# -#Examples: -# rm(/foo/bar/my_lib.a) -# -#INPUTS: -# FILE - path to file to delete -# -#OUTPUTS -# N/A -# -function(rm FILE) - execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${FILE} - RESULT_VARIABLE _STATUS_CODE - TIMEOUT 120) - if (STATUS_CODE GREATER 0) - message(FATAL_ERROR "ERROR: Failed to execute \"${CMAKE_COMMAND} -E remove ${FILE}\".") - endif() -endfunction() - - -############################################################################# -# Entry point -############################################################################# -#Verify input variables. - -if(NOT DEFINED SOURCE) - message(FATAL_ERROR "GNUArMerge.cmake: Variable SOURCE is not defined.") -endif() - -if(NOT DEFINED DESTINATION) - message(FATAL_ERROR "GNUArMerge.cmake: Variable DESTINATION is not defined.") -endif() - -if(NOT DEFINED CMAKE_AR) - message(FATAL_ERROR "GNUArMerge.cmake: Variable CMAKE_AR is not defined.") -endif() - - -#Get list of archive members -run_ar("OBJ_LIST" t ${SOURCE}) - -#Convert AR output to cmake list -string(REPLACE "\n" ";" OBJ_LIST ${OBJ_LIST}) - -#Iterate over member list. -foreach(OBJ ${OBJ_LIST}) - #Extract member - run_ar("_DUMMY" x ${SOURCE} ${OBJ}) - #Add member to destination archive - run_ar("_DUMMY" q ${DESTINATION} ${OBJ}) - #Remove extracted member - rm("${OBJ}") -endforeach() - -#Update the symbol table -run_ar("_DUMMY" s ${DESTINATION}) diff --git a/cmake/Common/IARArMerge.cmake b/cmake/Common/IARArMerge.cmake deleted file mode 100644 index e9d19f98d9..0000000000 --- a/cmake/Common/IARArMerge.cmake +++ /dev/null @@ -1,117 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2020, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#A cmake script to merge two archives using IAR iarchive. -# -# The script will first run iarchive to get the list of files in the source archive. -# Then each file is: -# -extracted -# -added to the target archive -# -deleted -# -# The loop is needed to avoid losing files with matching name in the source -# archive. -# The destination archive is updated in a way not to overwrite existing files -# with matching names. -# -#Examples: -# cmake -DCMAKE_AR=iarchive -DDESTINATION=new_lib.a -DSOURCE=/foo/bar/old_lib.a -P ./IARArMerge.cmake -# -#Parameters: -# SOURCE - archive file to copy all members from -# DESTINATION - archive file to copy members to. If file exists, then new -# members are added without overwriting existing ones. -# CMAKE_AR - GNU AR executable -# - -#Execute AR and capture its output -# -# Script execution will stop with a fatal error if AR execution fails. -# -#Examples: -# List content of archive: -# run_ar(RESULT t /foo/bar/my_lib.a) -# Add object file to archive -# run_ar(RESULT q /foo/bar/my_lib.a new_obj.o) -# -#INPUTS: -# RESULT - (mandatory) - name of variable to put result in -# All remaining parameters will be command line options to AR -# -#OUTPUTS -# RESULT - text output of AR command -# -function(run_ar OUTPUT ) - execute_process(COMMAND ${CMAKE_AR} ${ARGN} - TIMEOUT 120 - OUTPUT_VARIABLE _RES - RESULT_VARIABLE _STATUS_CODE - OUTPUT_STRIP_TRAILING_WHITESPACE) - - if (STATUS_CODE GREATER 0) - message(FATAL_ERROR "ERROR: Failed to execute \"${CMAKE_AR} ${ARGN}\".") - endif() - set(${OUTPUT} ${_RES} PARENT_SCOPE) -endfunction() - -#Delete a file -# -# Function to delete a file. No error will be reported if file is missing. -# Script execution will stop with a fatal error if AR execution fails. -# -#Examples: -# rm(/foo/bar/my_lib.a) -# -#INPUTS: -# FILE - path to file to delete -# -#OUTPUTS -# N/A -# -function(rm FILE) - execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${FILE} - RESULT_VARIABLE _STATUS_CODE - TIMEOUT 120) - if (STATUS_CODE GREATER 0) - message(FATAL_ERROR "ERROR: Failed to execute \"${CMAKE_COMMAND} -E remove ${FILE}\".") - endif() -endfunction() - - -############################################################################# -# Entry point -############################################################################# -#Verify input variables. - -if(NOT DEFINED SOURCE) - message(FATAL_ERROR "GNUArMerge.cmake: Variable SOURCE is not defined.") -endif() - -if(NOT DEFINED DESTINATION) - message(FATAL_ERROR "GNUArMerge.cmake: Variable DESTINATION is not defined.") -endif() - -if(NOT DEFINED CMAKE_AR) - message(FATAL_ERROR "GNUArMerge.cmake: Variable CMAKE_AR is not defined.") -endif() - - -#Get list of archive members -run_ar("OBJ_LIST" -t ${SOURCE}) - -#Convert AR output to cmake list -string(REPLACE "\n" ";" OBJ_LIST ${OBJ_LIST}) - -#Iterate over member list. -foreach(OBJ ${OBJ_LIST}) - #Extract member - run_ar("_DUMMY" -x ${SOURCE} ${OBJ}) - #Add member to destination archive - run_ar("_DUMMY" -r ${DESTINATION} ${OBJ}) - #Remove extracted member - rm("${OBJ}") -endforeach() diff --git a/cmake/Common/MultiCore.cmake b/cmake/Common/MultiCore.cmake deleted file mode 100644 index 86e9d00dbd..0000000000 --- a/cmake/Common/MultiCore.cmake +++ /dev/null @@ -1,95 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -# This file provides functions to support multi-core building. -cmake_minimum_required(VERSION 3.7) - -# Platform specific cmake script calls this function to select and enable -# building configuration in mulit-core scenario -function(enable_multi_core_topology_config) - set(TFM_MULTI_CORE_TOPOLOGY ON PARENT_SCOPE) -endfunction(enable_multi_core_topology_config) - -# Enable multiple outstanding NS PSA Client calls feature. -# It requires the multi-core platform implement the configuration and support -# of the multiple outstanding NS PSA Client calls feature. -function(enable_multi_core_multi_client_call) - add_definitions(-DTFM_MULTI_CORE_MULTI_CLIENT_CALL) -endfunction(enable_multi_core_multi_client_call) - -# Platform specific cmake script calls this function to set secure core cpu type -# Argument CPU_TYPE_CMAKE represents the CMake file of the corresponding secure -# CPU type. -# CPU_TYPE_CMAKE value CMake file CPU type to be selected -# CpuM0p CpuM0p.cmake Cortex-M0+ -# CpuM4 CpuM4.cmake Cortex-M4 -# CpuM23 CpuM23.cmake Cortex-M23 -# CpuM33 CpuM33.cmake Cortex-M33 -# Other CPU types are not yet supported. -function(set_secure_cpu_type CPU_TYPE_CMAKE) - include("Common/${CPU_TYPE_CMAKE}") - - if (NOT DEFINED ARM_CPU_TYPE) - message(FATAL_ERROR "Error: Fail to set secure cpu type.") - else () - set(SECURE_ARM_CPU_TYPE ${ARM_CPU_TYPE} PARENT_SCOPE) - endif () -endfunction(set_secure_cpu_type) - -# Platform specific cmake script calls this function to set non-secure core cpu -# type -# Argument CPU_TYPE_CMAKE represents the CMake file of the corresponding -# non-secure CPU type. -# CPU_TYPE_CMAKE value CMake file CPU type to be selected -# CpuM0p CpuM0p.cmake Cortex-M0+ -# CpuM4 CpuM4.cmake Cortex-M4 -# CpuM23 CpuM23.cmake Cortex-M23 -# CpuM33 CpuM33.cmake Cortex-M33 -# Other CPU types are not yet supported. -function(set_ns_cpu_type CPU_TYPE_CMAKE) - include("Common/${CPU_TYPE_CMAKE}") - - if (NOT DEFINED ARM_CPU_TYPE) - message(FATAL_ERROR "Error: Fail to set non-secure cpu type.") - else () - set(NS_ARM_CPU_TYPE ${ARM_CPU_TYPE} PARENT_SCOPE) - endif () -endfunction(set_ns_cpu_type) - -# Platform specific cmake script calls this function to add platform specific -# secure definitions. -# Multiple definitions and options can be organized in argument PLATFORM_DEFS, -# separated by spaces: -# add_platform_secure_definitions(DEF1 DEF2=VAL DEF3) -# The `-D` option flag before preprocessor macros should be skipped. -function(add_platform_secure_definitions PLATFORM_DEFS) - # Check if the same definition is already set - string(FIND TFM_PLATFORM_SECURE_DEFS PLATFORM_DEFS find_output) - - if (find_output EQUAL -1) - # Not set yet. Add it into secure definition list. - set(TFM_PLATFORM_SECURE_DEFS ${TFM_PLATFORM_SECURE_DEFS} - ${PLATFORM_DEFS} - PARENT_SCOPE) - endif () -endfunction(add_platform_secure_definitions) - -function(select_arm_cpu_type BUILD_IN_SPE_FLAG) - if (BUILD_IN_SPE_FLAG) - if (NOT DEFINED SECURE_ARM_CPU_TYPE) - message(FATAL_ERROR "Error: cannot find definition of SECURE_ARM_CPU_TYPE") - else () - set(ARM_CPU_TYPE ${SECURE_ARM_CPU_TYPE} PARENT_SCOPE) - endif () - else () - if (NOT DEFINED NS_ARM_CPU_TYPE) - message(FATAL_ERROR "Error: cannot find definition of NS_ARM_CPU_TYPE") - else () - set(ARM_CPU_TYPE ${NS_ARM_CPU_TYPE} PARENT_SCOPE) - endif () - endif () -endfunction(select_arm_cpu_type) diff --git a/cmake/Compiler/ARMCC-ASM.cmake b/cmake/Compiler/ARMCC-ASM.cmake deleted file mode 100644 index 450041fce2..0000000000 --- a/cmake/Compiler/ARMCC-ASM.cmake +++ /dev/null @@ -1,45 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -if(_ARMASM_CMAKE_LOADED) - return() -endif() -set(_ARMASM_CMAKE_LOADED TRUE) - -get_filename_component(_CMAKE_ASM_TOOLCHAIN_LOCATION "${CMAKE_ASM_COMPILER}" PATH) - -set(CMAKE_EXECUTABLE_SUFFIX ".axf") - -find_program(CMAKE_ARMCCLANG_LINKER armlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) -find_program(CMAKE_ARMCCLANG_AR armar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) -find_program(CMAKE_ARMCCLANG_FROMELF fromelf HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) - -set(CMAKE_LINKER "${CMAKE_ARMCCLANG_LINKER}" CACHE FILEPATH "The ARMCC linker" FORCE) -mark_as_advanced(CMAKE_ARMCCLANG_LINKER) -set(CMAKE_AR "${CMAKE_ARMCCLANG_AR}" CACHE FILEPATH "The ARMCC archiver" FORCE) -mark_as_advanced(CMAKE_ARMCCLANG_AR) - -macro(__compiler_armcc_asm) - set(lang "ASM") - if(NOT CMAKE_${lang}_FLAGS_SET) - set(CMAKE_${lang}_FLAGS_SET TRUE) - string(APPEND CMAKE_${lang}_FLAGS_INIT " ") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g") - - set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") - set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) - set(CMAKE_STATIC_LIBRARY_PREFIX_${lang} "") - set(CMAKE_STATIC_LIBRARY_SUFFIX_${lang} ".a") - - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map") - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") - - set(CMAKE_DEPFILE_FLAGS_${lang} "--depend=<DEPFILE> --depend_format=unix_quoted") - endif() -endmacro() -__compiler_armcc_asm() diff --git a/cmake/Compiler/ARMClang-ASM.cmake b/cmake/Compiler/ARMClang-ASM.cmake deleted file mode 100644 index 576a2b31c3..0000000000 --- a/cmake/Compiler/ARMClang-ASM.cmake +++ /dev/null @@ -1,10 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -include(Compiler/ARMClang) -set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) -__compiler_armclang(ASM) diff --git a/cmake/Compiler/ARMClang-C.cmake b/cmake/Compiler/ARMClang-C.cmake deleted file mode 100644 index fc3947ba1d..0000000000 --- a/cmake/Compiler/ARMClang-C.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -include(Compiler/ARMClang) -__compiler_armclang(C) diff --git a/cmake/Compiler/ARMClang-CXX.cmake b/cmake/Compiler/ARMClang-CXX.cmake deleted file mode 100644 index bf336fd2d9..0000000000 --- a/cmake/Compiler/ARMClang-CXX.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -include(Compiler/ARMClang) -__compiler_armclang(CXX) diff --git a/cmake/Compiler/ARMClang.cmake b/cmake/Compiler/ARMClang.cmake deleted file mode 100644 index 0e6f9418c4..0000000000 --- a/cmake/Compiler/ARMClang.cmake +++ /dev/null @@ -1,56 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -if(_ARMCCLANG_CMAKE_LOADED) - return() -endif() -set(_ARMCCLANG_CMAKE_LOADED TRUE) - -get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) -get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) - -set(CMAKE_EXECUTABLE_SUFFIX ".axf") - -find_program(CMAKE_ARMCCLANG_LINKER armlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) -find_program(CMAKE_ARMCCLANG_AR armar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) -find_program(CMAKE_ARMCCLANG_FROMELF fromelf HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) - -set(CMAKE_LINKER "${CMAKE_ARMCCLANG_LINKER}" CACHE FILEPATH "The ARMCC linker" FORCE) -mark_as_advanced(CMAKE_ARMCCLANG_LINKER) -set(CMAKE_AR "${CMAKE_ARMCCLANG_AR}" CACHE FILEPATH "The ARMCC archiver" FORCE) -mark_as_advanced(CMAKE_ARMCCLANG_AR) - -if(NOT DEFINED BUILD_DWARF_VERSION) - set(BUILD_DWARF_VERSION "") -else() - string(CONCAT BUILD_DWARF_VERSION "dwarf-" ${BUILD_DWARF_VERSION}) -endif() - -macro(__compiler_armclang lang) - if(NOT CMAKE_${lang}_FLAGS_SET) - set(CMAKE_${lang}_FLAGS_SET TRUE) - string(APPEND CMAKE_${lang}_FLAGS_INIT " ") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g${BUILD_DWARF_VERSION} -O0") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Oz -DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -g${BUILD_DWARF_VERSION} -DNDEBUG") - - set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") - set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) - set(CMAKE_STATIC_LIBRARY_PREFIX_${lang} "") - set(CMAKE_STATIC_LIBRARY_SUFFIX_${lang} ".a") - - set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "--via=") - - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map") - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") - set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - - set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>") - endif() -endmacro() diff --git a/cmake/Compiler/GNUARM-ASM.cmake b/cmake/Compiler/GNUARM-ASM.cmake deleted file mode 100644 index bd28beb78e..0000000000 --- a/cmake/Compiler/GNUARM-ASM.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) -#No furhter configuration is needed to extend cmake's buit-in GCC support. diff --git a/cmake/Compiler/GNUARM-C.cmake b/cmake/Compiler/GNUARM-C.cmake deleted file mode 100644 index 8d692d03c9..0000000000 --- a/cmake/Compiler/GNUARM-C.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -include(Compiler/GNUARM) -__compiler_gnuarm(C) diff --git a/cmake/Compiler/GNUARM-CXX.cmake b/cmake/Compiler/GNUARM-CXX.cmake deleted file mode 100644 index 93ec32f765..0000000000 --- a/cmake/Compiler/GNUARM-CXX.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -include(Compiler/GNUARM) -__compiler_gnuarm(CXX) diff --git a/cmake/Compiler/GNUARM.cmake b/cmake/Compiler/GNUARM.cmake deleted file mode 100644 index 8fbd97bbb5..0000000000 --- a/cmake/Compiler/GNUARM.cmake +++ /dev/null @@ -1,62 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017-2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -if(_GNUARM_CMAKE_LOADED) - return() -endif() -set(_GNUARM_CMAKE_LOADED TRUE) - -get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) -get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) - -set(CMAKE_EXECUTABLE_SUFFIX ".axf") - -if(NOT DEFINED GNUARM_PREFIX) - get_filename_component(__c_bin ${CMAKE_C_COMPILER} NAME) - string(REPLACE "-gcc" "" GNUARM_PREFIX ${__c_bin}) - string(REPLACE ".exe" "" GNUARM_PREFIX ${GNUARM_PREFIX}) -endif() - -find_program(CMAKE_GNUARM_LINKER ${GNUARM_PREFIX}-gcc HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) -find_program(CMAKE_GNUARM_AR ${GNUARM_PREFIX}-ar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) -find_program(CMAKE_GNUARM_OBJCOPY ${GNUARM_PREFIX}-objcopy HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) - -set(CMAKE_LINKER "${CMAKE_GNUARM_LINKER}" CACHE FILEPATH "The GNUARM linker" FORCE) -mark_as_advanced(CMAKE_GNUARM_LINKER) -set(CMAKE_AR "${CMAKE_GNUARM_AR}" CACHE FILEPATH "The GNUARM archiver" FORCE) -mark_as_advanced(CMAKE_GNUARM_AR) - -if(NOT DEFINED BUILD_DWARF_VERSION) - set(BUILD_DWARF_VERSION "") -else() - string(CONCAT BUILD_DWARF_VERSION "dwarf-" ${BUILD_DWARF_VERSION}) -endif() - -macro(__compiler_gnuarm lang) - if(NOT CMAKE_${lang}_FLAGS_SET) - set(CMAKE_${lang}_FLAGS_SET TRUE) - string(APPEND CMAKE_${lang}_FLAGS_INIT " ") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g${BUILD_DWARF_VERSION} -O0") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -g${BUILD_DWARF_VERSION} -DNDEBUG") - - set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") - set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) - set(CMAKE_STATIC_LIBRARY_PREFIX_${lang} "") - set(CMAKE_STATIC_LIBRARY_SUFFIX_${lang} ".a") - - set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") - - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET> -Xlinker -Map=<TARGET_BASE>.map") - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> rsc <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") - set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - - set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>") - endif() -endmacro() diff --git a/cmake/Platform/Embedded.cmake b/cmake/Platform/Embedded.cmake deleted file mode 100644 index edc40e7d7c..0000000000 --- a/cmake/Platform/Embedded.cmake +++ /dev/null @@ -1,17 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2017, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -#------------------------------------------------------------------------------- - -#Force extension for object files to be '.o'. -set(CMAKE_C_OUTPUT_EXTENSION ".o" CACHE STRING "" FORCE) - -# Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX -# was initialized by the block below. This is useful for user -# projects to change the default prefix while still allowing the -# command line to override it. -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1) -endif() diff --git a/cmake/install.cmake b/cmake/install.cmake new file mode 100644 index 0000000000..73a2a7ef26 --- /dev/null +++ b/cmake/install.cmake @@ -0,0 +1,14 @@ +#------------------------------------------------------------------------------- +# Copyright (c) 2020, Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +#------------------------------------------------------------------------------- + +#Generate correct filename +string(TOUPPER ${TFM_PLATFORM} TFM_PLATFORM_UPPERCASE) +string(REGEX REPLACE "-" "_" TFM_PLATFORM_UPPERCASE_UNDERSCORE ${TFM_PLATFORM_UPPERCASE}) + +install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/ + DESTINATION ${CMAKE_BINARY_DIR}/install/outputs/${TFM_PLATFORM_UPPERCASE_UNDERSCORE} + ) diff --git a/cmake/set_extensions.cmake b/cmake/set_extensions.cmake new file mode 100644 index 0000000000..50db7c6113 --- /dev/null +++ b/cmake/set_extensions.cmake @@ -0,0 +1,12 @@ +#------------------------------------------------------------------------------- +# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +#------------------------------------------------------------------------------- + +set(CMAKE_C_OUTPUT_EXTENSION ".o") +set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1) + +set(CMAKE_ASM_OUTPUT_EXTENSION ".o") +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) |