[CMake] EXEC_PROGRAM and its working directory

Brad King brad.king at kitware.com
Tue Mar 7 08:58:53 EST 2006


Patrick Cheng wrote:
> I have the following scripts, it suppose to check out the ITK code to 
> the ${TEST_BINARY_DIR} directory, but the result ITK code is actually 
> being checked out into the cmake binary directory (C:\Program 
> Files\CMake 2.2\bin):
> 
> EXEC_PROGRAM(${CVS_COMMAND}
>              ${TEST_BINARY_DIR}
>              ARGS "-d ${ITK_ROOT} co Insight"
>              OUTPUT_VARIABLE rm_out
>              RETURN_VARIABLE rm_retval )
> 
> FILE(WRITE ${TEST_BINARY_DIR}/co.txt ${rm_out})
> 
> In the output file "co.txt", I found the first line is:
> cvs checkout: cwd=C:\Program Files\CMake 2.2\bin ,current=C:\Program 
> Files\CMake 2.2\bin
> 
> Am I missing something here? How to solve this problem?

Go to your project build tree and run

   cmake . >log 2>&1

from the command line to reconfigure the project.  Look in the log for 
the line that says "running ..." for the CVS command.  Then post the 
line here.  Then we may be able to debug the problem.

Meanwhile you can probably work around it by using the "cmake -E chdir" 
command:

EXEC_PROGRAM(${CMAKE_COMMAND} -E chdir "${TEST_BINARY_DIR}"
              ARGS ${CVS_COMMAND} -d ${ITK_ROOT} co Insight
              OUTPUT_VARIABLE rm_out
              RETURN_VARIABLE rm_retval )

-Brad


More information about the CMake mailing list