# Exporting library generated by custom command

**URL:** <https://discourse.cmake.org/t/exporting-library-generated-by-custom-command/15285>\
**Category:** Code\
**Created:** [November 6, 2025, 7:55am UTC](https://discourse.cmake.org/t/exporting-library-generated-by-custom-command/15285 "2025-11-06T07:55:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![apozharski](https://discourse.cmake.org/user_avatar/discourse.cmake.org/apozharski/32/5886_2.png) [@apozharski](https://discourse.cmake.org/u/apozharski)\
**Post date:** [November 6, 2025, 7:55am UTC](https://discourse.cmake.org/t/exporting-library-generated-by-custom-command/15285/1 "2025-11-06T07:55:37Z")

</div>

Hello, I am currently writing a [Julia package that is used to ahead-of-time compile some Julia code so it can be used as a C-interface](https://github.com/apozharski/libmad). This uses the new `JuliaC.jl` package which acts (essentially) as a compiler, taking a Julia project and producing out a shared library. I then want to export this library. However the standard tricks I have seen using `add_library(SHARED IMPORTED)` do not work for this use case as doing this suggests to CMake that the library was not built by this project. It seems conceptually simple to me that I should be able to just add every property necessary to convince CMake that I did actually build this library in this project, but it seems my mental model or google-fu are faulty as I cannot seem to find a method to do this.

Is this simply impossible?
