blob: fef87429a45c765681a9ab2c4bb381b75e8dcbc2 [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 Favergeonc67252c2020-06-18 11:11:51 +020083
Christophe Favergeon26c2f682019-09-06 14:43:32 +010084 if(EXPERIMENTAL)
85 experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
86 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020087endfunction()
88
89
Christophe Favergeon26c2f682019-09-06 14:43:32 +010090function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020091 # A specific library is created for ASM file
92 # since we do not want standard compile flags (for C) to be applied to
93 # ASM files.
Christophe Favergeon26c2f682019-09-06 14:43:32 +010094 if (HASCSTARTUP)
95 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
96 else()
97 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
98 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020099 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
100
101 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
102
103 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
104
105 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
106 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
107
108endfunction()
109
110function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
111 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
112
113
114 # RTE Components.h
115 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
116
117 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
118
119 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
120
121 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
122
123 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
124 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
125
126endfunction()
127
128function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
129endfunction()
130
131function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
132endfunction()
133
134function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
135endfunction()
136
137function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
138endfunction()