Add compile flags or defines without adding to ASM_ settings

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Add compile flags or defines without adding to ASM_ settings

Richard A. Smith
I'm having a tough time figuring out how to get some compile flags added
to one of my targets without it breaking the ASM source file compile.

I currently have a build with a C_CLAGS setting that looks like below:


The only important part of the above is the GCC_DEBUG_FLAGS which looks
like this:


I'm in the process of creating a "release" build.  I'd prefer to make a
release target instead of generating with 'cmake -D RELEASE'

For my release build.  I'd like to have the same options as above except
for  ${GCC_DEBUG_FLAGS}.  Those should be omitted.  However, I'd still
like them included for all the other targets.

So I changed CMAKE_C_FLAGS to the following:


Essentially removing setting the debug flags by default.

Now my release target works fine.  No debug settings.

The problem comes when I try to add those debug options back into the
other builds using the per target config methods.

Doesn't matter if I use target_compile_options() or
set_target_properties() and change the COMPILE_FLAGS or COMPILE_OPTIONS
property the result is the same.

What happens is that all the options that I specify also get added to
the ASM_FLAGS setting.

In my sources list what looks similar to the following:

         ${PROJ_DIRECTORY}/asm_file.S )

When -DDEBUG -DMXC_ASSERT_ENABLE get added to ASM_FLAGS then the
assembler chokes on -DDEBUG

/usr/bin/arm-none-eabi-as: unrecognized option '-EBUG'

I've also tried breaking the options apart so that the -D options are on
their own and I used target_compile_definitions() to set just the defines.

The result is still the same but instead of getting added to ASM_FLAGS
they get added to ASM_DEFINES but the assembler still chokes.

How can I add compile options to my targets that only get added to
C_FLAGS and not to my ASM_FLAGS?


Richard A. Smith
[hidden email]

Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: