I got it working, thanks!<div><br></div><div>Turns out that whenever my dependency generator changes the deps file, CMake notices this fact (because the file is included) and does a reconfigure anyway. So all I have to do is "make" and everything works. Sweet!</div>
<div><br></div><div>In case you are interested, here's what I did:</div><div><br></div><div>The dependency file generator creates a dependency entry for each target in the library:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><div>set(TART_TESTING_ASSERTS_DEPS</div></div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/core/AssertionFailureException.tart"</div></div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/core/Debug.tart"</div>
</div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/core/Iterable.tart"</div></div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/core/String.tart"</div></div><div><div>)</div>
</div><div><div><br></div></div><div><div>set(TART_TESTING_TEST_DEPS</div></div><div><div> "/home/talin/Projects/tart/trunk/libtesting/tart/testing/Asserts.tart"</div></div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/core/Debug.tart"</div>
</div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/core/Throwable.tart"</div></div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/reflect/ComplexType.tart"</div></div><div><div>
"/home/talin/Projects/tart/trunk/stdlib/tart/reflect/Method.tart"</div></div><div><div> "/home/talin/Projects/tart/trunk/stdlib/tart/reflect/Type.tart"</div></div><div><div>)</div></div></blockquote>
<div><div><br></div><div>The name of the variable is generated by taking the target name, replacing all '/' with '_', and then converting to upper case. So "tart/testing/Test.tart" becomes "TART_TESTING_TEST_DEPS".</div>
<div><br></div><div>I then import the dependency file in my CMakeLists.txt:</div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div>include(${CMAKE_CURRENT_BINARY_DIR}/libtesting.deps OPTIONAL)</div>
</div></div></blockquote><div><div><div><br></div><div>For each target, I generate the name of the variable that contains the deps for that target, using the same algorithm as used in the generator program:</div><div><br>
</div></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div><div># Generate the deps variable name</div></div></div></div><div><div><div><div>string(REGEX REPLACE ".tart\$" "" DEPS_NAME "${SRC_FILE}")</div>
</div></div></div><div><div><div><div>string(TOUPPER "${DEPS_NAME}" DEPS_NAME)</div></div></div></div><div><div><div><div>string(REGEX REPLACE "[^a-zA-Z0-9]" "_" DEPS_NAME "${DEPS_NAME}")</div>
</div></div></div></blockquote><div><div><div><div><br></div><div>And then use recursive variable expansion to make the deps name a dependency of the target:</div></div></div></div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><div>DEPENDS "${SRC_FILE}" tartc ${${DEPS_NAME}_DEPS}</div></div></blockquote><div><div><br></div><div>Finally, at the end of the CMakeLists.txt, I invoke the dependency generator program to generate the new deps file for the next build:</div>
<div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div># Generate dependency info</div></div></div><div><div><div>add_custom_command(</div>
</div></div><div><div><div> OUTPUT libtesting.deps</div></div></div><div><div><div> COMMAND gendeps -o libtesting.deps ${TESTING_BC_FILES}</div></div></div><div><div><div> DEPENDS ${TESTING_BC_FILES} gendeps</div>
</div></div><div><div><div> COMMENT "Generating dependencies for libtesting.bc")</div></div></div></blockquote><div><div><div><br></div><div>CMake will notice that the date stamp has changed and reconfigure next time I run make. One final touch I want to make is to not change the date stamp on the output file unless the contents have changed.</div>
<div><br></div></div><div class="gmail_quote">On Wed, Dec 30, 2009 at 7:11 PM, Alan W. Irwin <span dir="ltr"><<a href="mailto:irwin@beluga.phys.uvic.ca">irwin@beluga.phys.uvic.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 2009-12-30 12:30-0800 Talin wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That is more along the lines of what I was looking for. Thanks! :)<br>
One further question: Using the technique you describe, the dependency file<br>
will need to be regenerated each time a source file changes - i.e. if I add<br>
a new "import" statement to a source file, the list of dependencies will<br>
change, which will require the dependency file to be rebuilt. Can that<br>
rebuild happen as part of the normal build, or can that only be done at<br>
CMake time?<br>
</blockquote>
<br></div>
Good question. The dependency information is used by CMake (at CMake time)<br>
to configure a custom command to be run at build time with the correct<br>
dependencies. Thus, the answer to your question must be that build time is<br>
too late to collect the dependency information used by CMake. Instead, you<br>
must do that at CMake time like I outlined.<div><div></div><div class="h5"><br>
<br>
Alan<br>
__________________________<br>
Alan W. Irwin<br>
<br>
Astronomical research affiliation with Department of Physics and Astronomy,<br>
University of Victoria (<a href="http://astrowww.phys.uvic.ca" target="_blank">astrowww.phys.uvic.ca</a>).<br>
<br>
Programming affiliations with the FreeEOS equation-of-state implementation<br>
for stellar interiors (<a href="http://freeeos.sf.net" target="_blank">freeeos.sf.net</a>); PLplot scientific plotting software<br>
package (<a href="http://plplot.org" target="_blank">plplot.org</a>); the libLASi project (<a href="http://unifont.org/lasi" target="_blank">unifont.org/lasi</a>); the Loads of<br>
Linux Links project (<a href="http://loll.sf.net" target="_blank">loll.sf.net</a>); and the Linux Brochure Project<br>
(<a href="http://lbproject.sf.net" target="_blank">lbproject.sf.net</a>).<br>
__________________________<br>
<br>
Linux-powered Science<br>
__________________________<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>-- Talin<br>
</div>