[CMake] Output assembly (g++ -S)

David Doria daviddoria at gmail.com
Thu Oct 18 21:47:41 EDT 2012


I am trying to produce the .s file that "g++ -S file.cpp" would
produce, but on a CMake target (because I want the include path that
I've setup through CMake, etc.)

Consider a simple demo:

PROJECT(Assembly)
ADD_EXECUTABLE(Assembly Assembly.cpp ) # this produces an 'Assembly' executable

I tried to do this:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -S")

but I get:

Linking CXX executable AssemblyAssembly
c++: warning: CMakeFiles/Assembly.dir/Assembly.cpp.o: linker input
file unused because linking not done

I also tried:

set_target_properties(Assembly PROPERTIES COMPILE_FLAGS "-S")

but I get:

"file format not recognized; treating as linker script"

Any suggestions on how to do this?

Thanks,

David


More information about the CMake mailing list