ctest --build-and-test ... --test-command <DirectoryName>?

I’m trying to understand most of the uses of this macro in the CMake sources. If the macro is passed more than its one argument, those other arguments are passed at the end of the ctest command line, preceded by --test-command. That totally makes sense to me when I see cases like this one, where those arguments clearly form an executable command.


But the vast majority of uses of the macro pass a single optional argument that is the same as the name of the test and of a subdirectory containing its own CMake project, e.g.:

ADD_TEST_MACRO(CommandLineTest CommandLineTest)

which should result in an invocation like

ctest --build-and-test ... --test-command CommandLineTest

What makes CommandLineTest an appropriate --test-command?


--test-command consumes multiple arguments after it to treat as a single command. --test-command CommandLineTest runs the CommandLineTest executable created by Tests/CommandLineTest/CMakeLists.txt.

So… ctest maps that target name to an actual executable file? If not, what puts that executable in the PATH?