Macro unrecognized when compiling assembly code

Hi,
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.

Hi,
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
add_compile_definitions(BOARD_PCA10040)
add_compile_definitions(CONFIG_GPIO_AS_PINRESET)
add_compile_definitions(FLOAT_ABI_HARD)
add_compile_definitions(INITIALIZE_USER_SECTIONS)
add_compile_definitions(NO_VTOR_CONFIG)

When I looked into flags.make file I still see these definitions as below
ASM_DEFINES = -DBOARD_PCA10040 -DCONFIG_GPIO_AS_PINRESET -DFLOAT_ABI_HARD

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!

add_definitions(-DBOARD_PCA10040)
add_definitions(-DCONFIG_GPIO_AS_PINRESET)

There was a recent issue fixed with GNU’s assembler where its compile definition flag was incorrect. It will be fixed in 3.18. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4838