Hi, I'm using CMake 2.10.2 the VS2012(VC11) generator. I summed-up my problem in the last paragraph.
I'm trying to do this: add_test( NAME ${TEST_PROJECT_NAME} WORKING_DIRECTORY ${TEST_WORKING_DIR} COMMAND ${TEST_PROJECT_NAME} ) In my current setup, I need ${TEST_WORKING_DIR} to be dependent on the build config name. ${TEST_WORKING_DIR} is equivalent to: "${MYPROJECT_FINAL_DIR}/$<CONFIGURATION>/myproject" But this don't work as WORKING_DIRECTORY don't accept generator commands. (note: ${MYPROJECT_FINAL_DIR} is a full path) I was considering using two commands, one to do "cd ${TEST_WORKING_DIR} and one to call the test project target (which is in another directory, the build one). There is a restriction that add_test() can't take more than one COMMAND instruction. I then figured that I could just call the test automatically on build. I first wrote this: add_custom_command( TARGET ${TEST_PROJECT_NAME} POST_BUILD COMMAND cd ${TEST_WORKING_DIR} COMMAND ${TEST_PROJECT_NAME} VERBATIM ) Unfortunately this cannot work as with the current generator the ${TEST_PROJECT_NAME} is converted to a windows-specific path which is the relative path from the CMakeLists.txt file. So the generated commands are something like cd E:/projects/myprojects/final/Debug ../../../../../../build/Debug/my_test Understanding this, I changed the command to find explicitly the test executable file so that the generated command would have a full path instead of a relative path. This is less flexible but should have worked: add_custom_command( TARGET ${TEST_PROJECT_NAME} POST_BUILD COMMAND cd ${TEST_WORKING_DIR} COMMAND ${MYPROHECT_BUILD_DIR}/$<Configuration>/$<TARGET_FILE_NAME:${TEST_PROJECT_NAME}> VERBATIM ) note that ${MYPROHECT_BUILD_DIR} is a full path. This generate EXACTLY the same command: cd E:/projects/myprojects/final/Debug ../../../../../../build/Debug/my_test Which is still wrong. In doubt I added a "call" command at the beginning of the second command, which works on Windows but will not work on other platform (from search I just did). To sum-up: 1. I would like to be able to set a working directory which would be generated using generated expression (as for the first example) both for add_test() and add_custom_command(). Currently I have no cross-platform way to do this (AFAIK) which don't imply calling an external script. 2. Why does the VS generator convert a binary call to a relative path systematically, evene if VERBATIM is defined? I'm not sure if there are reasons for these behaviours so I'm asking here before making tickets. If I should make tickets, does the first one is a feature and the second one a bug? Should I enter two tickets? Thanks for your patience. Joel Lamotte
-- 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