Use ALL to include your custom target in the default build of all.<div><br></div><div><a href="https://cmake.org/cmake/help/v3.4/command/add_custom_target.html">https://cmake.org/cmake/help/v3.4/command/add_custom_target.html</a></div><div><br></div><div><br></div><div>D</div><div><br><br>On Sunday, November 22, 2015, Nico Schlömer <<a href="mailto:nico.schloemer@gmail.com">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">I was under the impression that if I don't explicitly build a target, it won't get build. Perhaps I'm wrong here. In any case, this<div>```</div><div><div>add_custom_target(convert)</div><div>add_dependencies(convert testFetchData)</div><div>add_custom_command(</div><div>  TARGET convert</div><div>  COMMAND cp test.e test.g</div><div>  )</div></div><div>```</div><div>never gets executed on `make`, unlike all other targets (e.g., `<span style="line-height:1.5">testFetchData`)</span><span style="line-height:1.5">. (Full CMakeLists.txt at [1].) </span><span style="line-height:1.5">Explicitly calling `make convert` works alright.</span></div><div><br></div><div>Any idea why that might be?</div><div><br></div><div>Cheers,</div><div>Nico</div><div><br></div><div>[1] <a href="http://chunk.io/f/729beeab41fb4a7385ceb98b31a2ea0a" target="_blank">http://chunk.io/f/729beeab41fb4a7385ceb98b31a2ea0a</a><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 22, 2015 at 8:46 PM David Cole <<a href="javascript:_e(%7B%7D,'cvml','DLRdave@aol.com');" target="_blank">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">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 href="javascript:_e(%7B%7D,'cvml','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 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>