Unknown CMake command "generate_export_header"

Hi, I’m trying to make .dll, and I wrote this CMakeFile.txt:

# Shared Library CMakeList.txt
cmake_minimum_required (VERSION 3.12)

# Set language and the project name
project (mylib CXX)

# add all source files from directories
aux_source_directory("../src" MYLIB_SRC)

# compile library
add_library(mylib SHARED ${MYLIB_SRC})

generate_export_header(mylib)

# add include files
target_include_directories(mylib PUBLIC "../src")

And I want use generate_export_header for generation of export macros for library, but I have this error:

Unknown CMake command “generate_export_header”

Cmake version 3.20.3.

GenerateExportHeader is a module that has to be included, so

...
include(GenerateExportHeader)
generate_export_header(mylib)
...
1 Like

Thank you very much