<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">I&#39;ve got a problem that has been vexing me for several months: It seems that when I create a custom rule using add_custom_command, the DEPENDS clause sometimes works and sometimes doesn&#39;t, and I can&#39;t figure out why.<div>

<br></div><div>Here&#39;s what my custom rule looks like:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">  # Link with stdlib</font></div><div><font face="&#39;courier new&#39;, monospace">  string(REGEX REPLACE &quot;.tart\$&quot; &quot;.s&quot; ASM_FILE &quot;${SRC_FILE}&quot;)</font></div>

<div><font face="&#39;courier new&#39;, monospace">  add_custom_command(OUTPUT ${ASM_FILE}</font></div><div><font face="&#39;courier new&#39;, monospace">      COMMAND tartln -disable-fp-elim -filetype=asm ${TARTLN_OPTIONS} ${BC_FILE}</font></div>

<div><font face="&#39;courier new&#39;, monospace">          &quot;${PROJECT_BINARY_DIR}/stdlib/stdlib.bc&quot;</font></div><div><font face="&#39;courier new&#39;, monospace">          &quot;${PROJECT_BINARY_DIR}/libext/testing/testing.lib.bc&quot;</font></div>

<div><font face="&#39;courier new&#39;, monospace">      DEPENDS &quot;${BC_FILE}&quot; tartln stdlib testing.lib</font></div><div><font face="&#39;courier new&#39;, monospace">      COMMENT &quot;Linking Tart bitcode file ${BC_FILE}&quot;)</font></div>

<div><br></div><div>Now, the targets &#39;stdlib&#39; and &#39;testing.lib&#39; are almost identical in definition, however when I attempt to execute this rule it complains that it can&#39;t find a rule to build &#39;testing.lib&#39;. However, I can make both stdlib and testing.lib manually by typing &quot;make stdlib&quot; or &quot;make testing.lib&quot; respectively on the command line. So I know that both targets work.</div>

<div><br></div><div>The only significant difference between the two targets, as far as I can tell, is that the testing.lib target is one level deeper in the build hierarchy. That is, in my top-level CMakeLists.txt file, I include the subdirectories &quot;stdlib/&quot; and &quot;libext/testing/&quot;, which contain the CMakeLists.txt for the two libraries.</div>

<div><br></div><div>I&#39;ve tried putting $PROJECT_BINARY_DIR and $CMAKE_BINARY_DIR in front of testing.lib, neither of which seems to make any difference. I&#39;ve also tried depending on the actual build product (testing.lib.bc) rather than the abstract target testing.lib. Still no luck.</div>

<div><br></div><div>Can anyone suggest something else to try?</div></div></span><br>-- <br>-- Talin<br>