Skip to content

Commit 65c9a39

Browse files
sokhealyMatt Woodwardreimerix
authored
Update compiler options to support IAR [AP-1823] (#175)
Adding options to support the IAR compiler for Asensing. --------- Co-authored-by: Matt Woodward <[email protected]> Co-authored-by: Christian Reimer <[email protected]>
1 parent 68306be commit 65c9a39

File tree

3 files changed

+51
-21
lines changed

3 files changed

+51
-21
lines changed

.cmake-format.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,38 @@ format:
2323
require_valid_layout: false
2424
layout_passes: {}
2525
markup:
26-
bullet_char: '*'
26+
bullet_char: "*"
2727
enum_char: .
2828
first_comment_is_literal: false
2929
literal_comment_pattern: null
3030
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
3131
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
32-
explicit_trailing_pattern: '#<'
32+
explicit_trailing_pattern: "#<"
3333
hashruler_min_length: 10
3434
canonicalize_hashrulers: true
3535
enable_markup: true
3636
lint:
3737
disabled_codes:
38-
- C0103 # Invalid argument name
39-
- C0113 # Missing COMMENT in statement which allows it
40-
- C0111 # Missing docstring on function or macro declaration
41-
function_pattern: '[0-9a-z_]+'
42-
macro_pattern: '[0-9A-Z_]+'
43-
global_var_pattern: '[A-Z][0-9A-Z_]+'
38+
- C0103 # Invalid argument name
39+
- C0113 # Missing COMMENT in statement which allows it
40+
- C0111 # Missing docstring on function or macro declaration
41+
function_pattern: "[0-9a-z_]+"
42+
macro_pattern: "[0-9A-Z_]+"
43+
global_var_pattern: "[A-Z][0-9A-Z_]+"
4444
internal_var_pattern: _[A-Z][0-9A-Z_]+
45-
local_var_pattern: '[a-z][a-z0-9_]+'
45+
local_var_pattern: "[a-z][a-z0-9_]+"
4646
private_var_pattern: _[0-9a-z_]+
47-
public_var_pattern: '[A-Z][0-9A-Z_]+'
48-
argument_var_pattern: '[a-z][a-z0-9_]+'
49-
keyword_pattern: '[A-Z][0-9A-Z_]+'
47+
public_var_pattern: "[A-Z][0-9A-Z_]+"
48+
argument_var_pattern: "[a-z][a-z0-9_]+"
49+
keyword_pattern: "[A-Z][0-9A-Z_]+"
5050
max_conditionals_custom_parser: 2
5151
min_statement_spacing: 1
5252
max_statement_spacing: 2
5353
max_returns: 6
54-
max_branches: 40 # Default target: 12
55-
max_arguments: 6 # Default target: 5
54+
max_branches: 40 # Default target: 12
55+
max_arguments: 6 # Default target: 5
5656
max_localvars: 15
57-
max_statements: 120 # Default target: 50
57+
max_statements: 125 # Default target: 50
5858
encode:
5959
emit_byteorder_mark: false
6060
input_encoding: utf-8

CompileOptions.cmake

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,31 @@ function(swift_set_compile_options)
227227
foreach(target ${targets})
228228
if(cxx_enabled)
229229
if(x_EXCEPTIONS)
230-
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fexceptions>)
230+
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
231+
#target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--exceptions>)
232+
else()
233+
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fexceptions>)
234+
endif()
231235
else()
232-
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
236+
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
237+
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--no_exceptions>)
238+
else()
239+
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
240+
endif()
233241
endif()
234242

235243
if(x_RTTI)
236-
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-frtti>)
244+
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
245+
#target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--rtti>)
246+
else()
247+
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-frtti>)
248+
endif()
237249
else()
238-
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
250+
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
251+
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--no_rtti>)
252+
else()
253+
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
254+
endif()
239255
endif()
240256
endif()
241257

LanguageStandards.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,27 @@ function(swift_set_language_standards)
6060
set(C_EXTENSIONS OFF)
6161
endif()
6262

63-
set_target_properties(${x_UNPARSED_ARGUMENTS}
63+
if(${CMAKE_C_COMPILER_ID} STREQUAL "IAR")
64+
set_target_properties(${x_UNPARSED_ARGUMENTS}
65+
PROPERTIES
66+
C_STANDARD_REQUIRED ON
67+
C_EXTENSIONS ${C_EXTENSIONS}
68+
CXX_STANDARD_REQUIRED ON
69+
CXX_EXTENSIONS OFF
70+
)
71+
target_compile_options(${x_UNPARSED_ARGUMENTS} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--strict>)
72+
if(NOT ${C_EXTENSIONS})
73+
target_compile_options(${x_UNPARSED_ARGUMENTS} PRIVATE $<$<COMPILE_LANGUAGE:C>:--strict>)
74+
endif()
75+
else()
76+
set_target_properties(${x_UNPARSED_ARGUMENTS}
6477
PROPERTIES
6578
C_STANDARD ${x_C}
6679
C_STANDARD_REQUIRED ON
6780
C_EXTENSIONS ${C_EXTENSIONS}
6881
CXX_STANDARD ${x_CXX}
6982
CXX_STANDARD_REQUIRED ON
7083
CXX_EXTENSIONS OFF
71-
)
84+
)
85+
endif()
7286
endfunction()

0 commit comments

Comments
 (0)