[CMake] How to use a generated linker map with a shared library?

Paul Smith paul at mad-scientist.net
Sat Jan 14 21:16:21 EST 2017


On Sun, 2017-01-15 at 12:08 +1100, Craig Scott wrote:
> While not directly answering your question, it seems you may be trying
> to deal with symbol visibility. Are you aware of CMake's symbol
> visibility features? A good place to start would be the
> GenerateExportHeader module, the documentation for which does a
> reasonable job of showing how to use the visibility features CMake
> provides.

Yes, thanks for that info.  My situation is that I need to force ALL
symbols to be private, even those from external static shared libraries
that I'm linking in (whose symbols have global visibility by default).

So I need a linker script that contains (this is for GCC's ld):

  {
      global: ...;
      local: *;
  };

I need the "local: *;" to hide the external symbols, but to keep it from
hiding all my global symbols I need to list them all explicitly in the
global: section.

> Dealing with your question more directly, you may want to look at the
> TARGET form of add_custom_command() and in particular, the PRE_LINK
> keyword. See the Build Events section near the bottom of the page for
> the add_custom_command() docs.

Oh beauty!  That seems to be just what I need.  Thanks!


More information about the CMake mailing list