# How to get the packaging directory in a CPACK\_PRE\_BUILD\_SCRIPTS ?

**URL:** https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339
**Category:** Usage
**Created:** [June 15, 2023, 10:18am UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339 "2023-06-15T10:18:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [June 15, 2023, 10:18am UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339/1 "2023-06-15T10:18:26Z")

</div>

Hi,

when creating a package, I’d like to run some commands on the installed, but not yet packaged executables.  
in the scripts in CPACK\_INSTALL\_SCRIPTS there is the variable CMAKE\_INSTALL\_PREFIX set to the directory where the temporarily installed files are located.  
How do I get to this information in CPACK\_PRE\_BUILD\_SCRIPTS (and maybe CPACK\_POST\_BUILD\_SCRIPTS) ?  
(CPACK\_PACKAGE\_DIRECTORY and CPACK\_INSTALL\_PREFIX also don’t give me the temporary install dir.)  
Is there a reason that CMAKE\_PREFIX\_PATH is not set the same way when executing those two scripts ?

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [June 15, 2023, 11:29am UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339/2 "2023-06-15T11:29:34Z")

</div>

Ok, I found it in the cmake sources, there are CPACK\_TEMPORARY\_INSTALL\_DIRECTORY and CPACK\_TEMPORARY\_DIRECTORY (which both point to the same, correct directory) and also CPACK\_NATIVE\_INSTALL\_DIRECTORY. Unfortunately all of them are undocumented.

---

<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: [June 15, 2023, 12:52pm UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339/3 "2023-06-15T12:52:11Z")

</div>

You can find a previous discussion about this topic here: [https://gitlab.kitware.com/cmake/cmake/-/issues/21520](https://gitlab.kitware.com/cmake/cmake/-/issues/21520)

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [June 15, 2023, 1:49pm UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339/4 "2023-06-15T13:49:58Z")

</div>

Thanks.  
In 2006 the variables CPACK\_TEMPORARY\_INSTALL\_DIRECTORY and CPACK\_TEMPORARY\_DIRECTORY were still different:  
[https://gitlab.kitware.com/cmake/cmake/-/blame/3eea1990f51ef8d8a2c1e006a4f2fe089a64b836/Source/CPack/cmCPackGenericGenerator.cxx?page=1](https://gitlab.kitware.com/cmake/cmake/-/blame/3eea1990f51ef8d8a2c1e006a4f2fe089a64b836/Source/CPack/cmCPackGenericGenerator.cxx?page=1)

Since 2008 those two variables are the same:  
[https://gitlab.kitware.com/cmake/cmake/-/commit/1105a86c520d34a59b482b86b6f288c11ff45b81](https://gitlab.kitware.com/cmake/cmake/-/commit/1105a86c520d34a59b482b86b6f288c11ff45b81)  
Which one should be the “official” one ?  
I think I’d prefer CPACK\_TEMPORARY\_INSTALL\_DIRECTORY, the other one sounds more like a place for random temporary stuff.

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [June 15, 2023, 9:57pm UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339/5 "2023-06-15T21:57:26Z")

</div>

I created a merge request: [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/8566](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8566)
