blob: 83de49e3a107a48770406447df4713091fd1da8d [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")
39 #target_compile_options(${PROJECTNAME} PUBLIC -funsigned-char;-fshort-enums;-fshort-wchar;-ffunction-sections)
40 endif()
41
42 if (ARM_CPU STREQUAL "cortex-a9" )
43 if (NOT (NEON OR NEONEXPERIMENTAL))
44 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
45 endif()
46 endif()
47
48 if (ARM_CPU STREQUAL "cortex-a7" )
49 if (NOT (NEON OR NEONEXPERIMENTAL))
50 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
51 endif()
52 endif()
53
54 if (ARM_CPU STREQUAL "cortex-a5" )
55 if ((NEON OR NEONEXPERIMENTAL))
56 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
57 else()
58 target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
59 endif()
60 endif()
61endfunction()
62
63
64function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER)
65 # A specific library is created for ASM file
66 # since we do not want standard compile flags (for C) to be applied to
67 # ASM files.
68 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
69 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
70
71 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
72
73 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
74
75 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
76 target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
77
78endfunction()
79
80function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
81 target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
82
83
84 # RTE Components.h
85 target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
86
87 set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
88
89 set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
90
91 target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
92
93 #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
94 target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
95
96endfunction()
97
98function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
99endfunction()
100
101function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
102endfunction()
103
104function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
105endfunction()
106
107function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
108endfunction()