[CMake] CTest not searching for the correct executable

Saad Khattak saadrustam at gmail.com
Fri Jan 5 11:45:58 EST 2018


That was it, thanks Nils!

For future reference, after adding the test like Nils suggested, calling
"ctest" wouldn't work as it now needs your configuration:

ctest -C Debug

On Fri, Jan 5, 2018 at 11:16 AM Nils Gladitz <nilsgladitz at gmail.com> wrote:

> On 05.01.2018 17:11, Saad Khattak wrote:
>
> Hi,
>
> Suppose I have something like this:
>
> add_executable(MyTest main.cpp)
> set_target_properties(MyTest
>   PROPERTIES
>   DEBUG_POSTFIX _d
>   RELEASE_POSTFIX _r
>   )
> add_test(RunTests MyTest) # where MyTest is the <command>
>
> I expect CMake to recognize that "MyTest" has executables that are named
> "MyTest_d" and "MyTest_r" and NOT MyTest. I expect this because in the
> CMake documentation the <command> can be an executable target where CMake
> then replaces it with the location of the executable.
>
> However, what I get is errors when running "ctest" where it complains that
> it cannot find "MyTest" when it should really be searching for "MyTest_d"
> and "MyTest_r".
>
> Am I doing something wrong or is this a bug in CMake?
>
>
> You are using the old signature (without NAME|COMMAND) for which the
> documentation states [1]:
>     "Unlike the above NAME signature no transformation is performed on
> the command-line to support target names or generator expressions."
>
> Use the new signature instead e.g.:
>     add_test(NAME RunTests COMMAND MyTest)
>
> Nils
>
> [1] https://cmake.org/cmake/help/latest/command/add_test.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180105/c1a7adb9/attachment.html>


More information about the CMake mailing list