Isn't possible to use an IMPORTED library with FetchContent_Declare?

I created two examples for better understanding:

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

IMHO: That make no sense!

bash-3.2$ ar -p *.a
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

1 Like

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

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 (Sorry, but it was much more complex than your example)