mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-03 20:29:56 -06:00
On AIX, plugins meant to be loaded into executables via `dlopen` must be linked with access to a list of symbols exported from the executable in order to use them (when not using runtime linking). The AIX linker supports specifying this list as an "import file" passed on the command line either via the `-bI:...` option or (with a leading `#! .` line) as a normal input file like any other library file. The linker import file plays the same role on AIX as import libraries do on Windows. Teach CMake to enable its import library abstraction on AIX for executables with the `ENABLE_EXPORTS` target property set. Teach our internal `ExportImportList` script to optionally generate a leading `#! .` line at the top of the generated export/import list. Update our rule for linking an executable with exports to generate a public-facing "import library" implemented as an AIX linker import file. With this approach, our existing infrastructure for handling import libraries on Windows will now work for AIX linker import files too: * Plugins that link to their executable's symbols will be automatically linked using the import file on the command line. * The executable's import file will be (optionally) installed and exported for use in linking externally-built plugins. This will allow executables and their plugins to build even if we later turn off runtime linking. Issue: #19163
32 lines
1.4 KiB
ReStructuredText
32 lines
1.4 KiB
ReStructuredText
ENABLE_EXPORTS
|
|
--------------
|
|
|
|
Specify whether an executable exports symbols for loadable modules.
|
|
|
|
Normally an executable does not export any symbols because it is the
|
|
final program. It is possible for an executable to export symbols to
|
|
be used by loadable modules. When this property is set to true CMake
|
|
will allow other targets to "link" to the executable with the
|
|
:command:`target_link_libraries` command. On all platforms a target-level
|
|
dependency on the executable is created for targets that link to it.
|
|
Handling of the executable on the link lines of the loadable modules
|
|
varies by platform:
|
|
|
|
* On Windows-based systems (including Cygwin) an "import library" is
|
|
created along with the executable to list the exported symbols.
|
|
Loadable modules link to the import library to get the symbols.
|
|
|
|
* On macOS, loadable modules link to the executable itself using the
|
|
``-bundle_loader`` flag.
|
|
|
|
* On AIX, a linker "import file" is created along with the executable
|
|
to list the exported symbols for import when linking other targets.
|
|
Loadable modules link to the import file to get the symbols.
|
|
|
|
* On other platforms, loadable modules are simply linked without
|
|
referencing the executable since the dynamic loader will
|
|
automatically bind symbols when the module is loaded.
|
|
|
|
This property is initialized by the value of the variable
|
|
:variable:`CMAKE_ENABLE_EXPORTS` if it is set when a target is created.
|