Module libraries: Option to add dynamic lookup flag for Darwin modules
Modules are used for dynamic plugins, which may have undefined references if they use the APIs of other libraries.
On Linux, it is enough to mark these other libraries as OBJECT
and the plugin as MODULE
and it will just work. On Darwin on top of that we need to add a linker specific flag -undefined dynamic_lookup
.
I think this should be enabled for darwin MODULES
by default to exclude platform specific code from plugins cmake lists.
A small example of the issue is here (README and Github Actions included): https://github.com/bugdea1er/dynamic_lookup. It defines an OBJECT and a MODULE library. The main problem here, as I see it, is that the behaviour is different on these platforms and CMake does not provide a cross-platform method for adding the flag where needed.