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

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 11 16:00:05 EST 2010


On Saturday 09 January 2010, Arne Pagel wrote:
> 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.

Are you sure you really need that ?
If you enter "make help" in the directory of your target, you will see that 
there are also rules for building the object files foo.o and also for just 
generating the assembler files (foo.s).
I.e. you can manually enter "make ...path/foo.s" and this will produce the 
assembler file for you so you can look at it.

From my experience this is the typical use case: if something goes wrong, look 
at the assembler file of the file in question and check whether it makes 
sense. Do you need it for something else ?

Alex


More information about the CMake mailing list