I made a little GitHub repo based off the official cmake\Help\guide\tutorial\Complete at 0fdfd6bf. Kept things simple, all C code, two CMakeLists.txt (one library; one executable). And GitHub Actions so you can replicate in a pull-request (or just review my full log files):
BTW: I’m hacking around with generate_export_header now… maybe if I manually set the visibility for the function and array in my versions.h then it’ll work (just going off your suggestion)
EDIT: The generated header file is not findable even after adding its directory to target_include_directories and trying "" and <> with basename, and various levels of relative paths. Weird.
Unfortunately ${CMAKE_CURRENT_SOURCE_DIR} was the only thing that worked. Tried everything from relative paths to no EXPORT_FILE_NAME to completely different targets.
BTW: I actually did solve this linker error. With this export header setup properly it actually ran.