[CMake] how to define current working directory of command line tool

Jochen Wilhelmy j.wilhelmy at arcor.de
Fri Oct 29 08:48:48 EDT 2010


>>>>
>>>>          
>>> Are you trying to run the executable with ADD_TEST? In that case the working directory is always CMAKE_CURRENT_BINARY_DIR. If you need to change it, create a wrapper script (you can do so using the CMake language in order to not depend on any other interpreter).
>>>
>>>        
>> no, just add_executable and then starting the target in debug mode inside the ide. but maybe add_test is the solution to my
>> problem, i have to look at it. is this for starting an executable with some command line arguments?
>>
>> -Jochen
>>
>>      
> It is for adding a single unit test which can then be run using CTest.
>
> Michael

Perhaps adding unit tests for testing my command line tool is the right 
way, but really practical would be to
have a target property to set the default debugging working directory 
for a target.
In visual studio this is right click on a target, then properties. Then 
on the left side Configuration Properties->Debugging
and on the right side Working Directory. This is used when you launch 
the target from inside the IDE. I always have
to set it by hand. Even worse on macos: there I have to set it every 
time cmake has run.
Therefore I still would request this feature (e.g. 
set_target_properties(MyTarget PROPERTIES WORKING_DIRECTORY 
${CMAKE_CURRENT_SOURCE_DIR}) )

-Jochen



More information about the CMake mailing list