# How to cpack dependent shared libraries along with my executable?

**URL:** https://discourse.cmake.org/t/how-to-cpack-dependent-shared-libraries-along-with-my-executable/267
**Category:** Usage
**Created:** [November 27, 2019, 12:17am UTC](https://discourse.cmake.org/t/how-to-cpack-dependent-shared-libraries-along-with-my-executable/267 "2019-11-27T00:17:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![oscarh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/aca169/32.png) [@oscarh](https://discourse.cmake.org/u/oscarh)
#### Post date: [November 27, 2019, 12:17am UTC](https://discourse.cmake.org/t/how-to-cpack-dependent-shared-libraries-along-with-my-executable/267/1 "2019-11-27T00:17:34Z")

</div>

I have a cmake project which builds an executable. The executable depends on a 3rd party .so file to run:

> …  
> add\_executable(myapp …)  
> target\_link\_libraries(myapp ${3rd\_party\_so})  
> #install rules:  
> set(CMAKE\_INSTALL\_PREFIX ${CMAKE\_CURRENT\_BINARY\_DIR}/install\_root)  
> install(TARGETS myapp RUNTIME DESTINATION bin)
> 
> #Creating distribution package:  
> include(InstallRequiredSystemLibraries)  
> include(CPack)  
> …

After “cpack -G TXZ”, I only find “myapp” in the bin subfolder of the generated package. Neither system .so files nor the 3rd party .so file are included in the package. What else should I do to make cpack include those .so files?

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [November 27, 2019, 7:12pm UTC](https://discourse.cmake.org/t/how-to-cpack-dependent-shared-libraries-along-with-my-executable/267/2 "2019-11-27T19:12:34Z")

</div>

The `BundleUtilities` module can help with this. A very basic example would be

```cmake
set(APPS ...) # paths to executables
set(DIRS ...) # directories to search for prerequisites
install(CODE
"
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
"
 )

```

---

<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 27, 2019, 11:15pm UTC](https://discourse.cmake.org/t/how-to-cpack-dependent-shared-libraries-along-with-my-executable/267/3 "2019-11-27T23:15:53Z")

</div>

There is also [`file(GET_RUNTIME_DEPENDENCIES)`](https://cmake.org/cmake/help/latest/command/file.html#get-runtime-dependencies) available in 3.15 and newer. This does a more…exact calculation than `BundleUtilities` (but is restricted to the 3 main platforms of today). Once the list of dependent libraries is found, they can be installed and modified as necessary (I’d like to work on getting CMake to ship some common utilities for doing so, but don’t have a timeline).
