# CPack script not recognizing CMAKE\_BINARY\_DIR

**URL:** https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191
**Category:** Code
**Created:** [November 17, 2020, 2:57pm UTC](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191 "2020-11-17T14:57:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![reikdas](https://discourse.cmake.org/user_avatar/discourse.cmake.org/reikdas/32/957_2.png) [@reikdas](https://discourse.cmake.org/u/reikdas)
#### Post date: [November 17, 2020, 2:57pm UTC](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191/1 "2020-11-17T14:57:27Z")

</div>

For my CPack configuration, I have a step where I do -  
`set(CPACK_INSTALL_SCRIPTS ${CMAKE_SOURCE_DIR}/cmake/CPackfoo.cmake)`

Inside `CPackfoo.cmake` , I am using a command - `execute_process(COMMAND textutil -convert html README.md -output "${CMAKE_BINARY_DIR}/README.html")`  
But it seems like `${CMAKE_BINARY_DIR}` is not recognized here and `textutil` tries to write `README.html` to `/` . Is there an obvious way to fix this that I am missing?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 17, 2020, 4:27pm UTC](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191/2 "2020-11-17T16:27:01Z")

</div>

I think that sounds right. Not all CMake variables are transported over to CPack time. Apparently `CMAKE_BINARY_DIR` is one of them. You could `configure_file(@ONLY)` the script and use `@CMAKE_BINARY_DIR@` to have it be replaced at a time when it is known.
