CMake: Add CMake scripts

pull/13566/head
Hugues Kamba 2020-07-20 17:52:23 +01:00
parent f4e4012f81
commit 6dc5f5a582
33 changed files with 1665 additions and 0 deletions

41
CMakeLists.txt Normal file
View File

@ -0,0 +1,41 @@
# SPDX-License-Identifier: Apache-2.0
# This is not the application cmake, only boilerplate for Mbed OS
cmake_minimum_required(VERSION 3.13)
# Using relative paths behavior
if(POLICY CMP0076)
cmake_policy(SET CMP0076 NEW)
endif()
# Create Mbed OS library
add_library(mbed-os OBJECT)
# Include mbed.h and config from generate folder
target_include_directories(mbed-os PUBLIC .)
# Link config from generate folder
# TODO: @mbed-os-tools We need to get this gen_config somehow set up
target_link_libraries(mbed-os PRIVATE gen_config)
# Default build
add_subdirectory(cmsis)
add_subdirectory(components)
add_subdirectory(connectivity)
add_subdirectory(drivers)
add_subdirectory(events)
add_subdirectory(features)
add_subdirectory(hal)
add_subdirectory(platform)
add_subdirectory(rtos)
add_subdirectory(storage)
add_subdirectory(targets)
# Add additional component
get_property(component GLOBAL PROPERTY MBED_COMPONENT)
foreach(module ${component})
add_subdirectory(${module})
endforeach()

85
cmake/app.cmake Normal file
View File

@ -0,0 +1,85 @@
# SPDX-License-Identifier: Apache-2.0
include(.mbedbuild/mbed_config.cmake)
include(${MBED_ROOT}/cmake/toolchain.cmake)
include(${MBED_ROOT}/cmake/env.cmake)
include(${MBED_ROOT}/cmake/util.cmake)
include(${MBED_ROOT}/cmake/core.cmake)
include(${MBED_ROOT}/cmake/profile.cmake)
# if the environment does not specify build type, set to Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo"
CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
# Create application executable
add_executable(app)
# Include Mbed OS main cmake
add_subdirectory(mbed-os)
# Link the example libs
target_link_libraries(app mbed-os gen_config)
# I have to leave this here as linker is processed after mbed-os added, and can't be in toolchain.cmake
# as its global symbol is empty at that stage, this needs more work
# TODO: This property + pre/post should be moved
get_property(linkerfile GLOBAL PROPERTY MBED_TARGET_LINKER_FILE)
# TODO: get project name to inject into ld
# TODO: @mbed-os-tools this pre/post build commands should get details from target + profile
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
# I have to leave this here as linker is processed after mbed-os added, and can't be in toolchain.cmake
# as its global symbol is empty at that stage, this needs more work
# TODO: This property pre/post should be moved
set(CMAKE_PRE_BUILD_COMMAND
COMMAND "arm-none-eabi-cpp" -E -P
-Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r
-Wl,--wrap,_realloc_r -Wl,--wrap,_memalign_r -Wl,--wrap,_calloc_r
-Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
-DMBED_ROM_START=0x0 -DMBED_ROM_SIZE=0x100000 -DMBED_RAM_START=0x20000000
-DMBED_RAM_SIZE=0x30000 -DMBED_RAM1_START=0x1fff0000
-DMBED_RAM1_SIZE=0x10000 -DMBED_BOOT_STACK_SIZE=1024
-DXIP_ENABLE=0
${linkerfile} -o ${CMAKE_CURRENT_BINARY_DIR}/app.link_script.ld
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/app.link_script.ld"
)
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(CMAKE_PRE_BUILD_COMMAND COMMAND "")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --scatter=${linkerfile}")
endif()
# TODO: @mbed-os-tools this pre/post build commands should get details from target + profile
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(CMAKE_POST_BUILD_COMMAND
COMMAND ${ELF2BIN} -O binary $<TARGET_FILE:app> $<TARGET_FILE:app>.bin
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:app>.bin"
COMMAND ${ELF2BIN} -O ihex $<TARGET_FILE:app> $<TARGET_FILE:app>.hex
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:app>.hex"
)
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(CMAKE_POST_BUILD_COMMAND
COMMAND ${ELF2BIN} --bin -o $<TARGET_FILE:app>.bin $<TARGET_FILE:app>
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:app>.bin"
COMMAND ${ELF2BIN} --i32combined -o $<TARGET_FILE:app>.hex $<TARGET_FILE:app>
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:app>.hex"
)
elseif(MBED_TOOLCHAIN STREQUAL "IAR")
set(CMAKE_POST_BUILD_COMMAND
COMMAND ${ELF2BIN} --bin $<TARGET_FILE:app> $<TARGET_FILE:app>.bin
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:app>.bin"
COMMAND ${ELF2BIN} --ihex $<TARGET_FILE:app> $<TARGET_FILE:app>.hex
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:app>.hex"
)
endif()
# Custom pre/post build steps
add_custom_command(TARGET app PRE_LINK ${CMAKE_PRE_BUILD_COMMAND})
add_custom_command(TARGET app POST_BUILD ${CMAKE_POST_BUILD_COMMAND})

