[CMake] CPack source packaging

Ian Monroe ian.monroe at gmail.com
Thu Mar 7 13:36:23 EST 2013


On Wednesday, March 06, 2013 01:01:07 Szőts Ákos wrote:
> Dear list members,
> 
> I made a project with CMake (2.8.10) on Linux and want to use CPack to
> create its source .tar.bz2 file.
> 
> The task is really simple: copy all of the *.cpp and *.h files into the
> .tar.bz2 file preserving the directory structure.

What about the CMakeLists.txt? :)

> Although sounds really simple, I've yet to find a solution. The problems
> are: - In the source directory goes the development also, producing a lot
> of other files which are unneeded.
> - With CPACK_SOURCE_IGNORE_FILES variable I can exclude some files, but
> without the regexp positive lookahead feature I cannot say "exclude
> everything, except for the *.cpp and *.h"
> - Other solution would be an external command (eg. find and cp) to copy all
> the files into an other temporary directory and set that directory as the
> source directory. The drawback: there's no way to tell in CMakeLists.txt
> which is the current CPack generator, so I simply can't write "if
> (CPACK_GENERATOR STREQUAL "TBZ2")", because CPACK_GENERATOR is empty at
> "cmake ." time. So the find and copy command either ran all the time or not
> even once.
> - As a last resort I can execute a bz2 command which would do all the
> necessary things, but that would run every time (see the problem above).
> 
> The command I issue to generate the source:
> cpack --config CPackSourceConfig.cmake
> 
> Is there a simple solution to achieve this?

I think you should use your source code control system for this. It already 
knows which files are source. Git has a git archive command for this

Ian


More information about the CMake mailing list