<div dir="ltr">>  Is that a leftover, or is the other reference to -2 just omitted from your example...?<div><br></div><div>That's a leftover indeed. :)</div><div><br></div><div>--Nico</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 23, 2015 at 12:45 PM David Cole <<a href="mailto:DLRdave@aol.com">DLRdave@aol.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You're welcome.<div><br></div><div>I see you have ${file}-2.h5m in only one place, though... Is that a leftover, or is the other reference to -2 just omitted from your example...?</div><div><br></div><div><br></div><div>Cheers,</div><div>David C.</div><div><br></div><div><br><br>On Monday, November 23, 2015, Nico Schlömer <<a href="mailto:nico.schloemer@gmail.com" target="_blank">nico.schloemer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks David for your explanations. I've now reached a good solution:<div><br></div><div>Fetch the data:<br><div>```</div><div><div>INCLUDE(ExternalData)</div><div>set(</div><div>  ExternalData_URL_TEMPLATES</div><div>  "<a href="https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)" target="_blank">https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)</a>"</div><div>  )</div><div>foreach(file ${input_files})</div><div>  ExternalData_Expand_Arguments(</div><div>    noshTestFetchData</div><div>    OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test/data/${file}.e}</div><div>    )</div><div>endforeach()</div><div>ExternalData_Add_Target(noshTestFetchData)</div></div><div>```</div></div><div>Define conversion commands:</div><div>```</div><div><div>foreach(file ${input_files})</div><div>  LIST(APPEND FILES2 ${file}-2.h5m)<br></div><div>  add_custom_command(</div><div>    DEPENDS ${file}.e</div><div>    COMMAND convert ${file}.e ${file}.h5m</div><div>    OUTPUT ${file}.h5m</div><div>    )</div></div><div>endforeach()<br></div><div>```</div><div>Add a custom target with ALL:</div><div>```</div><div><div>add_custom_target(split2 ALL</div><div>  SOURCES ${FILES2}</div><div>  )</div></div><div>```</div><div>Adding the output files to the SOURCES makes the target do what's its supposed to do.</div><div><br></div><div>Cheers,</div><div>Nico</div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 22, 2015 at 11:59 PM David Cole <<a>DLRdave@aol.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You don't. You just assume all relevant targets have already been built by the time you run the tests... There's no such thing as a test from an add_test call depending on a target.<div><br></div><div>There **is** a dependency, of course, if you are using one of the build products in your test, but it's assumed that everything is already built at test time.</div><div><br></div><div>There is not yet a notion of connecting certain tests to certain build targets.</div><div><br></div><div>So, for example, there is no way to re-run only the tests affected by things which have changed since the last build, because there is no connection between targets and tests.</div><div><br></div><div>People have artificially created such connections using test labels, and running subsets of tests by label, but there is no official dependency from tests back to targets.</div><div><br></div><div><br></div><div>D</div><div><br></div><div><br><div><br>On Sunday, November 22, 2015, Nico Schlömer <<a>nico.schloemer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Aha, this was a misunderstanding of me then. Thanks!<div>How do I make a test depend on a target then?</div><div><br></div><div>Cheers,</div><div>Nico<br><div><br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 22, 2015 at 8:58 PM David Cole <<a>DLRdave@aol.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The DEPENDS property of a test is meant to ensure test running order in the case of parallel testing... It simply ensures that one test runs before another. It is not connected to the build system at all. It's different than target dependencies.<div><br></div><div><br></div><div>D</div><div><br></div><div><br><br>On Sunday, November 22, 2015, David Cole <<a>DLRdave@aol.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What do you mean by "depend" in this case? All libs and exes should be built during a "make" or "make all" or "make install" ... And all that should be done before any tests get run.<div><br></div><div>Simply typing "ctest" to execute all the tests never does any building. The assumed workflow is that you build stuff first and then run the tests.</div><div><br></div><div>If you want, you can add a custom target that runs a test, and make that custom target depend on any other targets, but ctest still won't know about it. Only "make custom_test_target" will...</div><div><br></div><div><br></div><div>D</div><div><br></div><div><br><br>On Sunday, November 22, 2015, Nico Schlömer <<a>nico.schloemer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for the hints!<div>I'm almost there now, the only thing missing is to have my test depend on the custom_target. This</div><div>```</div><div><div>SET_TESTS_PROPERTIES(testname PROPERTIES DEPENDS convert)</div></div><div>```</div><div>doesn't do the trick: The target `convert` isn't executed before `ctest`.</div><div><br></div><div>Any hints?</div><div><br></div><div>Cheers,</div><div>Nico</div><div><br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 22, 2015 at 3:18 AM David Cole <<a>DLRdave@aol.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Did you try using full path names for the add_custom_command file names?<div><br></div><div>And the NAME/COMMAND form of the add_test command?<br><br>Also, I've always found custom commands to work best when they're associated with a target. And if it was part of a target you could make the target depend on the external data target with add_dependencies if necessary.</div><div><br></div><div><br></div><div>HTH,</div><div>David C.</div><div><br><br>On Saturday, November 21, 2015, Nico Schlömer <<a>nico.schloemer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi everyone,</div><div><br></div>I would like to create a CMake test that does the following:<br> * Download a file from an external resource<br> * Do something with the file<br> * compile an executable myTest<br> * execute myTest outputfile<br><br>Using ExternalData for downloading the file works well, but the second step (file conversion, in this example cp for simplicity) does not work:<div>```</div><div><div>cmake_minimum_required(VERSION 3.2)</div><div><br></div><div>project(mytest)</div><div><br></div><div># Download the files</div><div>INCLUDE(ExternalData)</div><div>set(</div><div>  ExternalData_URL_TEMPLATES</div><div>  "<a href="https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)" target="_blank">https://downloads.sourceforge.net/project/noshdata/%(algo)/%(hash)</a>"</div><div>  )</div><div>ExternalData_Expand_Arguments(</div><div>  testFetchData</div><div>  OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test.e}</div><div>  )</div><div>ExternalData_Add_Target(testFetchData)</div><div><br></div><div>add_custom_command(</div><div>  OUTPUT test.g</div><div>  COMMAND cp test.e test.g</div><div>  DEPENDS test.e</div><div>  )</div><div><br></div><div>ADD_EXECUTABLE("myTest" main.cpp)</div><div><br></div><div>add_test(myTest test.g)</div>```<br>I suppose I'm missing something about the dependencies here; after all, the `add_custom_command` has to wait for `testFetchData` to complete. Likewise, `add_test` has to wait for `add_custom_command` to complete.<br><br>Hints appreciated.</div><div><br></div><div>Cheers,</div><div>Nico</div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div></div></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>