Choose between shared/static library after find_package()


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()?

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).

1 Like

Thank you for information