4
cmake/core.cmake Normal file
View File

@ -0,0 +1,4 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
include(${MBED_ROOT}/cmake/cores/${MBED_CPU_CORE}.cmake)

View File

@ -0,0 +1,58 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-a9)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb-interwork \
-marm \
-march=armv7-a \
-mfpu=vfpv3 \
-mfloat-abi=hard \
-mno-unaligned-access \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-A9 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_A9
-DARM_MATH_CA9
-D__FPU_PRESENT
-D__CMSIS_RTOS
-D__EVAL
-D__MBED_CMSIS_RTOS_CA9
)

View File

@ -0,0 +1,52 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mcpu=cortex-m0plus \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M0plus \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M0PLUS
-DARM_MATH_CM0PLUS
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,51 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m0)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M0 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M0
-DARM_MATH_CM0
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,51 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m1)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M1 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M3
-DARM_MATH_CM1
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,51 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m23)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M23 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M23
-DARM_MATH_ARMV8MBL
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,52 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m23)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M23 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M23
-DARM_MATH_ARMV8MBL
-DDOMAIN_NS=1
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,51 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m3)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M3 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M3
-DARM_MATH_CM3
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,52 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-march=armv8-m.main \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M33 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M33
-DARM_MATH_ARMV8MML
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,53 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-march=armv8-m.main \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M33 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M33
-DARM_MATH_ARMV8MML
-DDOMAIN_NS=1
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,55 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mfpu=fpv5-sp-d16 \
-mfloat-abi=softfp \
-march=armv8-m.main \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M33F \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M33
-DARM_MATH_ARMV8MML
-D__FPU_PRESENT=1U
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,56 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mfpu=fpv5-sp-d16 \
-mfloat-abi=softfp \
-march=armv8-m.main \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M33F \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M33
-DARM_MATH_ARMV8MML
-DDOMAIN_NS=1
-D__FPU_PRESENT=1U
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,56 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mfpu=fpv5-sp-d16 \
-mfloat-abi=softfp \
-march=armv8-m.main+dsp \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M33FE \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M33
-DARM_MATH_ARMV8MML
-D__FPU_PRESENT=1U
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
-D__DSP_PRESENT=1U
)

View File

@ -0,0 +1,57 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mfpu=fpv5-sp-d16 \
-mfloat-abi=softfp \
-march=armv8-m.main+dsp \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M33FE \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M33
-DARM_MATH_ARMV8MML
-DDOMAIN_NS=1
-D__FPU_PRESENT=1U
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
-D__DSP_PRESENT=1U
)

View File

