blob: fd3c663df13cda5c37e3ee9f9f88fbae97bc724e [file] [log] [blame]
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02001include(CMakePrintHelpers)
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02002
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +02003enable_language(CXX C ASM)
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02004
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02005
6# Otherwise there is a .obj on windows and it creates problems
7# with armlink.
8SET(CMAKE_C_OUTPUT_EXTENSION .o)
9SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
10SET(CMAKE_ASM_OUTPUT_EXTENSION .o)
11
12
13get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
14
15cmake_print_variables(PROJECT_NAME)
16
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020017
Christophe Favergeon26c2f682019-09-06 14:43:32 +010018function(cortexm CORE PROJECT_NAME ROOT PLATFORMFOLDER CSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020019
20 target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT}/CMSIS/Core/Include)
21
22 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/system_${CORE}.c)
23
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020024
Christophe Favergeon26c2f682019-09-06 14:43:32 +010025 toolchainSpecificLinkForCortexM(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER} ${CSTARTUP})
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020026
27 configplatformForApp(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER})
28 SET(PLATFORMID ${PLATFORMID} PARENT_SCOPE)
29
30endfunction()
31
32function(cortexa CORE PROJECT_NAME ROOT PLATFORMFOLDER)
33 target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT}/CMSIS/Core_A/Include)
34
35 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/irq_ctrl_gic.c)
36 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/mmu_${CORE}.c)
37 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/system_${CORE}.c)
38
39
40 target_compile_definitions(${PROJECT_NAME} PRIVATE -DCMSIS_device_header="${CORE}.h")
41
42 toolchainSpecificLinkForCortexA(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER})
43
44 configplatformForApp(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER})
45 SET(PLATFORMID ${PLATFORMID} PARENT_SCOPE)
46endfunction()
47
48function(configboot PROJECT_NAME ROOT PLATFORMFOLDER)
49
50 target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT}/CMSIS/DSP/Include)
51 set_platform_core()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010052
53 if(EXPERIMENTAL)
54 experimentalConfigboot(${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
55 if (ISCORTEXM)
56 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} ${HASCSTARTUP})
57 else()
58 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
59 endif()
60 endif()
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020061 ###################
62 #
63 # Cortex cortex-m7
64 #
65 if (ARM_CPU STREQUAL "cortex-m7")
Christophe Favergeon26c2f682019-09-06 14:43:32 +010066 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020067
68 endif()
69
70 ###################
71 #
72 # Cortex cortex-m4
73 #
74 if (ARM_CPU STREQUAL "cortex-m4")
Christophe Favergeon26c2f682019-09-06 14:43:32 +010075 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020076 endif()
77
78 ###################
79 #
80 # Cortex cortex-m35p
81 #
82 if (ARM_CPU STREQUAL "cortex-m35")
Christophe Favergeon26c2f682019-09-06 14:43:32 +010083 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020084
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020085 endif()
86
87 ###################
88 #
89 # Cortex cortex-m33
90 #
91 if (ARM_CPU STREQUAL "cortex-m33")
Christophe Favergeon26c2f682019-09-06 14:43:32 +010092 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020093
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020094 endif()
95
96 ###################
97 #
98 # Cortex cortex-m23
99 #
100 if (ARM_CPU STREQUAL "cortex-m23")
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100101 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200102
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200103 endif()
104
105 ###################
106 #
107 # Cortex cortex-m0+
108 #
109 if (ARM_CPU STREQUAL "cortex-m0p")
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100110 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200111
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200112 endif()
113
114 ###################
115 #
116 # Cortex cortex-m0
117 #
118 if (ARM_CPU STREQUAL "cortex-m0")
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100119 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200120
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200121 endif()
122
123 ###################
124 #
125 # Cortex cortex-a5
126 #
127 if (ARM_CPU STREQUAL "cortex-a5")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200128 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
129
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200130 endif()
131
132 ###################
133 #
134 # Cortex cortex-a7
135 #
136 if (ARM_CPU STREQUAL "cortex-a7")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200137 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
138
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200139 endif()
140
141 ###################
142 #
143 # Cortex cortex-a9
144 #
145 if (ARM_CPU STREQUAL "cortex-a9")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200146 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
147
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200148 endif()
Christophe Favergeon6b604eb2019-05-17 13:46:33 +0200149
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200150 ###################
151 #
152 # Cortex cortex-a15
153 #
154 if (ARM_CPU STREQUAL "cortex-a15")
155 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
156
157 endif()
158
159 SET(PLATFORMID ${PLATFORMID} PARENT_SCOPE)
160
161endfunction()
162