cmake Packaging and Distributing Projects Selecting a CPack Generator to be used


To create a package using a specific format, it is possible to pick the Generator to be used.

Similar to CMake this may be done using the -G argument:

cpack -G 7Z .

Using this command line would package the built project in the current directory using the 7-Zip archive format.

At the time of writing, CPack version 3.5 supports the following generators by default:

  • 7Z 7-Zip file format (archive)
  • IFW Qt Installer Framework (executable)
  • NSIS Null Soft Installer (executable)
  • NSIS64 Null Soft Installer (64-bit, executable)
  • STGZ Self extracting Tar GZip compression (archive)
  • TBZ2 Tar BZip2 compression (archive)
  • TGZ Tar GZip compression (archive)
  • TXZ Tar XZ compression (archive)
  • TZ Tar Compress compression (archive)
  • WIX MSI file format via WiX tools (executable archive)
  • ZIP ZIP file format (archive)

If no explicit generator is provided, CPack will try to determine the best available depending on the actual environment. For example, it will prefer creating a self-extracting executable on Windows and only create a ZIP archive if no suitable toolset is found.