The cmake --build . --target package
command is logically equivalent to running cpack
, but there are important differences:
- I think
cmake --build . --target package
will also build theall
target first, whereas runningcpack
directly won’t. Perhaps @kyle.edwards can confirm this? - Running
cpack
directly supports many options that allow you to control the behavior (e.g. specifying which package generators to use), whereascmake --build . --target package
can only support the defaults set by the project. - If you want to create a multi-config package, you can do that by invoking
cpack -C ...
. There is no equivalent forcmake --build . --target package
, which can only build/package a single configuration.