CMake installation of a software package that only provides headers and pre compiled libraries

Hello,

We routinely work with a closed source software package, call it Foo, that is distributed as a set of C++ headers and libraries. The install process entails extracting the tarballs containing headers and libs and compiling one wrapper library. There is no pkgconfig or cmake config file provided.

Downstream libraries have been using a FindFoo.cmake and find_package(Foo) in module mode to bring in the targets from the package. This works well but has to be copied into each package that depends on Foo.

Is it possible to write a CMakeLists.txt for Foo that extracts the tarballs, compiles the wrapper lib, and produces a FooConfig.cmake? If so, is there an existing example folks know of that I could look at.

Thank you.

Sure. There is the tutorial as well as blog posts around about doing it. You’ll likely need to make INTERFACE targets for the pre-compiled SDK components. Alternatively, you can make IMPORTED targets during the build as well as during the FooConfig.cmake that you generate.

Thanks Ben. I’m going through the guide on IMPORTED targets now.

https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html