Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate assembly for a target

Tags:

I am trying to pass -S to GCC for one of my executables. I tried this:

set_target_properties(MyTarget PROPERTIES COMPILE_FLAGS "-S") 

but I get "file format not recognized; treating as linker script"

(It builds fine without that line)

Is there something wrong with passing -S like this? Or is there another way to have CMake output the assembly .s files?

like image 820
David Doria Avatar asked Oct 18 '12 22:10

David Doria


1 Answers

CMake has targets built in for both assembler and preprocessor output. For a file called src.cpp, CMake generates the target src.s for assembler output and src.i for the preprocessor output. It generates the assembler/preprocessor outputs for each target seperately in case the compile flags are different. Using the make generator for your CMake project, you can get the assembler and preprocessor outputs like this:

make src.s   # assembler output
make src.i   # preprocessor output
like image 172
ingomueller.net Avatar answered Sep 22 '22 12:09

ingomueller.net