AC6.cmake 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #include(CMakePrintHelpers)
  2. include(AddFileDependencies)
  3. function(compilerVersion)
  4. execute_process(COMMAND "${CMAKE_C_COMPILER}" --version_number
  5. OUTPUT_VARIABLE CVERSION
  6. ERROR_VARIABLE CVERSION
  7. )
  8. SET(COMPILERVERSION ${CVERSION} PARENT_SCOPE)
  9. #cmake_print_variables(CVERSION)
  10. #cmake_print_variables(CMAKE_C_COMPILER)
  11. #MESSAGE( STATUS "CMD_OUTPUT:" ${CVERSION})
  12. endfunction()
  13. function(compilerSpecificCompileOptions PROJECTNAME ROOT)
  14. #cmake_print_properties(TARGETS ${PROJECTNAME} PROPERTIES DISABLEOPTIMIZATION)
  15. get_target_property(DISABLEOPTIM ${PROJECTNAME} DISABLEOPTIMIZATION)
  16. if ((OPTIMIZED) AND (NOT DISABLEOPTIM))
  17. #cmake_print_variables(DISABLEOPTIM)
  18. target_compile_options(${PROJECTNAME} PRIVATE "-O3")
  19. endif()
  20. if (FASTMATHCOMPUTATIONS)
  21. target_compile_options(${PROJECTNAME} PUBLIC "-ffast-math")
  22. endif()
  23. if (HARDFP)
  24. target_compile_options(${PROJECTNAME} PUBLIC "-mfloat-abi=hard")
  25. endif()
  26. if (LITTLEENDIAN)
  27. target_compile_options(${PROJECTNAME} PUBLIC "-mlittle-endian")
  28. endif()
  29. # Core specific config
  30. if (ARM_CPU STREQUAL "cortex-m55" )
  31. target_compile_options(${PROJECTNAME} PUBLIC "-fshort-enums")
  32. target_compile_options(${PROJECTNAME} PUBLIC "-fshort-wchar")
  33. endif()
  34. if (ARM_CPU STREQUAL "cortex-m33" )
  35. target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
  36. endif()
  37. if (ARM_CPU STREQUAL "cortex-m7" )
  38. target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5-sp-d16")
  39. endif()
  40. if (ARM_CPU STREQUAL "cortex-m4" )
  41. target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv4-sp-d16")
  42. endif()
  43. if (ARM_CPU STREQUAL "cortex-a9" )
  44. if (NOT (NEON OR NEONEXPERIMENTAL))
  45. target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv3-d16-fp16")
  46. endif()
  47. endif()
  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. if (ARM_CPU STREQUAL "cortex-a5" )
  54. if ((NEON OR NEONEXPERIMENTAL))
  55. target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=neon-vfpv4")
  56. else()
  57. target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=vfpv4-d16")
  58. endif()
  59. endif()
  60. if(EXPERIMENTAL)
  61. experimentalCompilerSpecificCompileOptions(${PROJECTNAME} ${ROOT})
  62. endif()
  63. endfunction()
  64. function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP)
  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. if (HASCSTARTUP)
  69. target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
  70. else()
  71. target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.s)
  72. endif()
  73. target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
  74. set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
  75. set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
  76. #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
  77. target_link_options(${PROJECTNAME} PRIVATE "--entry=Reset_Handler;--scatter=${SCATTERFILE}")
  78. endfunction()
  79. function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER)
  80. target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/AC6/startup_${CORE}.c)
  81. # RTE Components.h
  82. target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing)
  83. set(SCATTERFILE "${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/lnk.sct")
  84. set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6/mem_${CORE}.h")
  85. target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/AC6)
  86. #target_link_options(${PROJECTNAME} PRIVATE "--info=sizes")
  87. target_link_options(${PROJECTNAME} PRIVATE "--entry=Vectors;--scatter=${SCATTERFILE}")
  88. endfunction()
  89. function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT)
  90. endfunction()
  91. function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT)
  92. endfunction()
  93. function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT)
  94. endfunction()
  95. function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT)
  96. endfunction()