Creating List file outputs from each source file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Creating List file outputs from each source file

Thomas Fuller

I hope this is a simple question and I'm just missing something fundamental.

I'm trying to emulate a binary build manager for an embedded Cortex-M0 target using a CMake project. I'm having some trouble figuring out how to generate list files for each dependency of my executable target.

The current build system, when compiling a file called main.c passes -Wa,-alh=.\CortexM0\ARM_GCC_493\Debug/main.lst as an argument to gcc. I'd like to do something similar, but I can't figure out how to get CMake to use the current filename being compiled to save the file.

I've looked at the get_filename_component command, but it appears only to get the filename of the output:

add_executable(TestExe main.c)
get_filename_component(curr_name TestExe NAME_WM)

As expected, this prints TestExe instead of the hoped for main

Is there a simple variable I'm overlooking that I could put in my toolchain file's CMAKE_C_FLAGS like -Wa,-alh=${CURR_SOURCE}.lst? Or some other method that I'm not seeing?

System info:

  • Windows 10
  • Msys shell
  • CMake 3.7.2
  • arm-none-eabi-gcc v4.9.3

-Thomas Fuller


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: