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&#39;m trying to use ADD_TEST property WORKING_DIRECTORY in the following way:<div>

<br></div><div>ADD_TEST(</div><div>  NAME mytest</div><div>  WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}</div><div>  COMMAND myexec)</div><div><br></div><div>When using a multiple configuration build system like Visual Studio, I expect the working directory to be set, in the example of a debug build, to &quot;c:/path/to/runtime/dir/Debug&quot;, but it fails. To test that I&#39;ve printed the return of getcwd(), which would be&quot;c:/path/to/runtime/&quot; in this particular example. I&#39;ve also tried to hard code &quot;c:/path/to/runtime/dir/Debug&quot; as the working direcory property of the add_test command, it works fine.</div>

<div><br></div><div>So I&#39;m wondering if  CMAKE_CFG_INTDIR can be used in that case, or if there are other solutions to acheive this objective ?</div><div><br></div><div>I know I could use $&lt;TARGET_FILE_DIR:myexec&gt; as an argument of my test command, but this is not the test I want to do.</div>
<div><br></div><div>I also tried the command explained in that thread: <a href="http://www.mail-archive.com/cmake@cmake.org/msg24194.html">http://www.mail-archive.com/cmake@cmake.org/msg24194.html</a>. I did this simple test case : add_test(mytest ${CMAKE_COMMAND} -E chdir &quot;c:/&quot; $&lt;TARGET_FILE:myexec&gt;), but it fails to execute. I don&#39;t really understand this syntax, it seems that it tries to run 2 commands sequentially. Is this is supposed to work ?</div>
<div><br></div><div>My environment is CMake 2.8.8, Visual Studio 2010, Windows XP.</div>
<div><br></div><div>Best regards</div><div>Guillaume</div>