Skip to content

Commit

Permalink
Update compiler options to support IAR [AP-1823] (#175)
Browse files Browse the repository at this point in the history
Adding options to support the IAR compiler for Asensing.

---------

Co-authored-by: Matt Woodward <[email protected]>
Co-authored-by: Christian Reimer <[email protected]>
  • Loading branch information
3 people committed Jul 31, 2024
1 parent 68306be commit 65c9a39
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 21 deletions.
30 changes: 15 additions & 15 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@ format:
require_valid_layout: false
layout_passes: {}
markup:
bullet_char: '*'
bullet_char: "*"
enum_char: .
first_comment_is_literal: false
literal_comment_pattern: null
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
explicit_trailing_pattern: '#<'
explicit_trailing_pattern: "#<"
hashruler_min_length: 10
canonicalize_hashrulers: true
enable_markup: true
lint:
disabled_codes:
- C0103 # Invalid argument name
- C0113 # Missing COMMENT in statement which allows it
- C0111 # Missing docstring on function or macro declaration
function_pattern: '[0-9a-z_]+'
macro_pattern: '[0-9A-Z_]+'
global_var_pattern: '[A-Z][0-9A-Z_]+'
- C0103 # Invalid argument name
- C0113 # Missing COMMENT in statement which allows it
- C0111 # Missing docstring on function or macro declaration
function_pattern: "[0-9a-z_]+"
macro_pattern: "[0-9A-Z_]+"
global_var_pattern: "[A-Z][0-9A-Z_]+"
internal_var_pattern: _[A-Z][0-9A-Z_]+
local_var_pattern: '[a-z][a-z0-9_]+'
local_var_pattern: "[a-z][a-z0-9_]+"
private_var_pattern: _[0-9a-z_]+
public_var_pattern: '[A-Z][0-9A-Z_]+'
argument_var_pattern: '[a-z][a-z0-9_]+'
keyword_pattern: '[A-Z][0-9A-Z_]+'
public_var_pattern: "[A-Z][0-9A-Z_]+"
argument_var_pattern: "[a-z][a-z0-9_]+"
keyword_pattern: "[A-Z][0-9A-Z_]+"
max_conditionals_custom_parser: 2
min_statement_spacing: 1
max_statement_spacing: 2
max_returns: 6
max_branches: 40 # Default target: 12
max_arguments: 6 # Default target: 5
max_branches: 40 # Default target: 12
max_arguments: 6 # Default target: 5
max_localvars: 15
max_statements: 120 # Default target: 50
max_statements: 125 # Default target: 50
encode:
emit_byteorder_mark: false
input_encoding: utf-8
Expand Down
24 changes: 20 additions & 4 deletions CompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,31 @@ function(swift_set_compile_options)
foreach(target ${targets})
if(cxx_enabled)
if(x_EXCEPTIONS)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fexceptions>)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
#target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--exceptions>)
else()
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fexceptions>)
endif()
else()
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--no_exceptions>)
else()
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
endif()
endif()

if(x_RTTI)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-frtti>)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
#target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--rtti>)
else()
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-frtti>)
endif()
else()
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "IAR")
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--no_rtti>)
else()
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
endif()
endif()
endif()

Expand Down
18 changes: 16 additions & 2 deletions LanguageStandards.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,27 @@ function(swift_set_language_standards)
set(C_EXTENSIONS OFF)
endif()

set_target_properties(${x_UNPARSED_ARGUMENTS}
if(${CMAKE_C_COMPILER_ID} STREQUAL "IAR")
set_target_properties(${x_UNPARSED_ARGUMENTS}
PROPERTIES
C_STANDARD_REQUIRED ON
C_EXTENSIONS ${C_EXTENSIONS}
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
target_compile_options(${x_UNPARSED_ARGUMENTS} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:--strict>)
if(NOT ${C_EXTENSIONS})
target_compile_options(${x_UNPARSED_ARGUMENTS} PRIVATE $<$<COMPILE_LANGUAGE:C>:--strict>)
endif()
else()
set_target_properties(${x_UNPARSED_ARGUMENTS}
PROPERTIES
C_STANDARD ${x_C}
C_STANDARD_REQUIRED ON
C_EXTENSIONS ${C_EXTENSIONS}
CXX_STANDARD ${x_CXX}
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
)
endif()
endfunction()

0 comments on commit 65c9a39

Please sign in to comment.