summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-16 22:17:29 +0700
committerhathach <[email protected]>2024-04-19 23:16:54 +0700
commit7545c40003d5f143cd7cb21037e4dd63b882d7f7 (patch)
tree64e848fdd999e79654e5bdda59e22c00bcb97e30 /hw
parent0fb73eac7e058925cebf788f58d9f9f8e823d79b (diff)
cmake detect toolchain based on -DCMAKE_C_COMPILER
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/family_support.cmake19
1 files changed, 17 insertions, 2 deletions
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index d4f355e0c..7f4dda172 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -6,12 +6,24 @@ include(CMakePrintHelpers)
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../..")
get_filename_component(TOP ${TOP} ABSOLUTE)
-# Default to gcc
+#-------------------------------------------------------------
+# Toolchain
+# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER=
+#-------------------------------------------------------------
+if (DEFINED CMAKE_C_COMPILER)
+ string(FIND ${CMAKE_C_COMPILER} "iccarm" IS_IAR)
+ if (NOT IS_IAR EQUAL -1)
+ set(TOOLCHAIN iar)
+ endif ()
+endif ()
+
if (NOT DEFINED TOOLCHAIN)
set(TOOLCHAIN gcc)
endif ()
-# FAMILY not defined, try to detect it from BOARD
+#-------------------------------------------------------------
+# FAMILY and BOARD
+#-------------------------------------------------------------
if (NOT DEFINED FAMILY)
if (NOT DEFINED BOARD)
message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif).
@@ -74,6 +86,9 @@ set(WARNING_FLAGS_GNU
set(WARNING_FLAGS_IAR "")
+#-------------------------------------------------------------
+# Functions
+#-------------------------------------------------------------
# Filter example based on only.txt and skip.txt
function(family_filter RESULT DIR)