MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0014089 | CMake | CMake | public | 2013-04-15 10:52 | 2014-10-06 10:33 |
Reporter | Joël Lamotte | ||||
Assigned To | Ben Boeckel | ||||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | OS | OS Version | |||
Product Version | |||||
Target Version | Fixed in Version | CMake 3.0 | |||
Summary | 0014089: add_test/add_custom_command: Support generator expressions in WORKING_DIRECTORY | ||||
Description | I'm pasting here the report I gave there: http://cmake.3232098.n2.nabble.com/Potential-bug-to-set-a-working-directory-for-test-td7583812.html [^] ---- 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. | ||||
Steps To Reproduce | |||||
Additional Information | |||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2013-04-15 10:52 | Joël Lamotte | New Issue | |||
2013-04-15 10:59 | Brad King | Note Added: 0032840 | |||
2013-04-15 10:59 | Brad King | Severity | major => feature | ||
2013-04-15 10:59 | Brad King | Status | new => backlog | ||
2013-04-15 10:59 | Brad King | Summary | add_test() WORKING_DIR don't accept generators AND/OR add_custom_command() generator makes wrong paths => add_test/add_custom_command: Support generator expressions in WORKING_DIRECTORY | ||
2013-04-15 11:03 | Brad King | Note Added: 0032841 | |||
2014-03-24 18:11 | Ben Boeckel | Note Added: 0035497 | |||
2014-03-26 11:03 | Brad King | Assigned To | => Ben Boeckel | ||
2014-03-26 11:03 | Brad King | Status | backlog => resolved | ||
2014-03-26 11:03 | Brad King | Resolution | open => fixed | ||
2014-03-26 11:03 | Brad King | Fixed in Version | => CMake 3.0 | ||
2014-10-06 10:33 | Robert Maynard | Note Added: 0036958 | |||
2014-10-06 10:33 | Robert Maynard | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|