MLECO-1860: Support for Arm GNU Embedded Toolchain

This patch enables compilation of ML use cases bare-metal applications
using Arm GNU Embedded Toolchain. The GNU toolchain can be used instead
of the Arm Compiler that was already supported.

The GNU toolchain is also set as the default toolchain when building
applications for the MPS3 target.

Note: The version of GNU toolchain must be 10.2.1 or higher.

Change-Id: I5fff242f0f52d2db6c75d292f9fa990df1aec978
Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
diff --git a/scripts/cmake/cmsis-dsp.cmake b/scripts/cmake/cmsis-dsp.cmake
index cb0243b..bb26b69 100644
--- a/scripts/cmake/cmsis-dsp.cmake
+++ b/scripts/cmake/cmsis-dsp.cmake
@@ -37,7 +37,16 @@
 
 file(GLOB_RECURSE
     CMSIS_DSP_SRC
-    "${CMSIS_DSP_SRC_DIR}/arm_*.c")
+
+    "${CMSIS_DSP_SRC_DIR}/BasicMathFunctions/arm_*.c"
+    "${CMSIS_DSP_SRC_DIR}/FastMathFunctions/arm_*.c"
+    "${CMSIS_DSP_SRC_DIR}/CommonTables/arm_*.c"
+    "${CMSIS_DSP_SRC_DIR}/TransformFunctions/arm_*.c"
+    "${CMSIS_DSP_SRC_DIR}/StatisticsFunctions/arm_*.c"
+
+    # Issue with q15 and q31 functions with Arm GNU toolchain, we only
+    # need f32 functions.
+    "${CMSIS_DSP_SRC_DIR}/ComplexMathFunctions/arm_*f32.c")
 
 # 4. Create static library
 set(CMSIS_DSP_TARGET        cmsis-dsp)
@@ -50,6 +59,20 @@
 target_include_directories(${CMSIS_DSP_TARGET} PRIVATE
                            ${CMSIS_DSP_PRI_INC_DIR})
 
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    target_compile_options(${CMSIS_DSP_TARGET} PUBLIC -flax-vector-conversions)
+
+    # There is a known issue with -O0 optimisation option that affects
+    # FFT functions from CMSIS-DSP when compiling with Arm GNU embedded
+    # toolchain version 10.2.1
+    if (CMAKE_BUILD_TYPE STREQUAL Debug)
+        message(WARNING "There are known issues with CMSIS-DSP builds using "
+                        "MVE extension without optimisation. Forcing -O3 "
+                        "optimisation level")
+        target_compile_options(${CMSIS_DSP_TARGET} PUBLIC -O3)
+    endif()
+endif ()
+
 # 5. Add any custom/conditional flags for compilation or linkage
 if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL cortex-m55)
     target_compile_definitions(${CMSIS_DSP_TARGET} PUBLIC