<div dir="ltr">Hi,<div><br></div><div><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">I hope this is a simple question and I'm just missing something fundamental.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">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.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">The current build system, when compiling a file called<span class="inbox-inbox-Apple-converted-space"> </span><code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">main.c</code><span class="inbox-inbox-Apple-converted-space"> </span>passes<span class="inbox-inbox-Apple-converted-space"> </span><code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">-Wa,-alh=.\CortexM0\ARM_GCC_493\Debug/main.lst</code><span class="inbox-inbox-Apple-converted-space"> </span>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.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">I've looked at the<span class="inbox-inbox-Apple-converted-space"> </span><a href="https://cmake.org/cmake/help/v3.7/command/get_filename_component.html" rel="nofollow noreferrer" style="margin:0px;padding:0px;border:0px;color:rgb(0,89,153);text-decoration:none">get_filename_component</a><span class="inbox-inbox-Apple-converted-space"> </span>command, but it appears only to get the filename of the output:</p><pre class="inbox-inbox-lang-c inbox-inbox-prettyprint inbox-inbox-prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;white-space:inherit"><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">add_executable</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="inbox-inbox-typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">TestExe</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> main</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">c</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
get_filename_component</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">curr_name </span><span class="inbox-inbox-typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">TestExe</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> NAME_WM</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
message</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">$</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">{</span><span class="inbox-inbox-pln" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">curr_name</span><span class="inbox-inbox-pun" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">})</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">As expected, this prints<span class="inbox-inbox-Apple-converted-space"> </span><code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">TestExe</code><span class="inbox-inbox-Apple-converted-space"> </span>instead of the hoped for<span class="inbox-inbox-Apple-converted-space"> </span><code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">main</code></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">Is there a simple variable I'm overlooking that I could put in my toolchain file's CMAKE_C_FLAGS like<span class="inbox-inbox-Apple-converted-space"> </span><code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">-Wa,-alh=${CURR_SOURCE}.lst</code>? Or some other method that I'm not seeing?</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">System info:</p><ul style="margin:0px 0px 1em 30px;padding:0px;border:0px;font-size:15px;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif"><li style="margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word">Windows 10</li><li style="margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word">Msys shell</li><li style="margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word">CMake 3.7.2</li><li style="margin:0px;padding:0px;border:0px;word-wrap:break-word">arm-none-eabi-gcc v4.9.3</li></ul><div><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px"><br></span></font></div></div><div><span style="font-size:15px;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">-Thomas Fuller</span><br></div></div>