[CMake] Automated packaging

Eric Noulard eric.noulard at gmail.com
Wed Oct 14 15:31:31 EDT 2009


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