@@ -49,39 +49,81 @@ set(CMAKE_SYSTEM_NAME "Arduino")
49
49
set (ARDUINO_TOOLCHAIN_DIR "${CMAKE_CURRENT_LIST_DIR} " )
50
50
set (_ARDUINO_TOOLCHAIN_PARENT "${CMAKE_PARENT_LIST_FILE} " )
51
51
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} " "${CMAKE_CURRENT_LIST_DIR} " )
52
- set (ARDUINO_TOOLCHAIN_VERSION "1.0 " )
52
+ set (ARDUINO_TOOLCHAIN_VERSION "1.1 " )
53
53
54
54
# Include modules
55
+ include (Arduino/System/PackagePathIndex )
56
+ include (Arduino/System/PackageIndex )
55
57
include (Arduino/System/BoardsIndex )
56
58
include (Arduino/System/BoardToolchain )
57
59
include (Arduino/System/BoardBuildTargets )
60
+ include (Arduino/PackageManager/BoardsManager )
58
61
59
62
#*****************************************************************************
60
- # For improved speed, indexing of boards is done only once during a
61
- # cmake invocation. However, this toolchain file is included multiple
62
- # times in multiple contexts (system determination context, separate
63
- # context for each try compile etc.). After indexing, the selected
64
- # board's toolchain info is configured to a generated file that gets
65
- # included in every other inclusion of this toolchain.
66
- if (NOT _BOARD_INDEXING_COMPLETED )
63
+ # For improved speed, indexing and setup of boards is done only once during a
64
+ # cmake invocation. However, this toolchain file is included multiple times
65
+ # in multiple contexts (system determination context, separate context for
66
+ # each try compile etc.). After indexing, the selected board's toolchain
67
+ # info is configured to a generated file that gets included in every other
68
+ # inclusion of this toolchain.
69
+ if (NOT _BOARD_SETUP_COMPLETED )
67
70
get_property (_in_try_compile GLOBAL PROPERTY IN_TRY_COMPILE )
68
- # IN_TRY_COMPILE check seems to be not enough. Check for parent
69
- # script works, but may be undocumented!
70
- get_filename_component (parent_script "${_ARDUINO_TOOLCHAIN_PARENT} " NAME_WE )
71
+ # IN_TRY_COMPILE check seems to be not enough. Checking for parent
72
+ # script works, but might be using undocumented feature?
73
+ get_filename_component (parent_script "${_ARDUINO_TOOLCHAIN_PARENT} "
74
+ NAME_WE )
71
75
if (parent_script STREQUAL "CMakeSystem" )
72
76
check_board_options_changed (_b_changed )
73
77
if (NOT _b_changed )
74
- set (_BOARD_INDEXING_COMPLETED TRUE )
78
+ set (_BOARD_SETUP_COMPLETED TRUE )
75
79
endif ()
80
+ elseif (ARDUINO_SYSTEM_FILE )
81
+ # If passing with pre-generated Arduino system code
82
+ set (_BOARD_SETUP_COMPLETED TRUE )
83
+ set (CMAKE_SYSTEM_CUSTOM_CODE
84
+ "include(\" ${ARDUINO_SYSTEM_FILE} \" )"
85
+ )
76
86
endif ()
77
87
endif ()
78
88
79
- if (NOT _BOARD_INDEXING_COMPLETED )
80
- SetupBoardToolchain ()
89
+ # Wrap it in a function so that the scope of variables are within
90
+ # the function
91
+ function (BoardSetupWorkflow )
92
+
93
+ # Call the common workflow for setting up the platform, which includes
94
+ # installing the necessary platform (if package management is enabled),
95
+ # and indexing the boards based on the platform. The platform to be
96
+ # setup is identified using the board options which we already loaded.
97
+ PlatformSetupWorkflow ()
98
+
99
+ # Select one of the boards as selected in BoardOptions.cmake or in
100
+ # cmake-gui or other mechanisms. If none selected, this call will
101
+ # generate options in CMake Cache and BoardOptions.cmake to allow
102
+ # later selection of the board.
103
+ SelectArduinoBoard (ard_boards )
104
+ set (ARDUINO_BOARD_IDENTIFIER "${ARDUINO_BOARD_IDENTIFIER} "
105
+ PARENT_SCOPE )
106
+ list (LENGTH ARDUINO_BOARD_IDENTIFIER _num_board_ids )
107
+
108
+ # if a board is selected, setup a toolchain for the board
109
+ # Else, Arduino-Determine.cmake will print an error message later
110
+ # Arduino-Determine.cmake.
111
+ if (_num_board_ids EQUAL 1 )
112
+ SetupBoardToolchain (ard_boards "${ARDUINO_BOARD_IDENTIFIER} "
113
+ "${CMAKE_BINARY_DIR} " )
114
+ endif ()
115
+
116
+ endfunction ()
117
+
118
+ if (NOT _BOARD_SETUP_COMPLETED )
119
+
120
+ BoardSetupWorkflow ()
121
+
81
122
set (CMAKE_SYSTEM_CUSTOM_CODE
82
123
"include(\" ${CMAKE_BINARY_DIR} /ArduinoSystem.cmake\" )"
83
124
)
84
- set (_BOARD_INDEXING_COMPLETED TRUE )
125
+ set (_BOARD_SETUP_COMPLETED TRUE )
126
+
85
127
endif ()
86
128
87
129
# Search for programs in the build host directories
@@ -94,7 +136,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
94
136
file (WRITE "${CMAKE_CURRENT_BINARY_DIR} /build_opt.h" "" )
95
137
96
138
# Do not try to link during the configure time, due to the dependency on the
97
- # core, which we do not have a target yet.
98
- set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
139
+ # core for some platforms, which we do not have a target yet.
140
+ if (NOT "${ARDUINO_TRY_STANDALONE_TOOLCHAIN} " )
141
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
142
+ endif ()
99
143
100
144
cmake_policy (POP )
0 commit comments