1+ #=============================================================================#
2+ # Sets compiler flags on the given target using the given board ID, compiler language and scope.
3+ # _target_name - Name of the target (Executable or Library) to set flags on.
4+ # _board_id - Target's bounded board ID.
5+ # _language - Language for which flags are set (such as C/C++).
6+ # _scope - Flags' scope relative to outer targets (targets using the given target).
7+ #=============================================================================#
8+ function (_set_target_language_flags _target_name _board_id _language _scope)
9+
10+ parse_compiler_recipe_flags(${_board_id} compiler_recipe_flags
11+ LANGUAGE "${_language} " )
12+
13+ target_compile_options (${_target_name} ${_scope}
14+ $<$<COMPILE_LANGUAGE:${_language} >:${compiler_recipe_flags} >)
15+
16+ endfunction ()
17+
118#=============================================================================#
219# Sets compiler flags on the given target, according also to the given board ID.
320# _target_name - Name of the target (Executable or Library) to set flags on.
@@ -10,18 +27,18 @@ function(set_compiler_target_flags _target_name _board_id)
1027 DEFAULT_SCOPE PUBLIC )
1128
1229 if (parsed_args_LANGUAGE)
30+ _set_target_language_flags(${_target_name} ${_board_id} ${parsed_args_LANGUAGE} ${scope} )
1331
14- parse_compiler_recipe_flags("${_board_id} " compiler_recipe_flags
15- LANGUAGE "${parsed_args_LANGUAGE} " )
16-
17- target_compile_options (${_target_name} ${scope}
18- $<$<COMPILE_LANGUAGE:${parsed_args_LANGUAGE} >:${compiler_recipe_flags} >)
32+ else () # No specific language requested - Use all
1933
20- else ()
34+ get_cmake_compliant_language_name(asm lang)
35+ _set_target_language_flags(${_target_name} ${_board_id} ${lang} ${scope} )
2136
22- parse_compiler_recipe_flags("${_board_id} " compiler_recipe_flags)
37+ get_cmake_compliant_language_name(c lang)
38+ _set_target_language_flags(${_target_name} ${_board_id} ${lang} ${scope} )
2339
24- target_compile_options (${_target_name} ${scope} ${compiler_recipe_flags} )
40+ get_cmake_compliant_language_name(cpp lang)
41+ _set_target_language_flags(${_target_name} ${_board_id} ${lang} ${scope} )
2542
2643 endif ()
2744
0 commit comments