<font size=2 face="Arial">I want to make an executable depend on output
of a custom command. The custom command just copies a file to a place where
the executable will be able to find it. I find that I can't get a dependency
between an executable and, essentially, a file to work.</font>
<br>
<br><font size=2 face="Arial">For example, this doesn't work:</font>
<br>
<br><font size=2 face="Arial">ADD_EXECUTABLE(foo ${foo_SOURCES} ${foo_HEADERS})</font>
<br>
<br><font size=2 face="Arial">ADD_CUSTOM_COMMAND(</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;OUTPUT &quot;${PROJECT_BINARY_DIR}/bar.ini&quot;</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;COMMAND ${CMAKE_COMMAND} -E
copy &quot;${PROJECT_SOURCE_DIR}/bar.ini&quot; &quot;${PROJECT_BINARY_DIR}&quot;</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;DEPENDS &quot;${PROJECT_SOURCE_DIR}/bar.ini&quot;</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;COMMENT &quot;Localizing \&quot;bar.ini\&quot;&quot;)</font>
<br>
<br><font size=2 face="Arial">ADD_DEPENDENCIES(foo &quot;${PROJECT_BINARY_DIR}/bar.ini&quot;)</font>
<br>
<br><font size=2 face="Arial">I know it'll work if I was generating a source
file and feeding that into ${foo_SOURCES}, but that didn't seem like the
right thing to do.</font>
<br><font size=2 face="Arial">I can also get it to work if I add another
target like so:</font>
<br>
<br><font size=2 face="Arial">ADD_EXECUTABLE(foo ${foo_SOURCES} ${foo_HEADERS})</font>
<br>
<br><font size=2 face="Arial">ADD_CUSTOM_COMMAND(</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;OUTPUT &quot;${PROJECT_BINARY_DIR}/bar.ini&quot;</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;COMMAND ${CMAKE_COMMAND} -E
copy &quot;${PROJECT_SOURCE_DIR}/bar.ini&quot; &quot;${PROJECT_BINARY_DIR}&quot;</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;DEPENDS &quot;${PROJECT_SOURCE_DIR}/bar.ini&quot;</font>
<br><font size=2 face="Arial">&nbsp; &nbsp;COMMENT &quot;Localizing \&quot;bar.ini\&quot;&quot;)</font>
<br>
<br><font size=2 face="Arial">ADD_CUSTOM_TARGET(copy_bar.ini DEPENDS &quot;${PROJECT_BINARY_DIR}/bar.ini&quot;)</font>
<br>
<br><font size=2 face="Arial">ADD_DEPENDENCIES(foo copy_bar.ini)</font>
<br>
<br><font size=2 face="Arial">So do I have to have this additional indirection
with the extra target? I have way too many targets as is. Is there anyway
to get the first approach to work? It's like I need to add a file to ${foo_SOURCES}
or ${foo_HEADERS} that isn't compiled or that doesn't show up in the IDE.
And can this be done after the ADD_EXECUTABLE call, or does it have to
be before?</font>
<br><font size=2 face="Arial">-------------------------------------------------------------<br>
Aaron Wright</font>
<br>