On 08/20/2010 09:44 PM, Iman Brouwer wrote: > 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?
AFAIK, the "generator expressions" have been added to ADD_TEST() in order to address this issue; have you already tried the following? ADD_TEST(NAME "python test" COMMAND ${PYTHON_EXECUTABLE} $<TARGET_FILE:my_test>) Regards, Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake