[CMake] add_test: specify working directory?

Tyler Roscoe tyler at cryptio.net
Thu Sep 24 12:18:34 EDT 2009


On Thu, Sep 24, 2009 at 10:04:40AM -0600, Dixon, Shane wrote:
> ADD_TEST(ping_test ${CMAKE_CURRENT_BINARY_DIR}/testdir/bin/MyClient.exe my.server.com 4321)
> 
> SET_TESTS_PROPERTIES(ping_test PROPERTIES FAIL_REGULAR_EXPRESSION "Ping Failed")
> 
> SET_TESTS_PROPERTIES(ping_test PROPERTIES PASS_REGULAR_EXPRESSION "Ping Successful!")
> 
> If appears that by specifying the absolute path, it runs the
> MyClient.exe and the working directory isn't set to the same directory
> that the MyClient.exe resides.  My ping test fails horribly because it
> can't find the client.pem in the default working directory.  Is there
> any way to specify the working directory when using add_test?

Wow, you TLS-encrypt your ping packets? That's hardcore. :)

I'm surprised to see that add_test() doesn't accept a WORKING_DIRECTORY
argument.

One workaround would be to write a wrapper script that cd's to your
desired working directory and then calls your exe. Then you would
add_test(my_wrapper_script).

tyler


More information about the CMake mailing list