@ -0,0 +1,52 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mcpu=cortex-m4 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M4 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M4
-DARM_MATH_CM4
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,55 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mcpu=cortex-m4 \
-mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M4.fp.sp \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M4
-DARM_MATH_CM4
-D__FPU_PRESENT=1
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,52 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m7)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mcpu=cortex-m7 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M7 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M7
-DARM_MATH_CM7
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,55 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m7)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mfpu=fpv5-sp-d16 \
-mfloat-abi=softfp \
-mcpu=cortex-m7 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M7.fp.sp \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M7
-DARM_MATH_CM7
-D__FPU_PRESENT=1
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

View File

@ -0,0 +1,55 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_SYSTEM_PROCESSOR cortex-m7)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(GCC_FLAGS " \
-mthumb \
-mfpu=fpv5-d16 \
-mfloat-abi=softfp \
-mcpu=cortex-m7 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${GCC_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${GCC_FLAGS} \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(ARM_FLAGS " \
--cpu=Cortex-M7.fp.dp \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${ARM_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${ARM_FLAGS} \
")
endif()
add_definitions(
-D__CORTEX_M7
-DARM_MATH_CM7
-D__FPU_PRESENT=1
-D__CMSIS_RTOS
-D__MBED_CMSIS_RTOS_CM
)

16
cmake/env.cmake Normal file
View File

@ -0,0 +1,16 @@
# SPDX-License-Identifier: Apache-2.0
# Compiler setup
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
# Project setup
enable_language(C CXX ASM)
# Enabled components within a project
# TODO: @mbed-os-tools This needs to come from tools
# If this is a list like rtos/wifi/networking, we need to figure out the path in Mbed OS (have dictionary or
# something similar). The best would be if this list contains list of module paths (rtos/ features/ble etc)
set_property(GLOBAL PROPERTY MBED_COMPONENTS "")

4
cmake/profile.cmake Normal file
View File

@ -0,0 +1,4 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
include(${MBED_ROOT}/cmake/profiles/${MBED_PROFILE}.cmake)

123
cmake/profiles/debug.cmake Normal file
View File

@ -0,0 +1,123 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(DEBUG_DEFINITIONS
-DMBED_DEBUG
-DMBED_TRAP_ERRORS_ENABLED=1
)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-c \
-g3 \
-std=gnu11 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-c \
-g3 \
-std=gnu++14 \
-fno-rtti \
-Wvla \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
-c \
-g3 \
-x assembler-with-cpp \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
-Wl,--gc-sections \
-Wl,--wrap,main \
-Wl,--wrap,_malloc_r \
-Wl,--wrap,_free_r \
-Wl,--wrap,_realloc_r \
-Wl,--wrap,_memalign_r \
-Wl,--wrap,_calloc_r \
-Wl,--wrap,exit \
-Wl,--wrap,atexit \
-Wl,-n \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-std=gnu11 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-fno-rtti \
-fno-c++-static-destructors \
-std=gnu++14 \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--verbose \
--remove \
--show_full_path \
--legacyalign \
--any_contingency \
--keep=os_cb_sections \
")
set(DEBUG_DEFINITIONS ${DEBUG_DEFINITIONS}
-D__ASSERT_MSG
-DMULADDC_CANNOT_USE_R7
)
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--md \
--no_depend_system_headers \
--c99 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--cpp11 \
--no_rtti \
--no_vla \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--show_full_path \
--any_contingency \
--keep=os_cb_sections \
")
set(DEBUG_DEFINITIONS ${DEBUG_DEFINITIONS}
-D__ASSERT_MSG
)
elseif(MBED_TOOLCHAIN STREQUAL "uARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--md \
--no_depend_system_headers \
--c99 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--cpp11 \
--no_rtti \
--no_vla \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--library_type=microlib \
")
set(DEBUG_DEFINITIONS ${DEBUG_DEFINITIONS}
-D__ASSERT_MSG
-DMBED_RTOS_SINGLE_THREAD
-D__MICROLIB
)
elseif(MBED_TOOLCHAIN STREQUAL "IAR")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--vla \
--diag_suppress=Pe546 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--guard_calls \
--no_static_destruction \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--skip_dynamic_initialization \
--threaded_lib \
")
endif()
add_definitions(${DEBUG_DEFINITIONS})

View File

@ -0,0 +1,120 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(DEVELOP_DEFINITIONS
-DMBED_TRAP_ERRORS_ENABLED=1
)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-c \
-std=gnu11 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-std=gnu++14 \
-fno-rtti \
-Wvla \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
-x assembler-with-cpp \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
-Wl,--gc-sections \
-Wl,--wrap,main \
-Wl,--wrap,_malloc_r \
-Wl,--wrap,_free_r \
-Wl,--wrap,_realloc_r \
-Wl,--wrap,_memalign_r \
-Wl,--wrap,_calloc_r \
-Wl,--wrap,exit \
-Wl,--wrap,atexit \
-Wl,-n \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS}
-std=gnu11
)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}
-fno-rtti
-fno-c++-static-destructors
-std=gnu++14
)
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS}
--show_full_path
--legacyalign
--inline
--any_contingency
--keep=os_cb_sections
)
set(DEVELOP_DEFINITIONS ${DEVELOP_DEFINITIONS}
-D__ASSERT_MSG
)
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS}
--md
--no_depend_system_headers
--c99
)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}
--cpp11
--no_rtti
--no_vla
)
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS}
--show_full_path
--any_contingency
--inline
--keep=os_cb_sections
)
set(DEVELOP_DEFINITIONS ${DEVELOP_DEFINITIONS}
-D__ASSERT_MSG
)
elseif(MBED_TOOLCHAIN STREQUAL "uARM")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS}
--md
--no_depend_system_headers
--c99
)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}
--cpp11
--no_rtti
--no_vla
)
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS}
--inline
--library_type=microlib
)
set(DEVELOP_DEFINITIONS ${DEVELOP_DEFINITIONS}
-D__ASSERT_MSG
-DMBED_RTOS_SINGLE_THREAD
)
elseif(MBED_TOOLCHAIN STREQUAL "IAR")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS}
--vla
--diag_suppress=Pe546
)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}
--guard_calls
--no_static_destruction
)
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS}
--skip_dynamic_initialization
--threaded_lib
--inline
)
endif()
add_definitions(${DEVELOP_DEFINITIONS})

