Windows: Optionally generate DLL module definition files automatically

Create target property WINDOWS_EXPORT_ALL_SYMBOLS to automatically
generate a module definition file from MS-compatible .obj files and give
it to the linker in order to export all symbols from the .dll part of a
SHARED library.
This commit is contained in:
Bill Hoffman
2015-06-19 16:12:43 -04:00
committed by Brad King
parent 069aa93b55
commit 8f86407cfd
26 changed files with 455 additions and 3 deletions
+1
View File
@@ -251,6 +251,7 @@ Properties on Targets
/prop_tgt/VS_WINRT_EXTENSIONS
/prop_tgt/VS_WINRT_REFERENCES
/prop_tgt/WIN32_EXECUTABLE
/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS
/prop_tgt/XCODE_ATTRIBUTE_an-attribute
/prop_tgt/XCTEST
+1
View File
@@ -275,6 +275,7 @@ Variables that Control the Build
/variable/CMAKE_USE_RELATIVE_PATHS
/variable/CMAKE_VISIBILITY_INLINES_HIDDEN
/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
/variable/CMAKE_WIN32_EXECUTABLE
/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute
/variable/EXECUTABLE_OUTPUT_PATH
@@ -0,0 +1,18 @@
WINDOWS_EXPORT_ALL_SYMBOLS
--------------------------
This property is implemented only for MS-compatible tools on Windows.
Enable this boolean property to automatically create a module definition
(``.def``) file with all global symbols found in the input ``.obj`` files
for a ``SHARED`` library 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 property is initialized by the value of
the :variable:`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` variable if it is set
when a target is created.
@@ -0,0 +1,6 @@
auto_export_dll_symbols
-----------------------
* On Windows with MS-compatible tools, CMake learned to optionally
generate a module definition (``.def``) file for ``SHARED`` libraries.
See the :prop_tgt:`WINDOWS_EXPORT_ALL_SYMBOLS` target property.
@@ -0,0 +1,6 @@
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
--------------------------------
Default value for :prop_tgt:`WINDOWS_EXPORT_ALL_SYMBOLS` target property.
This variable is used to initialize the property on each target as it is
created.