blob: 94af8802f985a76a207f1e1dea9db283ca5e918d [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()
34
35 # Core specific config
36
Christophe Favergeon512b1482020-02-07 11:25:11 +010037 if (ARM_CPU STREQUAL "cortex-m55" )
38 target_compile_options(${PROJECTNAME} PUBLIC "-fshort-enums")
39 target_compile_options(${PROJECTNAME} PUBLIC "-fshort-wchar")
40 endif()
41
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020042 if (ARM_CPU STREQUAL "cortex-m33" )
43 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
Christophe Favergeon122be852019-07-30 10:36:30 +020044 endif()
45
46 if (ARM_CPU STREQUAL "cortex-m7" )
47 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
48 endif()
49
50 if (ARM_CPU STREQUAL "cortex-m4" )
51 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv4-sp-d16")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020052 endif()
53
54 if (ARM_CPU STREQUAL "cortex-a9" )
55 if (NOT (NEON OR NEONEXPERIMENTAL))
56 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
57 endif()
58 endif()
59
Christophe Favergeonea3ac962020-06-19 08:31:36 +020060
61 if (ARM_CPU STREQUAL "cortex-a32" )
62 if (NEON OR NEONEXPERIMENTAL)
63 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-fp-armv8")
64 endif()
65 endif()
66
67
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020068 if (ARM_CPU STREQUAL "cortex-a7" )
69 if (NOT (NEON OR NEONEXPERIMENTAL))
70 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
71 endif()
72 endif()
Christophe Favergeonc67252c2020-06-18 11:11:51 +020073
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020074
75 if (ARM_CPU STREQUAL "cortex-a5" )
76 if ((NEON OR NEONEXPERIMENTAL))
77 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
78 else()
79 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
80 endif()
81 endif()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010082
Christophe Favergeon0e0449a2020-07-28 09:44:14 +020083 if (ARM_CPU STREQUAL "cortex-r8" )
84 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
85 endif()
86
87 if (ARM_CPU STREQUAL "cortex-r5" )
88 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3")
89 endif()
90
Christophe Favergeonc67252c2020-06-18 11:11:51 +020091
Christophe Favergeon26c2f682019-09-06 14:43:32 +010092 if(EXPERIMENTAL)
93 experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
94 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020095endfunction()
96
97
Christophe Favergeon26c2f682019-09-06 14:43:32 +010098function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020099 # A specific library is created for ASM file
100 # since we do not want standard compile flags (for C) to be applied to
101 # ASM files.
Christophe Favergeon26c2f682019-09-06 14:43:32 +0100102 if (HASCSTARTUP)
103 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
104 else()
105 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
106 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200107 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
108
109 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
110
111 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
112
113 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
114 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
115
116endfunction()
117
118function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
119 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
120
121
122 # RTE Components.h
123 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
124
125 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
126
127 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
128
129 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
130
131 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
132 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
133
134endfunction()
135
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200136function(toolchainSpecificLinkForCortexR PROJECTNAME ROOT CORE PLATFORMFOLDER)
137 #target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
138 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup.s)
139
140
141 # RTE Components.h
142 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
143
144 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
145
146 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
147
148 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
149
150 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
151 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
152
153endfunction()
154
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200155function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
156endfunction()
157
158function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
159endfunction()
160
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200161function(compilerSpecificPlatformConfigLibForR PROJECTNAME ROOT)
162endfunction()
163
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200164function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
165endfunction()
166
167function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
Christophe Favergeon0e0449a2020-07-28 09:44:14 +0200168endfunction()
169
170function(compilerSpecificPlatformConfigAppForR PROJECTNAME ROOT)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +0200171endfunction()