# packaging an imported, but first-party, library

**URL:** <https://discourse.cmake.org/t/packaging-an-imported-but-first-party-library/13698>\
**Category:** Code\
**Created:** [March 7, 2025, 10:19pm UTC](https://discourse.cmake.org/t/packaging-an-imported-but-first-party-library/13698 "2025-03-07T22:19:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattp](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mattp/32/5078_2.png) [@mattp](https://discourse.cmake.org/u/mattp)\
**Post date:** [March 7, 2025, 10:19pm UTC](https://discourse.cmake.org/t/packaging-an-imported-but-first-party-library/13698/1 "2025-03-07T22:19:41Z")

</div>

In my product, we have a C++ library which depends on a library produced by Graal VM’s `native-image` tool. Effectively, a binary-only dependency. We build that from a set of Java sources.

I can get CMake to correctly build and link my C++ library with the native image library, and install both libraries and their headers, and even generate a tarball containing everything using CPack.

What I want to do is make it possible for users of the library to grab the CPack produced tarball and easily import it into their CMake-based project. The generated `.cmake` files mean I can import and add the library to a project, but the native-image-produced library, which is an IMPORTED library in our build, is not included in those `.cmake`s, and so the build fails because enough info is there for CMake to specify that the native-image-produced targets should be linked, but no more.

Once I can make it work I can look at making the whole thing usable with `find_package()`, but that feels like a problem for later.

Has anyone tried this, or something like it? Because all the parts here produced by me in some form, it feels like there ought to be the scope to make this work. I’d rather not create one of these exported `.cmake` files by hand, but at the moment that feels like the least stupid way.

Thanks!

---

<div class="post-metadata">

**Author:** ![mattp](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mattp/32/5078_2.png) [@mattp](https://discourse.cmake.org/u/mattp)\
**Post date:** [April 8, 2025, 2:14pm UTC](https://discourse.cmake.org/t/packaging-an-imported-but-first-party-library/13698/2 "2025-04-08T14:14:44Z")

</div>

To make this work, I’ve set up a ‘fake’ CMake project which builds a correctly-named library and has correctly-named headers. (There are only two…). From that I can create the `find_package()` machinery, and then I can copy \*Config.cmake and friends out and pair them with the correct library and header files, and, hey presto, I can import the resulting project into my C++ wrapper project and build a package tarball that includes all the things needed for a downstream user to download, unpack, and `find_package()`. It’s a bit more Frankenstein’s monster than I wanted, but it has been getting the job done.
