Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 1 | #include(CMakePrintHelpers) |
| 2 | include(AddFileDependencies) |
| 3 | |
| 4 | function(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}) |
| 13 | endfunction() |
| 14 | |
| 15 | function(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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 20 | target_compile_options(${PROJECTNAME} PRIVATE "-Ofast") |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 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 | |
Christophe Favergeon | 512b148 | 2020-02-07 11:25:11 +0100 | [diff] [blame] | 37 | 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 Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 42 | if (ARM_CPU STREQUAL "cortex-m33" ) |
| 43 | target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16") |
Christophe Favergeon | 122be85 | 2019-07-30 10:36:30 +0200 | [diff] [blame] | 44 | 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 Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 52 | 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 Favergeon | 26c2f68 | 2019-09-06 14:43:32 +0100 | [diff] [blame] | 73 | |
| 74 | if(EXPERIMENTAL) |
| 75 | experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT}) |
| 76 | endif() |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 77 | endfunction() |
| 78 | |
| 79 | |
Christophe Favergeon | 26c2f68 | 2019-09-06 14:43:32 +0100 | [diff] [blame] | 80 | function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP) |
Christophe Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 81 | # 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 Favergeon | 26c2f68 | 2019-09-06 14:43:32 +0100 | [diff] [blame] | 84 | 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 Favergeon | 3b2a0ee | 2019-06-12 13:29:14 +0200 | [diff] [blame] | 89 | 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 | |
| 98 | endfunction() |
| 99 | |
| 100 | function(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 | |
| 116 | endfunction() |
| 117 | |
| 118 | function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT) |
| 119 | endfunction() |
| 120 | |
| 121 | function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT) |
| 122 | endfunction() |
| 123 | |
| 124 | function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT) |
| 125 | endfunction() |
| 126 | |
| 127 | function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT) |
| 128 | endfunction() |