# Isn't possible to use an IMPORTED library with FetchContent\_Declare?

**URL:** https://discourse.cmake.org/t/isnt-possible-to-use-an-imported-library-with-fetchcontent-declare/8438
**Category:** Usage
**Created:** [June 30, 2023, 5:28am UTC](https://discourse.cmake.org/t/isnt-possible-to-use-an-imported-library-with-fetchcontent-declare/8438 "2023-06-30T05:28:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bog-dan-ro](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bog-dan-ro/32/3576_2.png) [@bog-dan-ro](https://discourse.cmake.org/u/bog-dan-ro)
#### Post date: [June 30, 2023, 5:28am UTC](https://discourse.cmake.org/t/isnt-possible-to-use-an-imported-library-with-fetchcontent-declare/8438/1 "2023-06-30T05:28:34Z")

</div>

I created two examples for better understanding:

- [GitHub - bog-dan-ro/cmake-imported-lib](https://github.com/bog-dan-ro/cmake-imported-lib) - is an `IMPORTED` static library
- [GitHub - bog-dan-ro/cmake-imported-lib-test](https://github.com/bog-dan-ro/cmake-imported-lib-test) is an example which tries to use it.

Am I doing something wrong or it’s a cmake limitation? I’m using cmake version 3.26.4

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [June 30, 2023, 7:56pm UTC](https://discourse.cmake.org/t/isnt-possible-to-use-an-imported-library-with-fetchcontent-declare/8438/2 "2023-06-30T19:56:38Z")

</div>

IMHO: That make no sense!

```auto
bash-3.2$ ar -p *.a
Zsay_somethingELF>@@
UH??H?H????]?SomethingGCC: (Debian 12.3.0-4) 12.3.0zRx

```

What should CMake do, your library is for some `architecture` and **binary ABI** , but there is no information about this?

Why not fetch the sources of your library?

When the sources are not available, write a [find\_module](https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#a-sample-find-module)

---

<div class="post-metadata">

### Author: ![bog-dan-ro](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bog-dan-ro/32/3576_2.png) [@bog-dan-ro](https://discourse.cmake.org/u/bog-dan-ro)
#### Post date: [July 1, 2023, 5:34am UTC](https://discourse.cmake.org/t/isnt-possible-to-use-an-imported-library-with-fetchcontent-declare/8438/3 "2023-07-01T05:34:53Z")

</div>

Sorry I should give more info about what I’m trying to achieve here:  
I’m trying to use FetchContent\_Declare & FetchContent\_MakeAvailable to download and use a **closed source** library.

[GitHub - bog-dan-ro/cmake-imported-lib](https://github.com/bog-dan-ro/cmake-imported-lib) is a very simple example which declares a static imported library. I didn’t added any platform & ABI support yet as I wanted to keep it as simple as possible.

[GitHub - bog-dan-ro/cmake-imported-lib-test](https://github.com/bog-dan-ro/cmake-imported-lib-test) is another example which is using FetchContent\_Declare & FetchContent\_MakeAvailable to download & use the previous example library.

I was hopping that cmake will make it available via FetchContent\_Declare & FetchContent\_MakeAvailable as it does with libraries built from sources.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [July 1, 2023, 6:53am UTC](https://discourse.cmake.org/t/isnt-possible-to-use-an-imported-library-with-fetchcontent-declare/8438/4 "2023-07-01T06:53:40Z")

</div>

We have the same Problems, but you have to write code like in find\_module example, then it can work.

Or you may have a lock at my solution for a TPS without CMake installation support: [axcioma/CMakeLists.txt at release/AXCIOMA\_v2.2.1-ck · ClausKlein/axcioma · GitHub](https://github.com/ClausKlein/axcioma/blob/release/AXCIOMA_v2.2.1-ck/CMakeLists.txt) (Sorry, but it was much more complex than your example)
