Fix: armasm debug information missing for debug builds

The build system failed to properly specify compilation switches for
armasm when executing debug builds (-DCMAKE_BUILD_TYPE=Debug).
As a resolution the "embedded_project_fixup()" processing was changed
to define proper compilation switches.

Change-Id: I412be8dc3037df860f064e32c4cad2c48c70a30e
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
diff --git a/cmake/Common/BuildSys.cmake b/cmake/Common/BuildSys.cmake
index cf4d3ab..370f275 100644
--- a/cmake/Common/BuildSys.cmake
+++ b/cmake/Common/BuildSys.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -69,18 +69,13 @@
 #Override CMake default behaviour
 macro(embedded_project_fixup)
 	get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
-	if("CXX" IN_LIST languages)
-		include(Common/CompilerDetermineCXX)
-		#since all CMake "built in" scripts already executed, we need fo fix up some things here.
-		embedded_fixup_build_type_vars(CXX)
-	endif()
-	if("C" IN_LIST languages)
-		include(Common/CompilerDetermineC)
-		embedded_fixup_build_type_vars(C)
-	endif()
 
 	#Merge CPU and configuration specific compiler and linker flags.
 	foreach(LNG ${languages})
+		include(Common/CompilerDetermine${LNG})
+		#since all CMake "built in" scripts already executed, we need fo fix up some things here.
+		embedded_fixup_build_type_vars(${LNG})
+
 		#Apply CPU specific and configuration specific compile flags.
 		if(NOT CMAKE_${LNG}_FLAGS MATCHES ".*${CMAKE_${LNG}_FLAGS_CPU}.*")
 			set(CMAKE_${LNG}_FLAGS "${CMAKE_${LNG}_FLAGS} ${CMAKE_${LNG}_FLAGS_CPU}")
@@ -118,10 +113,10 @@
 
 macro(embedded_fixup_build_type_vars LANG)
 	#since all CMake "built in" scripts already executed, we need fo fix up some things here.
-	set (CMAKE_${LANG}_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
-	set (CMAKE_${LANG}_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING "Flags used by the compiler during release builds for minimum size." FORCE)
-	set (CMAKE_${LANG}_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING "Flags used by the compiler during release builds." FORCE)
-	set (CMAKE_${LANG}_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE)
+	set (CMAKE_${LANG}_FLAGS_DEBUG "${CMAKE_${LANG}_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
+	set (CMAKE_${LANG}_FLAGS_MINSIZEREL "${CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT}" CACHE STRING "Flags used by the compiler during release builds for minimum size." FORCE)
+	set (CMAKE_${LANG}_FLAGS_RELEASE "${CMAKE_${LANG}_FLAGS_RELEASE_INIT}" CACHE STRING "Flags used by the compiler during release builds." FORCE)
+	set (CMAKE_${LANG}_FLAGS_RELWITHDEBINFO "${CMAKE_${LANG}_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE)
 endmacro()
 
 
diff --git a/cmake/Common/CompilerDetermineASM.cmake b/cmake/Common/CompilerDetermineASM.cmake
new file mode 100644
index 0000000..7bef05d
--- /dev/null
+++ b/cmake/Common/CompilerDetermineASM.cmake
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#Built in compiler identification does not work for embedded targets, so
+#override it here.
+
+if(NOT DEFINED CMAKE_ASM_COMPILER)
+	message(FATAL_ERROR "Please set CMAKE_ASM_COMPILER to hold the full path of\
+ your compiler executable")
+endif()
+
+get_filename_component(_ASM_COMPILER_NAME ${CMAKE_ASM_COMPILER} NAME)
+
+#Based on the name of the compiler executable select which tool we use.
+if (_ASM_COMPILER_NAME MATCHES "^.*armclang(\\.exe)?$")
+	set(ARM_TOOLCHAIN_FILE "Compiler/ARMClang-ASM")
+elseif(_ASM_COMPILER_NAME MATCHES "^.*armasm(\\.exe)?$")
+	set(ARM_TOOLCHAIN_FILE "Compiler/ARMCC-ASM")
+elseif (_ASM_COMPILER_NAME MATCHES "^.*gcc(\\.exe)?$")
+	set(ARM_TOOLCHAIN_FILE "Compiler/GNUARM-ASM")
+else()
+	message(FATAL_ERROR "ASM Compiler executable ${_ASM_COMPILER_NAME} is \
+unknown. Please add needed settings to ${CMAKE_CURRENT_LIST_FILE}")
+endif ()
+
+include(${ARM_TOOLCHAIN_FILE})