blob: 9733a38554d451c3fdc4f3dc67070fcb90a6bfc2 [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
60 if (ARM_CPU STREQUAL "cortex-a7" )
61 if (NOT (NEON OR NEONEXPERIMENTAL))
62 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
63 endif()
64 endif()
Christophe Favergeonc67252c2020-06-18 11:11:51 +020065
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020066
67 if (ARM_CPU STREQUAL "cortex-a5" )
68 if ((NEON OR NEONEXPERIMENTAL))
69 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
70 else()
71 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
72 endif()
73 endif()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010074
Christophe Favergeonc67252c2020-06-18 11:11:51 +020075
Christophe Favergeon26c2f682019-09-06 14:43:32 +010076 if(EXPERIMENTAL)
77 experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
78 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020079endfunction()
80
81
Christophe Favergeon26c2f682019-09-06 14:43:32 +010082function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020083 # A specific library is created for ASM file
84 # since we do not want standard compile flags (for C) to be applied to
85 # ASM files.
Christophe Favergeon26c2f682019-09-06 14:43:32 +010086 if (HASCSTARTUP)
87 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
88 else()
89 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
90 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020091 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
92
93 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
94
95 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
96
97 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
98 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
99
100endfunction()
101
102function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
103 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
104
105
106 # RTE Components.h
107 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
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_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
114
115 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
116 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
117
118endfunction()
119
120function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
121endfunction()
122
123function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
124endfunction()
125
126function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
127endfunction()
128
129function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
130endfunction()