blob: f232acd4c16797524156b017854a01c0eeaf1fe9 [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()
65
66 if (ARM_CPU STREQUAL "cortex-a5" )
67 if ((NEON OR NEONEXPERIMENTAL))
68 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
69 else()
70 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
71 endif()
72 endif()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010073
74 if(EXPERIMENTAL)
75 experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
76 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020077endfunction()
78
79
Christophe Favergeon26c2f682019-09-06 14:43:32 +010080function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020081 # A specific library is created for ASM file
82 # since we do not want standard compile flags (for C) to be applied to
83 # ASM files.
Christophe Favergeon26c2f682019-09-06 14:43:32 +010084 if (HASCSTARTUP)
85 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
86 else()
87 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
88 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020089 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
90
91 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
92
93 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
94
95 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
96 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
97
98endfunction()
99
100function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
101 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
102
103
104 # RTE Components.h
105 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
106
107 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
108
109 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
110
111 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
112
113 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
114 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
115
116endfunction()
117
118function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
119endfunction()
120
121function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
122endfunction()
123
124function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
125endfunction()
126
127function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
128endfunction()