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:

set(CMAKE_C_FLAGS "${GCC_PROCESSOR_FLAGS} ${GCC_OPTIMIZATION_FLAGS} ${GCC_WARNING_FLAGS} ${GCC_DEBUG_FLAGS} ${GCC_C_FLAGS} ")

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

set(GCC_DEBUG_FLAGS "-g3 -ggdb -DDEBUG -DMXC_ASSERT_ENABLE")

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:

set(CMAKE_C_FLAGS "${GCC_PROCESSOR_FLAGS} ${GCC_OPTIMIZATION_FLAGS} ${GCC_WARNING_FLAGS} ${GCC_C_FLAGS} ")

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:

set(PROJ_SOURCES
        ${PROJ_DIRECTORY}/file1.c
        ${PROJ_DIRECTORY}/file2.c
        ${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?

Thanks.

--
Richard A. Smith
sm...@whoop.com
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to