# Choose between shared/static library after find\_package()

**URL:** https://discourse.cmake.org/t/choose-between-shared-static-library-after-find-package/2910
**Category:** Code
**Created:** [March 7, 2021, 1:34pm UTC](https://discourse.cmake.org/t/choose-between-shared-static-library-after-find-package/2910 "2021-03-07T13:34:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kerim](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@kerim](https://discourse.cmake.org/u/kerim)
#### Post date: [March 7, 2021, 1:34pm UTC](https://discourse.cmake.org/t/choose-between-shared-static-library-after-find-package/2910/1 "2021-03-07T13:34:08Z")

</div>

Hi,

I’m writing project wich depends on HDF5. I’m looking for HDF5 via `find_package(HDF5 REQUIRED CONFIG)`. Then I need to chose between static or dynamic linking.

Usually HDF5 provides `hdf5-shared` and `hdf5-static` targets. But they maybe wrapped around namespace `hdf5::hdf5-shared` or `hdf5::hdf5-static`. And the namespace may be arbitrary.

How can I define whether there is a shared lib or static after performing `find_package()`?

---

<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: [March 7, 2021, 10:13pm UTC](https://discourse.cmake.org/t/choose-between-shared-static-library-after-find-package/2910/2 "2021-03-07T22:13:52Z")

</div>

That is up to the package to provide. If the package provides poor information, that is something to take up with upstream. I would recommend they provide variables like `HDF5_SHARED_AVAILABLE` and `HDF5_STATIC_AVAILABLE` (feel free to bikeshed the names).

---

<div class="post-metadata">

### Author: ![kerim](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@kerim](https://discourse.cmake.org/u/kerim)
#### Post date: [March 8, 2021, 12:55pm UTC](https://discourse.cmake.org/t/choose-between-shared-static-library-after-find-package/2910/3 "2021-03-08T12:55:07Z")

</div>

Thank you for information
