Are the commands "cmake -build . --target package" and "cpack ." equivalent?

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 the all target first, whereas running cpack 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), whereas cmake --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 for cmake --build . --target package, which can only build/package a single configuration.