View File

@ -0,0 +1,121 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(RELEASE_DEFINITIONS
-DNDEBUG
)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-c \
-std=gnu11 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-c \
-std=gnu++14 \
-fno-rtti \
-Wvla \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
-c \
-x assembler-with-cpp \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
-Wl,--gc-sections \
-Wl,--wrap,main \
-Wl,--wrap,_malloc_r \
-Wl,--wrap,_free_r \
-Wl,--wrap,_realloc_r \
-Wl,--wrap,_memalign_r \
-Wl,--wrap,_calloc_r \
-Wl,--wrap,exit \
-Wl,--wrap,atexit \
-Wl,-n \
")
elseif(MBED_TOOLCHAIN STREQUAL "ARMC6")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-std=gnu11 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-fno-rtti \
-fno-c++-static-destructors \
-std=gnu++14 \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--show_full_path \
--legacyalign \
--inline \
--any_contingency \
--keep=os_cb_sections \
")
set(RELEASE_DEFINITIONS ${RELEASE_DEFINITIONS}
-D__ASSERT_MSG
)
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--md \
--no_depend_system_headers \
--c99 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--cpp11 \
--no_rtti \
--no_vla \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--show_full_path \
--any_contingency \
--inline \
--keep=os_cb_sections \
")
set(RELEASE_DEFINITIONS ${RELEASE_DEFINITIONS}
-D__ASSERT_MSG
)
elseif(MBED_TOOLCHAIN STREQUAL "uARM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--md \
--no_depend_system_headers \
--c99 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--cpp11 \
--no_rtti \
--no_vla \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--inline \
--library_type=microlib \
")
set(RELEASE_DEFINITIONS ${RELEASE_DEFINITIONS}
-D__ASSERT_MSG
)
elseif(MBED_TOOLCHAIN STREQUAL "IAR")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--vla \
--diag_suppress=Pe546 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--guard_calls \
--no_static_destruction \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
--skip_dynamic_initialization \
--threaded_lib \
--inline \
")
endif()
add_definitions(${RELEASE_DEFINITIONS})

