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><br>Adolfo Rodríguez Tsouroukdissian<br><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>