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

Luca Cappa luca.cappa at sequoia.it
Mon Jan 11 04:52:07 EST 2010


Hi Arne,

I think this cmake script shows what you need to do to add a compiler flag  
for each source file.
It adds a dummy flag "/flagadded:FILE_NAME" for each source file according  
to its name.

project(flags_per_file)
cmake_minimum_required(VERSION 2.6)

set(SOURCES x1.c x2.c x3.c)
add_executable(executable ${SOURCES})

foreach(FILE ${SOURCES})
   set_source_files_properties (${FILE}
	  PROPERTIES
	  COMPILE_FLAGS "/flagadded:${FILE}")
   message("${FILE} -->> /flagadded:${FILE}")
endforeach(FILE in ${SOURCES})


Greetings,
Luca


On Sat, 09 Jan 2010 22:02:49 +0100, Arne Pagel <arne at pagelnet.de> 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.
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at  
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:  
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


-- 
--

Luca Cappa
R&D
Sequoia IT s.r.l.
Via L. Einaudi, 25
10024 Moncalieri (To) Italy
www.sequoia.it

CONFIDENZIALE: Questo messaggio e gli eventuali allegati sono  
confidenziali e riservati. Se vi è stato recapitato per errore e non siete  
fra i destinatari elencati, siete pregati di darne immediatamente avviso  
al mittente. Le informazioni contenute non devono essere mostrate ad  
altri, né utilizzate, memorizzate o copiate in qualsiasi forma.

CONFIDENTIALITY: This  e-mail  and  any attachments are confidential and  
may be privileged. If  you are not a named recipient, please notify the  
sender immediately and do not disclose the contents to another person, use  
it for any purpose or store or copy the information in any medium.


More information about the CMake mailing list