Packaging With CPack
Explore how to package C++ projects efficiently by using CPack integrated with CMake. This lesson helps you understand configuring install commands and generating binary packages like ZIP, 7Z, and Debian formats to distribute compiled artifacts easily to users.
We'll cover the following...
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 – ( TBZ2 ( TGZ ( TXZ ( TZ ( TZST ( ZIP( | Cross-platform |
Bundle | Bundle | macOS |
DEB | DEB | Linux |
DragNDrop | DMG | macOS |
External | JSON | Integration with external packaging tools |
FreeBSD | PKG | *BSD, Linux, OSX |
IFW | Binary | Linux, Windows, macOS |
NSIS | Binary | Windows |
NuGet | NuGet | Windows |
productbuild | PKG | macOS |
RPM | RPM | Linux |
WIX | 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: Package generators shouldn't be confused with buildsystem generators (Unix Makefiles, Visual Studio, and so on). ...