# README not packaged in tar.gz or .pkg file in CPack\_install\_scripts

**URL:** https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192
**Category:** Code
**Created:** [November 17, 2020, 6:27pm UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192 "2020-11-17T18:27:25Z")
**Posts on this page:** 6
**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, 6:27pm UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192/1 "2020-11-17T18:27:25Z")

</div>

Somewhat related to - [CPack script not recognizing CMAKE\_BINARY\_DIR](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191)

These are some steps in my CPack configuration file -

```
....
configure_file(README.md README.md COPYONLY)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_BINARY_DIR}/README.md")
set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.md")
configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/CPackfoo.cmake.in ${CMAKE_SOURCE_DIR}/cmake/modules/CPackfoo.cmake @ONLY)
set(CPACK_INSTALL_SCRIPTS ${CMAKE_SOURCE_DIR}/cmake/modules/CPackfoo.cmake)
....

```

And these are some steps inside `CPackfoo.cmake.in` -

```
....
if (APPLE)
  ....
  execute_process(COMMAND textutil -convert html README.md -output "@CMAKE_BINARY_DIR@/README.html")
  set(CPACK_PACKAGE_DESCRIPTION_FILE "@CMAKE_BINARY_DIR@/README.html") # Trying to overwrite the variable
  set(CPACK_RESOURCE_FILE_README "@CMAKE_BINARY_DIR@/README.html") # Trying to overwrite the variable
  ....
endif()
....

```

But when packaging for APPLE, the README.html file is not present either in the packaged tarball or the .pkg file.  
I think the variables set in CPackfoo.cmake are not carried over to the original CPack configuration file.  
How could I fix this?

---

<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 17, 2020, 10:36pm UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192/2 "2020-11-17T22:36:20Z")

</div>

Try using absolute paths for any files you reference, a relative path is fairly ambiguous when tools that use those paths could be running in different directories other than the source directory. This may require you to wire through variables like `CMAKE_BINARY_DIR` as mentioned by @ben.boeckel in another [forum discussion thread](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191/2).

---

<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 18, 2020, 5:36am UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192/3 "2020-11-18T05:36:09Z")

</div>

Ah, sorry I am using absolute paths, but it seems I removed a lot of important detail when trying to produce a minimal example.

I have updated the top post.

Could you please tell me what I could be doing wrong?

---

<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 18, 2020, 6:14am UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192/4 "2020-11-18T06:14:04Z")

</div>

Pretty sure the `if(APPLE)` expression will always evaluate to false inside the `CPackfoo.cmake` file. The `APPLE` variable is defined at configure time, but I don’t think it is defined when `cpack` is running.

---

<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 18, 2020, 6:17am UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192/5 "2020-11-18T06:17:57Z")

</div>

I think the APPLE check works, because this - `execute_process(COMMAND textutil -convert html README.md -output "@CMAKE_BINARY_DIR@/README.html")` is correctly executed and I am able to see a README.html in `${CMAKE_BINARY_DIR}`.

---

<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 18, 2020, 6:29am UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192/6 "2020-11-18T06:29:17Z")

</div>

What package generator are you using? Note that the docs for `CPACK_RESOURCE_FILE_README` mention that not all CPack generators support it.

I suggest that you add some `message(...)` commands around the commands in `CPackfoo.cmake.in` to print out values you are expecting to be set. Run `cpack` with the `-V` option for more verbose output. This should confirm that things are set and executed how and when you expected.
