# How to extract library into its own CMake project

**URL:** <https://discourse.cmake.org/t/how-to-extract-library-into-its-own-cmake-project/4721>\
**Category:** Usage\
**Created:** [December 20, 2021, 3:35pm UTC](https://discourse.cmake.org/t/how-to-extract-library-into-its-own-cmake-project/4721 "2021-12-20T15:35:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![poseid](https://discourse.cmake.org/user_avatar/discourse.cmake.org/poseid/32/666_2.png) [@poseid](https://discourse.cmake.org/u/poseid)\
**Post date:** [December 20, 2021, 3:35pm UTC](https://discourse.cmake.org/t/how-to-extract-library-into-its-own-cmake-project/4721/1 "2021-12-20T15:35:05Z")

</div>

Hello,

i have a CMake project which builds among other things a shared library foo.so / foo.dll  
Where can I find an example how to extract a part of this projects into its own standalone CMake project?

What would be then good practice to link to this external library?

Thanks for any help!

---

<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:** [December 21, 2021, 12:28pm UTC](https://discourse.cmake.org/t/how-to-extract-library-into-its-own-cmake-project/4721/2 "2021-12-21T12:28:54Z")

</div>

You’ll want to make it a project that installs its libraries, headers, and a CMake package. The [Importing and Exporting Guide](https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html) describes how to do this.
