Macro unrecognized when compiling assembly code

When compiling assembly code the macro is not recognized and throwing up error.
[ 85%] Building ASM object BLE/nRF52/modules/CMakeFiles/MODULES.dir/nrfx/mdk/gcc_startup_nrf52.S.obj
D:XXXX\gcc_7_2_1\tools\bin\arm-none-eabi-as.exe: unrecognized option `-BOARD_PCA10040
make[2]: *** [BLE/nRF52/modules/CMakeFiles/MODULES.dir/nrfx/mdk/gcc_startup_nrf52.S.obj] Error 1

Here BOARD_PCA10040 is project macro which is given to assembly code like any other C file.
Macros are added using add_definitions() method.

Can someone help me where to look into fix the error.

Please post the add_definitions() call that is adding the flag.

To avoid unexpected interpretation, it is strongly recommended to use add_compile_definitions rather than add_definitions.

I think add_compile_definitions is supported in latest version.
We are using 2.8.12 version in our project. The Cmake is picked from the configuration file which I am not able to edit.

I have installed the latest version 3.16 and I have generated the build file for the same

When I looked into flags.make file I still see these definitions as below

One thing I have observed
When I compile with Cmake version 3.16 and “MinGW Makefiles” generator
assembly code gets compiled without any issues (even when using add_definitions ())

But when I compile with 2.8 version cmake and “Eclipse CDT4 - Unix Makefiles” generator assembly code doesn’t get compiled.

I am not sure whether this issue is related to Generator!


There was a recent issue fixed with GNU’s assembler where its compile definition flag was incorrect. It will be fixed in 3.18.