# GenerateExportHeader: This macro can only be used with libraries?

**URL:** <https://discourse.cmake.org/t/generateexportheader-this-macro-can-only-be-used-with-libraries/15464>\
**Category:** Code\
**Created:** [January 16, 2026, 10:44pm UTC](https://discourse.cmake.org/t/generateexportheader-this-macro-can-only-be-used-with-libraries/15464 "2026-01-16T22:44:13Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [January 16, 2026, 10:44pm UTC](https://discourse.cmake.org/t/generateexportheader-this-macro-can-only-be-used-with-libraries/15464/1 "2026-01-16T22:44:14Z")

</div>

```bash
CMake Warning at /Users/runner/work/_temp/-295072365/cmake-4.2.1-macos-universal/CMake.app/Contents/share/cmake-4.2/Modules/GenerateExportHeader.cmake:690 (message):
  This macro can only be used with libraries
Call Stack (most recent call first):
  CMakeLists.txt:64 (generate_export_header)

```

I have a header only library which may be build as `CXX_MODULE`.

To build Windows dll, I need to export the public interfaces.

But NOT, if I build only an `interface library`.

### With this _cmake_ _configure warning_ the build fails caused by missing header file?

---

<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:** [January 16, 2026, 10:55pm UTC](https://discourse.cmake.org/t/generateexportheader-this-macro-can-only-be-used-with-libraries/15464/2 "2026-01-16T22:55:34Z")

</div>

My solution is:

> <https://github.com/ClausKlein/scope/commit/f51bfa4b0a85363a3461bebafff2d1abce6fc8d6>
>
> This is needed if only an interface library is build
