Greetings,<br><br>I&#39;ll stir the pot a little bit more in this subject, since I may not have explained myself clearly last time, and I haven&#39;t been able to solve it by my own means. I apologize for the extra noise ;)<br>
So, restating: I want the &quot;test&quot; target (and not &quot;all&quot;, nor any other target) to build my test executables. According to the CMake documentation, this is possible through something like<br><br><span style="font-family: courier new,monospace;">add_test(fooTest ${CMAKE_CTEST_COMMAND}</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-and-test</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;${CMAKE_CURRENT_SOURCE_DIR}/test&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;${CMAKE_CURRENT_BINARY_DIR}/test&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-two-config</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-generator ${CMAKE_GENERATOR}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-makeprogram ${CMAKE_BUILD_TOOL}</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-project myProj</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --test-command </span><span style="font-family: courier new,monospace;">fooTest)</span><br>
<br>where <span style="font-family: courier new,monospace;">${CMAKE_CURRENT_SOURCE_DIR}/test</span> points to a standalone CMake project. Being standalone, I have to perform lengthy initializations (or maybe import the tested project?) that I&#39;d like to avoid. If someone out there knows any alternatives to this scenario, I&#39;d be grateful to read them.<br>
<br>Cheers, and thanks in advance,<br><br>Adolfo Rodríguez Tsouroukdissian.<br><br><br><div class="gmail_quote">On Fri, Jan 30, 2009 at 10:31 AM, Adolfo Rodríguez <span dir="ltr">&lt;<a href="mailto:dofo79@gmail.com">dofo79@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;">Hi all,<br><br>I have a project with a suit of test executables that I create with CMake by means of add_executable(fooTest ${foo_DEPENDENCIES}), and then register in CTest with add_test(fooTest fooTest), and everything works just fine.<br>

As a next step, I wanted to exclude the building of the tests from the all target and associate them to the test target. Naively, I tried to EXCLUDE_FROM_ALL the test executables, and add_dependency(fooTest test), but I realized that this is not possible, since test (and install, clean, etc.) are not primary targets, and are only exist in the generated Makefiles.<br>

After reading various threads in this list, Section 10.5 of Mastering CMake (Using CTest to Drive Complex Tasks), and a couple of examples from the CMake source code, I tried something like:<br><br><span style="font-family: courier new,monospace;">add_test(fooTest ${CMAKE_CTEST_COMMAND}</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-and-test</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;${CMAKE_CURRENT_SOURCE_DIR}/test&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;${CMAKE_CURRENT_BINARY_DIR}/test&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-two-config</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-generator ${CMAKE_GENERATOR}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-makeprogram ${CMAKE_BUILD_TOOL}</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --build-project common</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --test-command </span><span style="font-family: courier new,monospace;">fooTest)</span><br>

<br>where the CMakeLists.txt file located in <span style="font-family: courier new,monospace;">${CMAKE_CURRENT_SOURCE_DIR}/test <span style="font-family: arial,helvetica,sans-serif;">creates the test executable</span></span>. Correct me if I&#39;m wrong, but this  CMakeLists.txt file needs to be a standalone CMake project that needs to &quot;bring into scope&quot; all the required external dependencies, and set up the necessary variables, which were all defined with the previous setup (using add_test(fooTest fooTest)). Since I&#39;m working on a somewhat big project, performing this setup is quite inconvenient. Am I doing something wrong here? am I missing something? or must I pay the price of setting up a project for each test executable?<br>

<br>Thanks in advance,<br><font color="#888888"><br>Adolfo Rodríguez Tsouroukdissian<br></font><br>P.S., I would like to express my support for the feature request reported in <a href="http://public.kitware.com/Bug/view.php?id=8438" target="_blank">http://public.kitware.com/Bug/view.php?id=8438</a> although I know that asking for this is easier said than done.<br>

</blockquote></div><br>