On Thu, Jul 5, 2012 at 2:53 AM, Rolf Eike Beer <e...@sf-mail.de> wrote: > Guillaume Blanc wrote: >> Some tests that I run need to access files (using a relative path) that are >> located in the same directory as the test executable itself. So I'm trying >> to use ADD_TEST property WORKING_DIRECTORY in the following way: >> >> ADD_TEST( >> NAME mytest >> WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR} >> COMMAND myexec) > > WORKING_DIRECTORY $<TARGET_FILE_DIR:mytest> > > Eike > -- > > -- > > 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
This does not work: add_test(mytest ${CMAKE_COMMAND} -E chdir "c:/" $<TARGET_FILE:myexec>) But this should: add_test(NAME mytest COMMAND ${CMAKE_COMMAND} -E chdir "c:/" $<TARGET_FILE:myexec>) As noted in the --help-command for add_test: http://cmake.org/cmake/help/v2.8.8/cmake.html#command:add_test "Arguments after COMMAND may use "generator expressions" with the syntax "$<...>"." Only the NAME+COMMAND signature of add_test evaluates generator expressions properly (like $<TARGET_FILE:myexec>). For that reason, always prefer the newer NAME+COMMAND signature of add_test. (i.e. always start with "add_test(NAME" using the NAME keyword...) It should also be noted that you must run ctest with a -C Debug or -C Release command line argument when you have a Visual Studio based build and your tests are added with the NAME+COMMAND signature of add_test. (If you run tests via the RUN_TESTS project in VS, then it is already passing -C for you...) HTH, David -- 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