4
cmake/toolchain.cmake Normal file
View File

@ -0,0 +1,4 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
include(${MBED_ROOT}/cmake/toolchains/${MBED_TOOLCHAIN}.cmake)

View File

@ -0,0 +1,26 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(COMMON_FLAGS " \
-c \
--gnu \
-Ospace \
--split_sections \
--apcs=interwork \
--brief_diagnostics \
--restrict \
--multibyte_chars \
-O3 \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${COMMON_FLAGS} \
")

View File

@ -0,0 +1,38 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_ASM_COMPILER "armasm")
set(CMAKE_C_COMPILER "armclang")
set(CMAKE_CXX_COMPILER "armclang")
set(CMAKE_AR "armar")
set(ELF2BIN "fromelf")
set(COMMON_FLAGS " \
-c \
--target=arm-arm-none-eabi \
-Oz \
-Wno-armcc-pragma-push-pop \
-Wno-armcc-pragma-anon-unions \
-Wno-reserved-user-defined-literal \
-Wno-deprecated-register \
-fdata-sections \
-fno-exceptions \
-MMD \
-fshort-enums \
-fshort-wchar \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${COMMON_FLAGS} \
")
add_definitions(
-DTOOLCHAIN_ARM
)

View File

@ -0,0 +1,53 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
set(ELF2BIN "arm-none-eabi-objcopy")
set(LD_SYS_LIBS " \
-Wl,--start-group \
-lstdc++ \
-lsupc++ \
-lm \
-lc \
-lgcc \
-lnosys \
-Wl,--end-group \
")
set(COMMON_FLAGS " \
-Wall \
-Wextra \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
-fmessage-length=0 \
-fno-exceptions \
-ffunction-sections \
-fdata-sections \
-funsigned-char \
-MMD \
-fomit-frame-pointer \
-Os \
-g \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${LD_SYS_LIBS} \
-T ${CMAKE_BINARY_DIR}/app.link_script.ld \
")
add_definitions(
-DTOOLCHAIN_GCC_ARM
-DTOOLCHAIN_GCC
)

View File

@ -0,0 +1,22 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(COMMON_FLAGS " \
--no_wrap_diagnostics \
-e \
--diag_suppress=Pa050,Pa084,Pa093,Pa082,Pe540 \
-Ohz \
--enable_restrict \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${COMMON_FLAGS} \
")

View File

@ -0,0 +1,27 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(COMMON_FLAGS " \
-c \
--gnu \
-Ospace \
--split_sections \
--apcs=interwork \
--brief_diagnostics \
--restrict \
--multibyte_chars \
-O3 \
--library_type=microlib \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
${COMMON_FLAGS} \
")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} \
${COMMON_FLAGS} \
")

17
cmake/util.cmake Normal file
View File

@ -0,0 +1,17 @@
# SPDX-License-Identifier: Apache-2.0
# PREFIX - TARGET or similar (can be empty string)
# KEYWORD_LIST - list of labels that are used to include directories
function(mbed_add_cmake_directory_if_labels PREFIX)
get_property(target_labels GLOBAL PROPERTY MBED_TARGET_LABELS)
foreach(key ${target_labels})
if(NOT "${PREFIX}" STREQUAL "")
string(PREPEND key ${PREFIX} "_")
endif()
# assumption: relative path, no need to check for absolute here
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${key})
if (EXISTS ${path})
add_subdirectory(${path})
endif()
endforeach()
endfunction()