Create a dissasembly from a single c file

Hi, I want to compile and produce an assembly file from a c file.
Am translating some makefiles where one produces a single dissasembly file from a c file to determine some info about how this compiler aligns data and so on.
They just do: $(CC) -o disassem.s -c -S dissassem.c
Have tried with add_executable and change the options but it wants to link which fails.
Like :
add_executable(create_offset asm-offsets.c)

OUTPUT_NAME asm-offsets.s
Is there a better way?

You’d probably have to use execute_process() or custom_target() to run the compiler to generate the asm-offsets.s file. You hint that after creating the disassembly file then something parses asm-offsets.s file and then generates a header file or something. Then that all needs to be done a project generation time or before compiling files that need the data.

I think the Makefiles generators support this? I don’t quite see how to do it from the main entry points, but this works:

$ make -f Utilities/KWIML/test/CMakeFiles/kwiml_test.dir/build.make Utilities/KWIML/test/CMakeFiles/kwiml_test.dir/test.c.s
Compiling C source to assembly CMakeFiles/kwiml_test.dir/test.c.s
$ cat Utilities/KWIML/test/CMakeFiles/kwiml_test.dir/test.c.s

Yes, maybe but that is not my immediate problem.
For the moment it tries to link and fails which halts the compilation.

Interesting, I did not understand what to enter in my CMakeList though.
I found the generator code and a CMAKE_CREATE_ASSEMBLER variable but I could not find that in LLVM compiler which I want to support as an alternative compiler.
For now I solved it with a add_custom_command that calls the CMAKE_C_COMPILER .
Thanks anyway

For the Makefiles generator, there’s nothing to add. You just need to “know” what file to ask for the relevant .s file to create.

Well I just tried to understand what the generator did. I do not know what to enter in my CMakeLists.txt for getting just a .s file and not trigger any linking.
I am using a cross-compiler and am building a new OS so I do not have anything to link to (yet).
But the old add_custom_target is good enough I think.