11#=============================================================================#
22# Sets compiler flags on the given target using the given board ID, compiler language and scope.
33# _target_name - Name of the target (Executable or Library) to set flags on.
4- # _board_id - Target's bounded board ID.
54# _language - Language for which flags are set (such as C/C++).
65# _scope - Flags' scope relative to outer targets (targets using the given target).
6+ # _board_id - Board ID asociated with the target.
77#=============================================================================#
88function (_set_target_language_flags _target_name _board_id _language _scope)
99
10- parse_compiler_recipe_flags(${_board_id} compiler_recipe_flags
11- LANGUAGE "${_language} " )
10+ parse_compiler_recipe_flags(${_board_id} compiler_recipe_flags LANGUAGE "${_language} " )
1211
13- target_compile_options (${_target_name} ${_scope}
14- $<$<COMPILE_LANGUAGE:${_language} >:${compiler_recipe_flags} >)
12+ target_compile_options (${_target_name} ${_scope} $<$<COMPILE_LANGUAGE:${_language} >:${compiler_recipe_flags} >)
1513
1614endfunction ()
1715
1816#=============================================================================#
1917# Sets compiler flags on the given target, according also to the given board ID.
20- # _target_name - Name of the target (Executable or Library) to set flags on.
21- # _board_id - Target's bounded board ID .
18+ # _target_name - Name of the target (Executable or Library) to set flags on
19+ # _board_id - Board ID asociated with the target. .
2220#=============================================================================#
23- function (set_compiler_target_flags _target_name _board_id)
21+ function (set_target_compile_flags _target_name _board_id)
2422
2523 cmake_parse_arguments (parsed_args "" "LANGUAGE" "" ${ARGN} )
2624 parse_scope_argument(scope "${ARGN} "
@@ -47,11 +45,11 @@ endfunction()
4745#=============================================================================#
4846# Sets linker flags on the given target, according also to the given board ID.
4947# _target_name - Name of the target (Executable or Library) to set flags on.
50- # _board_id - Target's bounded board ID .
48+ # _board_id - Board ID asociated with the target .
5149#=============================================================================#
52- function (set_linker_flags _target_name _board_id)
50+ function (set_target_linker_flags _target_name _board_id)
5351
54- parse_linker_recpie_pattern(" ${_board_id} " linker_recipe_flags)
52+ parse_linker_recpie_pattern(${_board_id} linker_recipe_flags)
5553
5654 string (REPLACE ";" " " cmake_compliant_linker_flags "${linker_recipe_flags} " )
5755
@@ -63,12 +61,11 @@ endfunction()
6361# Sets compiler and linker flags on the given Executable target,
6462# according also to the given board ID.
6563# _target_name - Name of the target (Executable) to set flags on.
66- # _board_id - Target's bounded board ID.
6764#=============================================================================#
68- function (set_executable_target_flags _target_name _board_id )
65+ function (set_executable_target_flags _target_name)
6966
70- set_compiler_target_flags (${_target_name} " ${_board_id} " )
71- set_linker_flags (${_target_name} " ${_board_id} " )
67+ set_target_compile_flags (${_target_name} ${PROJECT_ ${ARDUINO_CMAKE_PROJECT_NAME} _BOARD} )
68+ set_target_linker_flags (${_target_name} ${PROJECT_ ${ARDUINO_CMAKE_PROJECT_NAME} _BOARD} )
7269
7370 target_link_libraries (${_target_name} PUBLIC m) # Add math library
7471
@@ -80,14 +77,11 @@ endfunction()
8077#=============================================================================#
8178# Sets upload/flash flags on the given target, according also to the given board ID.
8279# _target_name - Name of the target (Executable) to set flags on.
83- # _board_id - Target's bounded board ID.
8480#=============================================================================#
85- function (set_upload_target_flags _target_name _board_id _upload_port _return_var)
86- 87- set (upload_flags "" )
81+ function (set_upload_target_flags _target_name _upload_port _return_var)
8882
8983 # Parse and append recipe flags
90- parse_upload_recipe_pattern(" ${_board_id} " "${_upload_port} " upload_recipe_flags)
84+ parse_upload_recipe_pattern(${PROJECT_ ${ARDUINO_CMAKE_PROJECT_NAME} _BOARD} "${_upload_port} " upload_recipe_flags)
9185 list (APPEND upload_flags "${upload_recipe_flags} " )
9286
9387 set (target_binary_base_path "${CMAKE_CURRENT_BINARY_DIR} /${_target_name} " )
0 commit comments