[CMake] Problem with CTest and configuration specific binary paths

Iman Brouwer iman.brouwer at gmail.com
Fri Aug 20 15:44:35 EDT 2010


Hello,

The path to a binary target built by cmake depends on the
configuration type when using the Visual Studio generators. Is it
possible to pass this path the ctest without having to run ctest with
the -c option?

I'd like to do the following:
I create an executable with cmake as follows, and add a test for it:

add_executable( my_test main.cpp )
add_test( "test_name" my_test )

Let's assume this executable gets built in bin_path\debug or
bin_path\release, dependent on the configuration. Cmake generates the
following line in the CTestTestfile.cmake:

ADD_TEST( test_name "bin_path/my_test" )

Note that the my_test path will not contain the executable, it will be
in a configuration dependent subdirectory. However, when running
"ctest", ctest will automatically pick a configuration and will change
the path in CTestTestfile.cmake to the right path for this
configuration.

In my case i'd like to call a python script to which i pass the
executables name including path, so i'd to do something like:

add_test( "python test" ${PYTHON_EXECUTABLE}  my_test )

In this case, "my_test" does not get expanded in CTestTestfile.cmake
to "bin_path/my_test". Also, if I replace "my_test" here with
"bin_path/my_test", ctest will not do the automatic substitution to of
the base path to the right configuration dependent path anymore.

Alternatively, i tried replacing the add_test line with the add_test(
NAME.... COMMAND ...)  syntax, but then all the tests are inside ctest
configuration specific ifs. Basically the tests drops of the list of
tests when just running "ctest", it only appears when running ctest
with an explicit configuration, e.g. "ctest -C Debug".

Is it possible to have ctest automatically figure out the right path
to a cmake-built binary, without having to run ctest with an explicit
configuration?

Thanks,

Iman


More information about the CMake mailing list