# cpack and third-party libs on mac os

**URL:** https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366
**Category:** Usage
**Created:** [May 19, 2021, 12:58pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366 "2021-05-19T12:58:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![manang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/manang/32/1460_2.png) [@manang](https://discourse.cmake.org/u/manang)
#### Post date: [May 19, 2021, 12:58pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366/1 "2021-05-19T12:58:52Z")

</div>

Hi,  
I’m trying to create an installer on Mac Os of a little project that uses openssl as dependency.  
I need to create an installer that includes libssl and libcrypto in my destination foder.  
How can I change the rpath on the third-party libraries?  
Thank you very much for your help  
Angelo

---

<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: [May 19, 2021, 1:02pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366/2 "2021-05-19T13:02:22Z")

</div>

You’ll need to run `install_name_tool` to edit the libraries (post-installation). Though @kyle.edwards is working on some code which should help with that, it’s not in a CMake release yet.

---

<div class="post-metadata">

### Author: ![manang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/manang/32/1460_2.png) [@manang](https://discourse.cmake.org/u/manang)
#### Post date: [May 19, 2021, 1:05pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366/3 "2021-05-19T13:05:50Z")

</div>

Hi, thanks for your very fast answer.  
I found this command:

```auto
add_custom_command(TARGET executable 
    POST_BUILD COMMAND 
    ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../../Frameworks/"
    $<TARGET_FILE:executable>)

```

My problem is: how can I run it recursively to non-system libraries?  
Thanks  
Angelo

---

<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: [May 19, 2021, 1:24pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366/4 "2021-05-19T13:24:45Z")

</div>

For your own code, just do something like:

```auto
list(APPEND CMAKE_INSTALL_RPATH
  "@executable_path/../../Frameworks")
add_executable(…)
# Or edit the `INSTALL_RPATH` property on the executable afterwards.

```

There’s no mechanism to run `install_name_tool` recursively, but you could write a CMake script and use `install(SCRIPT)` to run it. [`file(GET_RUNTIME_DEPENDENCIES)`](https://cmake.org/cmake/help/latest/command/file.html#get-runtime-dependencies) is useful for this.

---

<div class="post-metadata">

### Author: ![manang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/manang/32/1460_2.png) [@manang](https://discourse.cmake.org/u/manang)
#### Post date: [May 19, 2021, 2:59pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366/5 "2021-05-19T14:59:08Z")

</div>

Hi,  
thanks for your help.

I’m noticing that during the “make package” phase, the script creates a folder  
./\_CPack\_Packages/Darwin/productbuild/MyLib-1.0.0-Darwin/development/Applications/lib/  
where I can find all the libraries that I want to install.  
how can I tell to cpack to execute a script before the package or after the installation phase?  
Thank you

---

<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: [May 19, 2021, 4:07pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366/6 "2021-05-19T16:07:06Z")

</div>

Those files get copied there based on project-specific rules. I imagine it is either using `file(GRD)` or the `BundleUtilities` module already. You’ll have to hook into those parts of the code to do any post-processing.
