[CMake] EXECUTE_PROCESS - I can't copy files on Windows

Vitor Vasconcelos Araujo Silva vasconcv at loria.fr
Tue Mar 20 08:57:34 EST 2007


	Hello all,

	I'm experiencing a problem in EXECUTE_PROCESS command.
	
	My test set needs some image files to execute. On Linux, it works fine 
with "make test" because I use the same directory to source code and to 
build.
	On Windows (Visual Studio) the file is built in the /Release directory. 
It's not a problem, but I have to copy the image files that are inside 
the SOURCE_DIR to BINARY_DIR. Otherwise, the RUN_TESTS project reports 
an execution error (of course, the files are missing. If a manually copy 
them inside the directory, it works fine). I use the code below:

   IF (WIN32)

      STRING (REGEX REPLACE "/" "\\\\" TESTSUITE_SOURCE_DIR_WINDOWS 
${TESTSUITE_SOURCE_DIR})

      STRING (REGEX REPLACE "/" "\\\\" TESTSUITE_BINARY_DIR_WINDOWS 
${TESTSUITE_BINARY_DIR})

      SET (ARGS_PBM_COPY \"${TESTSUITE_SOURCE_DIR_WINDOWS}*.pbm\" " " 
\"${TESTSUITE_BINARY_DIR_WINDOWS}\")

      MESSAGE ("--- Copying TEST files arguments needed to performe unit 
tests...")
      MESSAGE ("copy " ${ARGS_PBM_COPY})

      EXECUTE_PROCESS(COMMAND copy ${ARGS_PBM_COPY}
		     RESULT_VARIABLE result)
      MESSAGE ("My result: " ${result})

   ENDIF (WIN32)

	I tested all strings and they works well when I try them by hand.
	To clarify a little bit more, my "result" is: Impossible to find files. 
If I try the ERROR_VARIABLE, nothing is set.
	I tried before the EXEC_PROGRAM command as in the Mastering CMake book 
chaging after to EXECUTE_PROCESS. The both gave me the same errors.
	I'm using Windows XP.
	On Linux I don't need to copy the files, but as a test, I've tried and 
it worked as well (not copy, but cp).
	Am I doing something wrong? Or that are any better options?
	Thanks in advance,

	Vitor Vasconcelos
	INRIA Lorraine


More information about the CMake mailing list