Skip to content

Commit 46c3596

Browse files
committed
CMake: Create separate function to set MCU core compile defintions
The new function (mbed_set_cpu_core_definitions()) should always be called as it has defintions needed by Mbed OS to work with that particular MCU core. mbed_set_cpu_core_options() should only be called if a third-party toolchain file has not been used as it has compile options that can cause conflicts.
1 parent 76f4953 commit 46c3596

18 files changed

+45
-9
lines changed

tools/cmake/cores/Cortex-A9.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3939
"--cpu=Cortex-A9"
4040
)
4141
endif()
42+
endfunction()
4243

44+
function(mbed_set_cpu_core_definitions target)
4345
target_compile_definitions(${target}
4446
INTERFACE
4547
__CORTEX_A9

tools/cmake/cores/Cortex-M0+.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3535
"--cpu=Cortex-M0plus"
3636
)
3737
endif()
38+
endfunction()
3839

40+
function(mbed_set_cpu_core_definitions target)
3941
target_compile_definitions(${target}
4042
INTERFACE
4143
__CORTEX_M0PLUS

tools/cmake/cores/Cortex-M0.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3434
"-cpu=Cortex-M0"
3535
)
3636
endif()
37+
endfunction()
3738

39+
function(mbed_set_cpu_core_definitions target)
3840
target_compile_definitions(${target}
3941
INTERFACE
4042
__CORTEX_M0

tools/cmake/cores/Cortex-M1.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3434
"--cpu=Cortex-M1"
3535
)
3636
endif()
37+
endfunction()
3738

39+
function(mbed_set_cpu_core_definitions target)
3840
target_compile_definitions(${target}
3941
INTERFACE
4042
__CORTEX_M3

tools/cmake/cores/Cortex-M23-NS.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3434
"--cpu=Cortex-M23"
3535
)
3636
endif()
37+
endfunction()
3738

39+
function(mbed_set_cpu_core_definitions target)
3840
target_compile_definitions(${target}
3941
INTERFACE
4042
__CORTEX_M23

tools/cmake/cores/Cortex-M23.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3434
"--cpu=Cortex-M23"
3535
)
3636
endif()
37+
endfunction()
3738

39+
function(mbed_set_cpu_core_definitions target)
3840
target_compile_definitions(${target}
3941
INTERFACE
4042
__CORTEX_M23

tools/cmake/cores/Cortex-M3.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3434
"--cpu=Cortex-M3"
3535
)
3636
endif()
37+
endfunction()
3738

39+
function(mbed_set_cpu_core_definitions target)
3840
target_compile_definitions(${target}
3941
INTERFACE
4042
__CORTEX_M3

tools/cmake/cores/Cortex-M33-NS.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3636
"--cpu=Cortex-M33.no_dsp.no_fp"
3737
)
3838
endif()
39+
endfunction()
3940

41+
function(mbed_set_cpu_core_definitions target)
4042
target_compile_definitions(${target}
4143
INTERFACE
4244
__CORTEX_M33

tools/cmake/cores/Cortex-M33.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3838
"--cpu=Cortex-M33.no_dsp.no_fp"
3939
)
4040
endif()
41+
endfunction()
4142

43+
function(mbed_set_cpu_core_definitions target)
4244
target_compile_definitions(${target}
4345
INTERFACE
4446
__CORTEX_M33

tools/cmake/cores/Cortex-M33F-NS.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3939
"--cpu=Cortex-M33.no_dsp"
4040
)
4141
endif()
42+
endfunction()
4243

44+
function(mbed_set_cpu_core_definitions target)
4345
target_compile_definitions(${target}
4446
INTERFACE
4547
__CORTEX_M33

tools/cmake/cores/Cortex-M33F.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3939
"--cpu=Cortex-M33.no_dsp"
4040
)
4141
endif()
42+
endfunction()
4243

44+
function(mbed_set_cpu_core_definitions target)
4345
target_compile_definitions(${target}
4446
INTERFACE
4547
__CORTEX_M33

tools/cmake/cores/Cortex-M33FE-NS.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3737
"--cpu=Cortex-M33"
3838
)
3939
endif()
40+
endfunction()
4041

42+
function(mbed_set_cpu_core_definitions target)
4143
target_compile_definitions(${target}
4244
INTERFACE
4345
__CORTEX_M33

tools/cmake/cores/Cortex-M33FE.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3737
"--cpu=Cortex-M33"
3838
)
3939
endif()
40+
endfunction()
4041

42+
function(mbed_set_cpu_core_definitions target)
4143
target_compile_definitions(${target}
4244
INTERFACE
4345
__CORTEX_M33

tools/cmake/cores/Cortex-M4.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3636
"--cpu=Cortex-M4.no_fp"
3737
)
3838
endif()
39+
endfunction()
3940

41+
function(mbed_set_cpu_core_definitions target)
4042
target_compile_definitions(${target}
4143
INTERFACE
4244
__CORTEX_M4

tools/cmake/cores/Cortex-M4F.cmake

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33

44
# Sets cpu core options
55
function(mbed_set_cpu_core_options target mbed_toolchain)
6-
target_compile_definitions(${target}
7-
INTERFACE
8-
__CORTEX_M4
9-
ARM_MATH_CM4
10-
__FPU_PRESENT=1
11-
__CMSIS_RTOS
12-
__MBED_CMSIS_RTOS_CM
13-
)
14-
156
if(${mbed_toolchain} STREQUAL "GCC_ARM")
167
list(APPEND common_toolchain_options
178
"-mthumb"
@@ -49,3 +40,14 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
4940
)
5041
endif()
5142
endfunction()
43+
44+
function(mbed_set_cpu_core_definitions target)
45+
target_compile_definitions(${target}
46+
INTERFACE
47+
__CORTEX_M4
48+
ARM_MATH_CM4
49+
__FPU_PRESENT=1
50+
__CMSIS_RTOS
51+
__MBED_CMSIS_RTOS_CM
52+
)
53+
endfunction()

tools/cmake/cores/Cortex-M7.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3636
"--cpu=Cortex-M7.no_fp"
3737
)
3838
endif()
39+
endfunction()
3940

41+
function(mbed_set_cpu_core_definitions target)
4042
target_compile_definitions(${target}
4143
INTERFACE
4244
__CORTEX_M7

tools/cmake/cores/Cortex-M7F.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3939
"--cpu=Cortex-M7.fp.sp"
4040
)
4141
endif()
42+
endfunction()
4243

44+
function(mbed_set_cpu_core_definitions target)
4345
target_compile_definitions(${target}
4446
INTERFACE
4547
__CORTEX_M7

tools/cmake/cores/Cortex-M7FD.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function(mbed_set_cpu_core_options target mbed_toolchain)
3939
"--cpu=Cortex-M7"
4040
)
4141
endif()
42+
endfunction()
4243

44+
function(mbed_set_cpu_core_definitions target)
4345
target_compile_definitions(${target}
4446
INTERFACE
4547
__CORTEX_M7

0 commit comments

Comments
 (0)