<div class="gmail_quote">On Sat, Mar 28, 2009 at 7:26 PM, James Bigler <span dir="ltr">&lt;<a href="mailto:jamesbigler@gmail.com">jamesbigler@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Below.<div class="im"><br>
<br>
On Mar 28, 2009, at 12:21 PM, Tyler Roscoe &lt;<a href="mailto:tyler@cryptio.net" target="_blank">tyler@cryptio.net</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sat, Mar 28, 2009 at 12:16:21AM -0600, James Bigler wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have an add_custom_command in a subdirectory, and I&#39;m trying to use<br>
that output as a dependency in a parent directory.<br>
<br>
Unfortunately, the parent directory doesn&#39;t see that I made a rule<br>
(add_custom_command) for the file in the subdirectory.<br>
<br>
<br>
top level CMakeLists.txt:<br>
...<br>
add_subdirectory(sub1)<br>
<br>
add_custom_target(generate ALL<br>
 DEPENDS ${CMAKE_BINARY_DIR}/myfile.txt<br>
 )<br>
<br>
sub1/CMakeLists.txt:<br>
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/myfile.txt<br>
 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/genmyfile.cmake<br>
 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}<br>
 )<br>
</blockquote>
<br>
I would just do the add_custom_target in the same CMakeLists where you<br>
do the add_custom_command. That target will still be available from your<br>
top-level CMakeLists. I use this approach all over the place.<br>
<br>
tyler<br>
</blockquote>
<br></div>
Unfortunately, I have several directories that all pool their files into the same target. I don&#39;t want to have a single target per file as this would clutter up Visial Studio projects quite quickly.<br>
<br>
Unless there&#39;s a different way to make the add_custom_command behave globally I&#39;ll have to somehow call this function only from the directory I call add_custom_target from. :(</blockquote><div><br>See the thread titled &quot;problem with add_custom_command / add_custom_target in different directories&quot; from a month ago.  I had the same exact problem.  There were two suggested solutions.<br>
<br>1. Make add_custom_command and add_custom_target be in the same directory<br>2. Create helper targets using add_custom_command and add_custom_target along the way and then add them to a global target.<br><br><a href="http://www.cmake.org/pipermail/cmake/2009-February/027314.html">http://www.cmake.org/pipermail/cmake/2009-February/027314.html</a><br>
</div></div><br>-- <br>Philip Lowman<br>