blob: cb7ec760ee89470e206a108a952f0771d1ad3d31 [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()
68endfunction()
69
70
71function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER)
72 # A specific library is created for ASM file
73 # since we do not want standard compile flags (for C) to be applied to
74 # ASM files.
75 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
76 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
77
78 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
79
80 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
81
82 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
83 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
84
85endfunction()
86
87function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
88 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
89
90
91 # RTE Components.h
92 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
93
94 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
95
96 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
97
98 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
99
100 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
101 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
102
103endfunction()
104
105function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
106endfunction()
107
108function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
109endfunction()
110
111function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
112endfunction()
113
114function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
115endfunction()