1212function (get_board_id _return_var _board_name)
1313
1414 set (extra_args ${ARGN} )
15+ 1516 list (LENGTH extra_args num_of_extra_args)
17+ 1618 if (${num_of_extra_args} GREATER 0)
1719 list (GET extra_args 0 _board_cpu)
1820 endif ()
1921
2022 list (FIND ARDUINO_CMAKE_BOARDS ${_board_name} board_name_index)
23+ 2124 if (${board_name_index} LESS 0) # Negative value = not found in list
22- message (FATAL_ERROR "Unknown given board name, not defined in 'boards.txt'. Check your\
23- spelling." )
25+ message (FATAL_ERROR "Given board not defined in 'boards.txt' - Check your spelling." )
26+ 2427 else () # Board is valid and has been found
28+ 2529 if (DEFINED ${_board_name} _cpu_list) # Board cpu is to be expected
30+ 2631 if (NOT _board_cpu)
2732 message (FATAL_ERROR "Expected board CPU to be provided for the ${_board_name} board" )
33+ 2834 else ()
35+ 2936 list (FIND ${_board_name} _cpu_list ${_board_cpu} board_cpu_index)
37+ 3038 if (${board_cpu_index} LESS 0)
3139 message (FATAL_ERROR "Unknown given board cpu" )
3240 endif ()
41+ 3342 set (board_id "${_board_name} .${_board_cpu} " )
43+ 3444 set (${_return_var} "${board_id} " PARENT_SCOPE)
45+ 3546 endif ()
47+ 3648 else () # Board without explicit CPU
3749 set (${_return_var} ${_board_name} PARENT_SCOPE)
3850 endif ()
51+ 3952 endif ()
4053
4154endfunction ()
@@ -58,19 +71,24 @@ function(get_board_property _board_id _property _return_var)
5871
5972 # Get the length of the board to determine whether board CPU is to be expected
6073 list (LENGTH board_id num_of_board_elements)
74+ 6175 list (GET board_id 0 board_name) # Get the board name which is mandatory
6276
6377 if (DEFINED ${board_name} _${property} )
6478 set (retrieved_property ${${board_name} _${property} })
6579 elseif (${num_of_board_elements} EQUAL 1) # Only board name is supplied
6680 message (WARNING "Property ${_property} couldn't be found on board ${_board_id} " )
81+ 6782 else ()
83+ 6884 list (GET board_id 1 board_cpu)
85+ 6986 if (NOT DEFINED ${board_name} _menu_cpu_${board_cpu} _${property} )
7087 message (WARNING "Property ${_property} couldn't be found on board ${_board_id} " )
7188 else ()
7289 set (retrieved_property ${${board_name} _menu_cpu_${board_cpu} _${property} })
7390 endif ()
91+ 7492 endif ()
7593
7694 set (${_return_var} ${retrieved_property} PARENT_SCOPE)
@@ -100,13 +118,17 @@ function(try_get_board_property _board_id _property _return_var)
100118 set (${_return_var} ${${board_name} _${property} } PARENT_SCOPE)
101119 elseif (${num_of_board_elements} EQUAL 1) # Only board name is supplied
102120 return ()
121+ 103122 else ()
123+ 104124 list (GET board_id 1 board_cpu)
125+ 105126 if (NOT DEFINED ${board_name} _menu_cpu_${board_cpu} _${property} )
106127 return ()
107128 else ()
108129 set (${_return_var} ${${board_name} _menu_cpu_${board_cpu} _${property} } PARENT_SCOPE)
109130 endif ()
131+ 110132 endif ()
111133
112134endfunction ()
0 commit comments