# GenerateExportHeader error

**URL:** https://discourse.cmake.org/t/generateexportheader-error/5304
**Category:** Usage
**Created:** [March 26, 2022, 7:43pm UTC](https://discourse.cmake.org/t/generateexportheader-error/5304 "2022-03-26T19:43:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [March 26, 2022, 7:43pm UTC](https://discourse.cmake.org/t/generateexportheader-error/5304/1 "2022-03-26T19:43:17Z")

</div>

Attempting to use the GenerateExportHeader module, I get this error:

```auto
CMake Error: File /exportheader.cmake.in does not exist.
CMake Error at /usr/local/Cellar/cmake/3.22.3/share/cmake/Modules/GenerateExportHeader.cmake:406 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.22.3/share/cmake/Modules/GenerateExportHeader.cmake:422 (_do_generate_export_header)
  Cache/oranges-src/modules/code_generation/OrangesGenerateExportHeader.cmake:93 (generate_export_header)

```

It looks like an internal CMake file is somehow missing. I get this error on both my local machine and on CI.

Does anyone have any ideas?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [March 26, 2022, 10:11pm UTC](https://discourse.cmake.org/t/generateexportheader-error/5304/2 "2022-03-26T22:11:41Z")

</div>

Looks to me like you’ve called `generate_export_header()` without ensuring you’ve called `include(GenerateExportHeader)` in the same scope or a parent of it. The line in `GenerateExportHeader.cmake` where the error is coming from is this:

```cmake
  configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in"
    "${EXPORT_FILE_NAME}" @ONLY)

```

The error message indicates that `_GENERATE_EXPORT_HEADER_MODULE_DIR` is not set. That would only be the case if you had not called `include(GenerateExportHeader)` in the current or parent scope.

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [March 26, 2022, 10:22pm UTC](https://discourse.cmake.org/t/generateexportheader-error/5304/3 "2022-03-26T22:22:28Z")

</div>

That solved the issue, thanks!
