# CPACK\_PRE\_BUILD\_SCRIPTS duplicates CPACK\_INSTALL\_SCRIPTS

**URL:** https://discourse.cmake.org/t/cpack-pre-build-scripts-duplicates-cpack-install-scripts/2105
**Category:** Development
**Created:** [November 2, 2020, 3:13am UTC](https://discourse.cmake.org/t/cpack-pre-build-scripts-duplicates-cpack-install-scripts/2105 "2020-11-02T03:13:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [November 2, 2020, 3:13am UTC](https://discourse.cmake.org/t/cpack-pre-build-scripts-duplicates-cpack-install-scripts/2105/1 "2020-11-02T03:13:26Z")

</div>

While cleaning up the docs for the new `CPACK_PRE_BUILD_SCRIPTS`, `CPACK_POST_BUILD_SCRIPTS` and `CPACK_PACKAGE_FILES` variables added by [!4846](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4846), I noticed that we already have `CPACK_INSTALL_SCRIPTS`. This seems to already provide the capabilities that `CPACK_PRE_BUILD_SCRIPTS` aims to cover. The naming for `CPACK_PRE_BUILD_SCRIPTS` is clearer now that we also have post-build capabilities, but this raises some questions:

- Do we have the same guaranteed variables set for `CPACK_PRE_BUILD_SCRIPTS` as we do for `CPACK_INSTALL_SCRIPTS`? This would include `CMAKE_CURRENT_SOURCE_DIR`, `CMAKE_CURRENT_BINARY_DIR` and `CMAKE_INSTALL_PREFIX`.
- Should we update the docs for `CPACK_INSTALL_SCRIPTS` to say to prefer to use `CPACK_PRE_BUILD_SCRIPTS` instead?
- Should we mark `CPACK_INSTALL_SCRIPTS` as deprecated?

Some related background material:

- [CPack and post-build actions](https://discourse.cmake.org/t/cpack-and-post-build-actions/1296)
- [https://gitlab.kitware.com/cmake/cmake/-/issues/19077](https://gitlab.kitware.com/cmake/cmake/-/issues/19077)

Cc: @zaufi

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [November 2, 2020, 3:25am UTC](https://discourse.cmake.org/t/cpack-pre-build-scripts-duplicates-cpack-install-scripts/2105/2 "2020-11-02T03:25:00Z")

</div>

My comparison between `CPACK_INSTALL_SCRIPTS` and `CPACK_PRE_BUILD_SCRIPTS` is incorrect. The former occurs before targets are even installed, the latter occurs after install but before packages are built. I’ll update the docs to make this clearer and put up a MR for this today.

MR can be found here: [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/5454](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5454)

---

<div class="post-metadata">

### Author: ![zaufi](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zaufi/32/116_2.png) [@zaufi](https://discourse.cmake.org/u/zaufi)
#### Post date: [November 4, 2020, 11:33am UTC](https://discourse.cmake.org/t/cpack-pre-build-scripts-duplicates-cpack-install-scripts/2105/3 "2020-11-04T11:33:31Z")

</div>

Huh, I’ve missed your post… %)  
But yeah, that is just a different stage of package building.

`CPACK_INSTALL_SCRIPTS` similar to `install(CODE|SCRIPT)`, but works only when CPack performs install.

`CPACK_PRE_BUILD_SCRIPTS` aimed to do smth w/ staged files before they are going to be packed. For example, sign executables.

`CPACK_POST_BUILD_SCRIPTS` is for doing smth w/ just built packages. For example, sign them (e.g. RPM/DEB/NuGet).
