...

/

Packaging With CPack

Packaging With CPack

Let's learn how to configure automatic installation; we can use the CPack tool to provide our users with prebuilt artifacts.

Building projects from a source has its benefits, but it can take a long time and introduce a lot of complexity. This isn't the best experience for end users who just want to use the package, especially if they aren't developers themselves. A much more convenient form of software distribution is to use binary packages that contain compiled artifacts and other static files that are needed by the runtime. CMake supports generating multiple kinds of such packages through a command-line tool called cpack.

Package Generators

The following table lists the available package generators:

Name

File Types

Platform

Archive

7Z – 7zip – (.7z)

TBZ2 (.tar .bz2)

TGZ (.tar.gz)

TXZ (.tar.xz)

TZ (.tar.Z)

TZST (.tar.zst)

ZIP(.zip)

Cross-platform

Bundle

Bundle (.bundle)

macOS

DEB

DEB (.deb)

Linux

DragNDrop

DMG (.dmg)

macOS

External

JSON (.json)

Integration with external packaging tools

FreeBSD

PKG (pkg)

*BSD, Linux, OSX

IFW

Binary

Linux, Windows, macOS

NSIS

Binary (.exe)

Windows

NuGet

NuGet (.nupkg)

Windows

productbuild

PKG (.pkg)

macOS

RPM

RPM (.rpm)

Linux

WIX

MSI (.msi)

Windows

Most of these generators have extensive configurations. It is beyond the scope of this course to delve into all their details, so be sure to check out the full documentation. Instead, we'll focus on the general use case.

Note: ...