[CMake] cd before add custom command
Brad King
brad.king at kitware.com
Wed Aug 3 13:43:07 EDT 2005
Alexander Neundorf wrote:
>>Von: David Somers <dsomers at omz13.com>
>>
>>When a command is invoked through ADD_CUSTOM_COMMAND, is it possible to
>>change the current directory *before* the command is invoked? (I have
>>need to run some programs and these must be run in specific directories
>>- they can't simply be run elsewhere and passed the working dircetory
>>as a parameter).
>>
>>At the moment I'm applying bit of fudge and instead of running the
>>custom command directly per se, its actually running a bash script
>>which does a cd before running the actual command.
You can use the cmake -E option:
ADD_CUSTOM_COMMAND(...
COMMAND ${CMAKE_COMMAND}
ARGS -E chdir ${WORKING_DIR} rest-of-command ...
)
This will run the CMake executable which will change to the proper
directory and then run the rest of the command line as a child process.
It won't work for shell expressions with redirection but it works in
the simple case.
> Same here. Having an option "WORKING_DIRECTORY" or something link this
> would be nice.
That sounds like a good feature request for a shorthand version of the
above:
http://www.cmake.org/Bug
-Brad
More information about the CMake
mailing list