1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

Help: Document more WINDOWS_EXPORT_ALL_SYMBOLS limitations on data symbols

Issue: #26604
This commit is contained in:
Brad King
2025-01-22 16:19:45 -05:00
parent 10cfc8f538
commit 7a69f9037e

View File

@@ -10,11 +10,24 @@ Enable this boolean property to automatically create a module definition
for a ``SHARED`` library (or executable with :prop_tgt:`ENABLE_EXPORTS`)
on Windows. The module definition file will be passed to the linker
causing all symbols to be exported from the ``.dll``.
For global *data* symbols, ``__declspec(dllimport)`` must still be used when
compiling against the code in the ``.dll``. All other function symbols will
be automatically exported and imported by callers. This simplifies porting
projects to Windows by reducing the need for explicit ``dllexport`` markup,
even in ``C++`` classes.
This simplifies porting projects to Windows by reducing the need for
explicit ``dllexport`` markup, even in ``C++`` classes. Function
symbols will be automatically exported and may be linked by callers.
However, there are some cases when compiling code in a consumer may
require explicit ``dllimport`` markup:
* Global *data* symbols must be explicitly marked with
``__declspec(dllimport)`` in order to link to data in the ``.dll``.
* In cases that the compiler generates references to the virtual function
table, such as in a delegating constructor of a class with virtual
functions, the whole class must be marked with ``__declspec(dllimport)``
in order to link to the vftable in the ``.dll``.
* See the `MSVC Linker /EXPORT Option`_ for more information on data symbols.
.. _`MSVC Linker /EXPORT Option`: https://learn.microsoft.com/en-us/cpp/build/reference/export-exports-a-function
When this property is enabled, zero or more ``.def`` files may also be
specified as source files of the target. The exports named by these files