Skip to content

Use explicit DLL exports on Windows

Compare
Choose a tag to compare
@wravery wravery released this 14 Mar 00:47
155a366

This should be backwards compatible at the source/CMake level with previous 3.x versions, but the change is big enough that I decided to rev the minor version to 3.2.

Previously, if you used BUILD_SHARED_LIBS on Windows (including building with vcpkg by default), it was setting CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS and letting CMake figure out all of the symbols in all of the DLLs and mark them as exported. That bloats the import libs which are used to consume them and increases the binary size considerably.

This release replaces that mechanism with explicit __declspec(dllimport/dllimport) attributes defined conditionally through macros on Windows for the methods which are actually referenced across modules. There should be no duplication of symbols between DLLs, and part of that meant I needed to split graphqlresponse into an independent library target/DLL in order to take a dependency on it from both graphqljson and graphqlservice.

I've tested this with static and shared libraries on Windows and Linux, as well as building with vcpkg and verifying that schemagen and the samples/tests still work.