[CMake] "rule" to generate assembler listings for each c file

Arne Pagel arne at pagelnet.de
Sat Jan 9 16:02:49 EST 2010


Hello,

I try to use cmake for crosscompiling an embedded project with arm-elf-gcc.
For a simple project, a CMakeLists.txt like this works fine for me:

cmake_minimum_required(VERSION 2.6)

SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER arm-elf-gcc)

SET (CMAKE_SHARED_LINKER_FLAGS_INIT "")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

SET (CMAKE_C_FLAGS "-O3 -g3 -Wall -L lib -mcpu=cortex-m3 -mthumb")
SET (CMAKE_EXE_LINKER_FLAGS "-mcpu=cortex-m3 -mthumb -nostartfiles -T link.ld")

add_executable (../test.elf startup.c main.c foo.c)
TARGET_LINK_LIBRARIES (../test.elf ${CMAKE_CURRENT_SOURCE_DIR}/lib/bar.a)


For debugging, I want gcc to export assembler listings for each c-file it compiles.

This can be done with adding -Wa,-ahl=file.lst to the C-Flags
SET (CMAKE_C_FLAGS "-O9 -g3 -Wall -L lib -mcpu=cortex-m3 -mthumb" -Wa,-ahl=file.lst)

But this is not exactly what I want,
instead of file.lst I want that "file" is replaced with the filename which make is currently 
processing.
The result should be foo.lst while processing foo.c and main.lst for main.c.

I know how I can solve it with make, but I have no idea how I could tell this to cmake.

I found CMAKE_CURRENT_LIST_FILE, but I don't know if it helps me.

Has anyone an Idea?

Best Regards
   Arne


More information about the CMake mailing list