[CMake] CTest question...

BRM bm_witness at yahoo.com
Wed Nov 19 19:40:51 EST 2008

It was reporting that it could not find the executable.
However, this was certainly a PEBKAC issue (do'h) - I forgot to have an ADD_EXECUTABLE() for the test program - or even an CREATE_TEST_SOURCE_LIST()...though so it shouldn't have been finding it. Though I am not sure what the best method is...I don't want these executables installed when I do a 'make install' later...while I am no where near needing to think about the install process (far too much to go before the project will be ready for that), it would be good to avoid doing it the wrong-even-if-it-works way.

Thanks for the tip on the ADD_TEST()...I was simply trying to follow the referenced WIKI page - it made no mention of needing to define the EXECUTE_OUTPUT_PATH variable...It probably should be amended to just read as you mentioned.

I've now got it working. Thanks!


----- Original Message ----
From: Eric NOULARD <eric.noulard at gmail.com>
To: cmake at cmake.org
Sent: Wednesday, November 19, 2008 7:52:49 AM
Subject: Re: [CMake] CTest question...

Le Tue, 18 Nov 2008 15:53:25 -0800 (PST),
BRM <bm_witness at yahoo.com> a écrit :

> Any info on this? Any better resources?

I think we miss informations about your particular configuration.
I do use ADD_TEST with no trouble.

See more question below: 

> From: BRM <bm_witness at yahoo.com>
> To: CMake <cmake at cmake.org>
> Sent: Monday, November 17, 2008 3:14:53 AM
> Subject: [CMake] CTest question...
> I'd like to build a series of test using the CTest functionality in
> CMake. I have added ENABLE_TESTING() to the main CMakeLists, and was
> hoping to put the tests in their own sub-directories - as follows:
> /
> /Tests
> /Tests/object
> /Tests/object/child-objects
> I added the Tests directory in the root's CMakeLists.txt. I've
> created my first test (/Tests/object/objectTest) and tried adding it
> via ADD_TEST(objectTest ${EXECUTABLE_OUTPUT_PATH}/objectTest}) 

if objectTest is a target built in /Tests/object/objectTest
then you don't need the extra ${EXECUTABLE_OUTPUT_PATH} just put:

ADD_TEST(objectTest objectTest)

or in order to avoid name clash (I never experienced that but who knows)

ADD_TEST(objectTest_test objectTest)

> - no
> parameters needed (as described by
> http://www.vtk.org/Wiki/CMake_Testing_With_CTest). However, it's
> unable to find the test when I run "make test".

What is the exact error shown by "make test".
Do you get the same error when running


> Note: I tried doing a MESSAGE() to find out the value of
> EXECUTABLE_OUTPUT_PATH and it seems to be NULL. Is that reall the
> right variable?

I don't think EXECUTABLE_OUTPUT_PATH is set by CMake unless you
decide to set it yourself. The default behavior of cmake is to put
built executable in CMAKE_CURRENT_BINARY_DIR.

Did you set EXECUTABLE_OUTPUT_PATH is your main CMakeLists.txt?

> The documentation on ENABLE_TESTING() mentions that CTest expects
> files in build's root directory. Does that also apply to ADD_TEST()?
> (no mention in ADD_TEST()'s documentation of this).

This is true for me but I do not use absolute file specification with
ADD_TEST, my ADD_TEST use target name previsouly built with
ADD_EXECUTABLE with no problem.

CMake mailing list
CMake at cmake.org

More information about the CMake mailing list