Is there a generic way to detect and reject underlinking?

In many projects I use:

set(LINKER_OPTIONS "LINKER:-z,defs")

to prevent underlinking. But this requires tests for what platform is being used (macOS does not recognize this flag, and doesn’t need it), and perhaps even depends on the compiler and linker toolchain being used.

Is there a “generic” way to have CMake provide this for me, when it is needed?

There’s no generic CMake feature to do this that I’m aware of.