I am building static libraries with CMake, but the final linking process happens in a custom make script. In one of the components that build a library, there is a table that's not used in the code, but contains version information and has to end up in the final executable.
The compiler here is tasking, but its linker should behave similar to gcc.
Currently there is a makefile that defines a linker option to achieve that:
LINK_OPT += --extern=MyTable myLibrary.a
which I am reasonably sure is the equivalent of gcc's --undefined=MyTable myLibrary.a
.
My goal is to get rid of those makefiles, so the component can be defined solely in CMake. The issue I have is that, due to how the build is set up with the linking not happening in the CMake context, simply attaching linker options to the static library targets in CMake won't help, as they aren't available when I actually link.
I have tried using __attribute__((used))
and __attribute__((export))
in the source code, but they didn't help. I checked the compiler supports them, and suspect they would work if I simply linked object files instead of libraries(?)
Is there any meta information I can attach to the library or the source code that tells the linker to please include MyTable in the executable, without me having to specify a linker option on the linker command line?