blob: 8604f0cefb36ae54fe376425fe786b201fd8fdbf [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)
20 target_compile_options(${PROJECTNAME} PRIVATE "-O2")
21 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
37 if (ARM_CPU STREQUAL "cortex-m33" )
38 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
Christophe Favergeon122be852019-07-30 10:36:30 +020039 endif()
40
41 if (ARM_CPU STREQUAL "cortex-m7" )
42 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
43 endif()
44
45 if (ARM_CPU STREQUAL "cortex-m4" )
46 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv4-sp-d16")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020047 endif()
48
49 if (ARM_CPU STREQUAL "cortex-a9" )
50 if (NOT (NEON OR NEONEXPERIMENTAL))
51 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
52 endif()
53 endif()
54
55 if (ARM_CPU STREQUAL "cortex-a7" )
56 if (NOT (NEON OR NEONEXPERIMENTAL))
57 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
58 endif()
59 endif()
60
61 if (ARM_CPU STREQUAL "cortex-a5" )
62 if ((NEON OR NEONEXPERIMENTAL))
63 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
64 else()
65 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
66 endif()
67 endif()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010068
69 if(EXPERIMENTAL)
70 experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
71 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020072endfunction()
73
74
Christophe Favergeon26c2f682019-09-06 14:43:32 +010075function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020076 # A specific library is created for ASM file
77 # since we do not want standard compile flags (for C) to be applied to
78 # ASM files.
Christophe Favergeon26c2f682019-09-06 14:43:32 +010079 if (HASCSTARTUP)
80 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
81 else()
82 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
83 endif()
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020084 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
85
86 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
87
88 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
89
90 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
91 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
92
93endfunction()
94
95function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
96 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
97
98
99 # RTE Components.h
100 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
101
102 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
103
104 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
105
106 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
107
108 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
109 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
110
111endfunction()
112
113function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
114endfunction()
115
116function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
117endfunction()
118
119function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
120endfunction()
121
122function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
123endfunction()