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.
Asked
Active
Viewed 259 times
0
-
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 Answers
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
-
Thanks Alex, Actually i want to mask misra check for some file at folder level. So is there any way to do so? – shivkumar wadewale Jan 19 '22 at 08:39