When this generator is called from CPackSourceConfig.cmake (or through the packagesource target), then the generated archive will contain all files in the project directory, except those specified in CPACKSOURCEIGNOREFILES. The following is one example of packaging all source files of a project. Compname is the name of an installation component, as defined by the COMPONENT argument of one or more CMake install commands. With the cpackaddcomponent command one can set a name, a description, and other attributes of an installation component. One can also assign a component to a component group.
I am trying to modify the file “CMakeLists.txt” in my OptiX project’s root to also create an installer file via CPack.
The code posted below will generate an installer file but without any dependencies. Any tips on how to link everything properly just as in CMake?
I added the lines (158 and 202) commented with
I suspect I am missing just a few lines to set up the entire project for deployment/packing. I found this comment but can’t really make sense of it:
Any help is greatly appreaciated here!
Build binary and source package installers.
The CPack module generates a file
CPackConfig.cmake intended foruse in a subsequent run of the
cpack programwhere it steers the generation of installers or/and source packages.
Inclusion of the CPack module adds two new build targets,
package_source, which build the binary and source installersrespectively. The generated binary installers contain everythinginstalled via CMake’s
install() command (and the deprecatedcommands
For certain kinds of binary installers (including the graphicalinstallers on macOS and Windows), CPack generates installers thatallow users to select individual application components to install.See
CPackComponent module for further details.
CPACK_GENERATOR variable has different meanings in differentcontexts. In a
CPACK_GENERATOR is alist of generators: and when
cpack is run with no otherarguments, it will iterate over that list and produce one package for eachgenerator. In a
CPACK_GENERATOR is a string naming a single generator. If youneed per-cpack-generator logic to control other cpack settings, then youneed a
The CMake source tree itself contains a
CPACK_PROJECT_CONFIG_FILE.See the top level file
CMakeCPackOptions.cmake.in for an example.
If set, the
CPACK_PROJECT_CONFIG_FILE is included automaticallyon a per-generator basis. It only need contain overrides.
Here’s how it works:
- it includes
- it iterates over the generators given by the
-Gcommand line option,or if no such option was specified, over the list of generators given bythe
CPACK_GENERATORvariable set in the
- foreach generator, it then
CPACK_GENERATORto the one currently being iterated
- includes the
- produces the package for that generator
This is the key: For each generator listed in
CPackConfig.cmake, cpack will reset
CPACK_GENERATORinternally to the one currently being used and then include the
Variables common to all CPack Generators¶
Before including this CPack module in your
CMakeLists.txt file, thereare a variety of variables that can be set to customize the resultinginstallers. The most commonly-used variables are:
The name of the package (or application). If not specified, it defaults tothe project name.
The name of the package vendor. (e.g., “Kitware”). The default is “Humanity”.
The directory in which CPack is doing its packaging. If it is not setthen this will default (internally) to the build dir. This variable maybe defined in a CPack config file or from the
cpackcommand line option
-B. If set, the command line option overrides thevalue found in the config file.
Package major version. This variable will always be set, but its defaultvalue depends on whether or not version details were given to the
project() command in the top level CMakeLists.txt file. If versiondetails were given, the default value will be
CMAKE_PROJECT_VERSION_MAJOR. If no version details were given,a default version of 0.1.1 will be assumed, leading to
CPACK_PACKAGE_VERSION_MAJOR having a default value of 0.
Package minor version. The default value is determined based on whether ornot version details were given to the
project() command in the toplevel CMakeLists.txt file. If version details were given, the defaultvalue will be
CMAKE_PROJECT_VERSION_MINOR, but if no minorversion component was specified then
CPACK_PACKAGE_VERSION_MINOR will beleft unset. If no project version was given at all, a default version of0.1.1 will be assumed, leading to
CPACK_PACKAGE_VERSION_MINOR having adefault value of 1.
Package patch version. The default value is determined based on whether ornot version details were given to the
project() command in the toplevel CMakeLists.txt file. If version details were given, the defaultvalue will be
CMAKE_PROJECT_VERSION_PATCH, but if no patchversion component was specified then
CPACK_PACKAGE_VERSION_PATCH will beleft unset. If no project version was given at all, a default version of0.1.1 will be assumed, leading to
CPACK_PACKAGE_VERSION_PATCH having adefault value of 1.
A description of the project, used in places such as the introductionscreen of CPack-generated Windows installers. If not set, the value ofthis variable is populated from the file named by
A text file used to describe the project when
CPACK_PACKAGE_DESCRIPTION is not explicitly set. The defaultvalue for
CPACK_PACKAGE_DESCRIPTION_FILE points to a built-in templatefile
Short description of the project (only a few words). If the
CMAKE_PROJECT_DESCRIPTION variable is set, it is used as thedefault value, otherwise the default will be a string generated by CMakebased on
Project homepage URL. The default value is taken from the
CMAKE_PROJECT_HOMEPAGE_URL variable, which is set by the toplevel
project() command, or else the default will be empty if noURL was provided to
The name of the package file to generate, not including theextension. For example,
cmake-2.6.1-Linux-i686. The default valueis:
Installation directory on the target system. This may be used by someCPack generators like NSIS to create an installation directory e.g.,“CMake 2.5” below the installation prefix. All installed elements will beput inside this directory.
A branding image that will be displayed inside the installer (used by GUIinstallers).
An algorithm that will be used to generate an additional file with thechecksum of the package. The output file name will be:
Supported algorithms are those listed by thestring(<HASH>) command.
CPack-time project CPack configuration file. This file is included at cpacktime, once per generator after CPack has set
CPACK_GENERATORto the actual generator being used. It allows per-generator setting of
CPACK_* variables at cpack time.
License to be embedded in the installer. It will typically be displayedto the user by the produced installer (often with an explicit “Accept”button, for graphical installers) prior to installation. This licensefile is NOT added to the installed files but is used by some CPack generatorslike NSIS. If you want to install a license file (may be the same as thisone) along with your project, you must add an appropriate CMake
install() command in your
Cmake Build Install
ReadMe file to be embedded in the installer. It typically describes insome detail the purpose of the project during the installation. Not allCPack generators use this file.
Welcome file to be embedded in the installer. It welcomes users to thisinstaller. Typically used in the graphical installers on Windows and MacOS X.
Cmake Cpack Example
Disables the component-based installation mechanism. When set, thecomponent specification is ignored and all installed items are put in asingle “MONOLITHIC” package. Some CPack generators do monolithicpackaging by default and may be asked to do component packaging bysetting
List of CPack generators to use. If not specified, CPack will create aset of options following the naming pattern'>
CPACK_BINARY_NSIS) allowingthe user to enable/disable individual generators. If the
-G option isgiven on the
cpack command line, it will override thisvariable and any
The name of the CPack binary configuration file. This file is the CPackconfiguration generated by the CPack module for binary installers.Defaults to
Lists each of the executables and associated text label to be used tocreate Start Menu shortcuts. For example, setting this to the list
ccmake;CMake will create a shortcut named “CMake” that will execute theinstalled executable
ccmake. Not all CPack generators use it (at leastNSIS, WIX and OSXX11 do).
List of files to be stripped. Starting with CMake 2.6.0,
CPACK_STRIP_FILES will be a boolean variable which enablesstripping of all files (a list of files evaluates to
TRUE in CMake,so this change is compatible).
If set to
TRUE, values of variables prefixed with
CPACK_ will beescaped before being written to the configuration files, so that the cpackprogram receives them exactly as they were specified. If not, characterslike quotes and backslashes can cause parsing errors or alter the valuereceived by the cpack program. Defaults to
FALSE for backwardscompatibility.
Variables for Source Package Generators¶
The following CPack variables are specific to source packages, andwill not affect binary packages:
The name of the source package. For example
List of files in the source tree that will be stripped. Starting withCMake 2.6.0,
CPACK_SOURCE_STRIP_FILES will be a booleanvariable which enables stripping of all files (a list of files evaluatesto
TRUE in CMake, so this change is compatible).
List of generators used for the source packages. As with
CPACK_GENERATOR, if this is not specified then CPack willcreate a set of options (e.g.
CPACK_SOURCE_ZIP) allowingusers to select which packages will be generated.
The name of the CPack source configuration file. This file is the CPackconfiguration generated by the CPack module for source installers.Defaults to
Pattern of files in the source tree that won’t be packaged when buildinga source package. This is a list of regular expression patterns (thatmust be properly escaped), e.g.,
Variables for Advanced Use¶
The following variables are for advanced uses of CPack:
What CMake generator should be used if the project is a CMakeproject. Defaults to the value of
CMAKE_GENERATOR. Few userswill want to change this setting.
List of four values that specify what project to install. The four valuesare: Build directory, Project Name, Project Component, Directory. Ifomitted, CPack will build an installer that installs everything.
System name, defaults to the value of
CMAKE_SYSTEM_NAME,except on Windows where it will be
Package full version, used internally. By default, this is built from
Directory for the installed files.
Cmake Install File
Extra commands to install components.
Extra directories to install.
Registry key used when installing this project. This is only used byinstallers for Windows. The default value is based on the installationdirectory.
List of desktop links to create. Each desktop link requires acorresponding start menu shortcut as created by
CPack generated options for binary generators. The
CPack.cmake modulegenerates (when
CPACK_GENERATOR is not set) a set of CMakeoptions (see CMake
option() command) which may then be used toselect the CPack generator(s) to be used when building the
packagetarget or when running
cpack without the