Aurélien Gâteau

CMake and "make dist", the simpler version

written on Sunday, August 9, 2009

I wrote about using CPack to create a make dist target earlier today, but it turns out there is a much simpler way to do this, thanks to Christophe Fergeau for pointing me to it.

Note that this won't work if your project is not using a version control system (but if you are not, then you are asking for trouble!).

Here are the necessary lines to add to your CMakeLists.txt file if your project is using Git:

set(PROJECT_VERSION "0.2.3")
    COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
        | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2

If your project uses Bazaar, replace the "add_custom_target" line with:

    COMMAND bzr export --root=${ARCHIVE_NAME}

If you know how to do this with another version control system, please add a comment!

This post was tagged CMake, Tips, make and make dist
blog comments powered by Disqus