0

I used Set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "--saferc=none") to mask misra check in directory, but I got Warning: Ccv850:Warning:option "-D--saferc=none" ignored due to invalid argument. Expected name or name=string.

  • The property [COMPILE_DEFINITIONS](https://cmake.org/cmake/help/latest/prop_dir/COMPILE_DEFINITIONS.html) contains **macro definitions**, which will be available in C/C++ code. For pass general **options** to the compiler you can use e.g. command [target_compile_options](https://cmake.org/cmake/help/latest/command/target_compile_options.html). See [duplicate question](https://stackoverflow.com/questions/11783932/how-do-i-add-a-linker-or-compile-flag-in-a-cmake-file) and its answers for more solutions. – Tsyvarev Jan 19 '22 at 07:00

1 Answers1

0

You should basically never use directory properties, ever.

For whichever targets cannot compile without the flag, you can add it like so:

target_compile_options(
  my_target
  PRIVATE 
  "$<$<CXX_COMPILER_ID:GHS>:--saferc=none>"
  "$<$<C_COMPILER_ID:GHS>:--saferc=none>"
)

My understanding is that --saferc=none is a Green Hills flag, hence the check for $<CXX_COMPILER_ID:GHS>. If you are only using one of C or C++, you can delete the flag for the other language.

Alex Reinking
  • 16,724
  • 5
  • 52
  • 86