Contents

Introduction

CPack is a powerful, easy to use, cross-platform software packaging tool distributed with CMake since version 2.4.2. It uses the generators concept from CMake, to abstract package generation on specific platforms, and it can be used with or without CMake.

Using either a simple configuration file or the CMake module, a complex project can be packaged into an installer.

Using CPack without CMake

CPack can be used directly by specifying a CPackConfig.cmake file, which uses CMake syntax and defines several variables. Here is an example CPackConfig.cmake file for a Linux system:

Using CPack with CMake

CMake comes with a CPack module, which will automatically generate an appropriate CPack configuration file. To use the module, simply invoke the following command (BTW, failure to do so will result in an annoying "CPack Error: CPack project name not specified" message...):

INCLUDE(CPack)

This generates a new target called "package" in your build system. When this target is built, CPack will be invoked to generate all of the packages. Internally, CPack will use CMake's install mechanism to automatically populate the package.