[CMake] Automated packaging

Dixon, Shane Shane.Dixon at atmel.com
Wed Oct 14 17:07:57 EDT 2009


Eric,

I'm trying your idea and I feel like I'm so close to a solution.  Here's the call:

EXECUTE_PROCESS(
	WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
	COMMAND ${CTEST_CMAKE_COMMAND}
     -DCTEST_BINARY_DIRECTORY:STRING="${CTEST_BINARY_DIRECTORY}"
     -DCTEST_CMAKE_COMMAND:STRING="${CTEST_CMAKE_COMMAND}"
     -DPACKAGE_ARCHIVE:STRING="${PACKAGE_ARCHIVE}"
     -P ${CTEST_SOURCE_DIRECTORY}/cmake/CopyToArchive.cmake
	RESULT_VARIABLE copy_result )

EXECUTE_PROCESS(
	WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
	COMMAND ${CTEST_CMAKE_COMMAND}
	-E echo "copy_result = ${copy_result}" )

Here's the contents of CopyToArchive.cmake:

include(CPackConfig.cmake)
	
EXECUTE_PROCESS(
	WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
	COMMAND ${CTEST_CMAKE_COMMAND}
	-E echo "CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}" )
	
EXECUTE_PROCESS(
	WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
	COMMAND ${CTEST_CMAKE_COMMAND} 
	-E copy ${CPACK_PACKAGE_FILE_NAME}.exe ${PACKAGE_ARCHIVE}
	RESULT_VARIABLE copy_result )

For some reason, I get a "copy_result = 0" which indicates success, but then the file is never moved.

If I run the exact same thing manually, it works:

cmake -DCTEST_BINARY_DIRECTORY:STRING="C:/temp/ctest_builds/myproj_build_nmake" -DCTEST_CMAKE_COMMAND:STRING="cmake" -DPACKAGE_ARCHIVE:STRING="c:/temp/ctest_builds/archive" -P C:/temp/ctest_builds/myproj/cmake/CopyToArchive.cmake

I'm not sure why this never appears to call.  It should print out the file name when it's called and it never does.  When I run by hand, it works great.

Why is it that in Ctest this fails?  I'm using Cmake 2.8rc3 so maybe that makes a difference.

--
Shane Dixon
Linux Engineer
Atmel Corporation 


-----Original Message-----
From: Eric Noulard [mailto:eric.noulard at gmail.com] 
Sent: Wednesday, October 14, 2009 1:32 PM
To: Dixon, Shane
Cc: cmake at cmake.org
Subject: Re: [CMake] Automated packaging

2009/10/14 Dixon, Shane <Shane.Dixon at atmel.com>:
> Clinton,
>
> Okay, that PARTIALLY works.  It does in fact build everything the way it should.  The problem comes when I try to copy the file.  I don't know what the product of the Cpack step is unless I have visibility to the variable CPACK_PACKAGE_FILE_NAME.  I try this block:
>
> EXECUTE_PROCESS(
>        WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
>        COMMAND ${CTEST_CMAKE_COMMAND}
>        -E copy ${CPACK_PACKAGE_FILE_NAME}.exe ${PACKAGE_ARCHIVE}
>        RESULT_VARIABLE copy_result )
>
> And it doesn't work.  I get this:
>
> Error copying file ".exe" to "C:/temp/ctest_builds/archive".
>
> The CPACK_PACKAGE_FILE_NAME is empty.  If I try to load the CPackConfig.cmake with --config, the -E option balks and doesn't like that.  Is there any way to load that variable in my script?  Am I going to have to REGEX it out of the CMakeCache.txt?

You can write an extra CMake mycopy.cmake whose content may be something like:
******
include(CPackConfig.cmake)
EXECUTE_PROCESS(
        WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
        COMMAND ${CTEST_CMAKE_COMMAND}
        -E copy ${CPACK_PACKAGE_FILE_NAME}.exe ${PACKAGE_ARCHIVE}
        RESULT_VARIABLE copy_result )
******

then in your ctest script you may
EXECUTE_PROCESS(
        WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
        COMMAND ${CTEST_CMAKE_COMMAND}
        -DCTEST_BINARY_DIRECTORY:STRING="${CTEST_BINARY_DIRECTORY}"
        -DCTEST_CMAKE_COMMAND:STRING="${CMAKE_COMMAND"
        -DPACKAGE_ARCHIVE:STRING="${PACKAGE_ARCHIVE}"
         -P mycopy.cmake
        RESULT_VARIABLE copy_result )


You need to add the extra -D definitions because in -P scripting mode you do not have much variable defined.

(not tested but theoretically this should work)

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org


More information about the CMake mailing list