blob: 91012c2f42c0f110bc6ab09bb2912f84bc011588 [file] [log] [blame]
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +02001#include(CMakePrintHelpers)
2include(AddFileDependencies)
3
4function(compilerVersion)
5 execute_process(COMMAND "${CMAKE_C_COMPILER}" --version_number
6 OUTPUT_VARIABLE CVERSION
7 ERROR_VARIABLE CVERSION
8 )
9 SET(COMPILERVERSION ${CVERSION} PARENT_SCOPE)
10 #cmake_print_variables(CVERSION)
11 #cmake_print_variables(CMAKE_C_COMPILER)
12 #MESSAGE( STATUS "CMD_OUTPUT:" ${CVERSION})
13endfunction()
14
15function(compilerSpecificCompileOptions PROJECTNAME ROOT)
16 #cmake_print_properties(TARGETS ${PROJECTNAME} PROPERTIES DISABLEOPTIMIZATION)
17 get_target_property(DISABLEOPTIM ${PROJECTNAME} DISABLEOPTIMIZATION)
18 if ((OPTIMIZED) AND (NOT DISABLEOPTIM))
19 #cmake_print_variables(DISABLEOPTIM)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020020 target_compile_options(${PROJECTNAME} PRIVATE "-Ofast")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020021 endif()
22
23 if (FASTMATHCOMPUTATIONS)
24 target_compile_options(${PROJECTNAME} PUBLIC "-ffast-math")
25 endif()
26
27 if (HARDFP)
28 target_compile_options(${PROJECTNAME} PUBLIC "-mfloat-abi=hard")
29 endif()
30
31 if (LITTLEENDIAN)
32 target_compile_options(${PROJECTNAME} PUBLIC "-mlittle-endian")
33 endif()
Christophe Favergeonfe27d872020-07-31 07:20:18 +020034
35 if (CORTEXM OR CORTEXR)
36 target_compile_options(${PROJECTNAME} PUBLIC "-mthumb")
37 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020038
39 # Core specific config
40
Christophe Favergeon512b1482020-02-07 11:25:11 +010041 if (ARM_CPU STREQUAL "cortex-m55" )
42 target_compile_options(${PROJECTNAME} PUBLIC "-fshort-enums")
43 target_compile_options(${PROJECTNAME} PUBLIC "-fshort-wchar")
44 endif()
45
Christophe Favergeon72f1d9e2020-08-12 10:39:33 +020046 if (ARM_CPU STREQUAL "cortex-m55+nomve" )
47 target_compile_options(${PROJECTNAME} PUBLIC "-fshort-enums")
48 target_compile_options(${PROJECTNAME} PUBLIC "-fshort-wchar")
49 endif()
50
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020051 if (ARM_CPU STREQUAL "cortex-m33" )
52 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
Christophe Favergeon122be852019-07-30 10:36:30 +020053 endif()
54
55 if (ARM_CPU STREQUAL "cortex-m7" )
56 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
57 endif()
58
59 if (ARM_CPU STREQUAL "cortex-m4" )
60 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv4-sp-d16")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020061 endif()
62
63 if (ARM_CPU STREQUAL "cortex-a9" )
64 if (NOT (NEON OR NEONEXPERIMENTAL))
65 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
66 endif()
67 endif()
68
Christophe Favergeonea3ac962020-06-19 08:31:36 +020069
70 if (ARM_CPU STREQUAL "cortex-a32" )
71 if (NEON OR NEONEXPERIMENTAL)
72 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-fp-armv8")
73 endif()
74 endif()
75
76
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020077 if (ARM_CPU STREQUAL "cortex-a7" )
78 if (NOT (NEON OR NEONEXPERIMENTAL))
79 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
80 endif()
81 endif()
Christophe Favergeonc67252c2020-06-18 11:11:51 +020082
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020083
84 if (ARM_CPU STREQUAL "cortex-a5" )
85 if ((NEON OR NEONEXPERIMENTAL))
86 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
87 else()
88 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
89 endif()
90 endif()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010091
Christophe Favergeonfe27d872020-07-31 07:20:18 +020092 if (ARM_CPU STREQUAL "cortex-r52" )
93 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-fp-armv8")
94 endif()
95
Christophe Favergeon0e0449a2020-07-28 09:44:14 +020096 if (ARM_CPU STREQUAL "cortex-r8" )
97 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
98 endif()
99
100 if (ARM_CPU STREQUAL "cortex-r5" )
101 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3")
102 endif()
103
Christophe Favergeonc67252c2020-06-18 11:11:51 +0200104
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100105 if(EXPERIMENTAL)
106 experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
107 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200108endfunction()
109
110
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100111function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200112 # A specific library is created for ASM file
113 # since we do not want standard compile flags (for C) to be applied to
114 # ASM files.
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100115 if (HASCSTARTUP)
116 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
117 else()
118 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
119 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200120 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
121
122 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
123
124 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
125
126 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
127 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
128
129endfunction()
130
131function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
132 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
133
134
135 # RTE Components.h
136 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
137
138 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
139
140 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
141
142 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
143
144 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
145 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
146
147endfunction()
148
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200149function(toolchainSpecificLinkForCortexR PROJECTNAME ROOT CORE PLATFORMFOLDER)
150 #target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
151 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup.s)
152
153
154 # RTE Components.h
155 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
156
157 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
158
159 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
160
161 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
162
163 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
164 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200165endfunction()
166
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200167function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
168endfunction()
169
170function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
171endfunction()
172
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200173function(compilerSpecificPlatformConfigLibForR PROJECTNAME ROOT)
174endfunction()
175
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200176function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
177endfunction()
178
179function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200180endfunction()
181
182function(compilerSpecificPlatformConfigAppForR PROJECTNAME ROOT)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200183endfunction()