GenerateExportHeader error

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

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?

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:

  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.

That solved the issue, thanks!