You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support linking static dependencies when building with MSVC (#73)
* Support linking static dependencies when building with MSVC
### Motivation
Currently it's impossible to build Pulsar C++ client on Windows with
`LINK_STATIC=ON`. It means users have to package all 3rd-party DLLs as
well as `pulsar.dll`, which harms the experience.
### Modifications
Enable `LINK_STATIC` when the Vcpkg triplet is `xxx-static`. In this
case, find the 3rd party libraries with correct names on Windows. And
replace `Threads::Threads` with `CMAKE_THREAD_LIB_INIT`.
The most important change is replacing the `/MD` compile option with
`/MT`. It should have been done by setting the
[`MSVC_RUNTIME_LIBRARY`](https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html)
property, but it seems not work. So this PR just modifies the
`CMAKE_CXX_FLAGS_<CONFIG>` variables.
For `pulsarWithAllDeps.lib`, add the actual library (`*.lib`) to
`COMMON_LIBS` instead of the target name (`dlfcn-win32::dl`).
Some warnings on Windows caused by incorrect compile options are fixed
as well.
A workflow is added to verify the static build for x64 and x86 Windows.
And a simple example is added as `win-examples` to show the
`pulsarWithAllDeps.lib` can be linked without any other dependency to
run an executable.
Change the existing release workflow to release two `*.zip` files:
- pulsar-client-cpp-x64-windows-static.zip
- pulsar-client-cpp-x86-windows-static.zip
Each zip file consists of:
```
bin/pulsar.dll - The dynamic library that links statically to dependencies
include/pulsar/ - Headers
lib/
pulsar.lib - The import library of pulsar.dll
pulsar-static.lib - The static library
pulsarWithDeps.lib - The static library with all dependnecies included
dependencies.txt - The vcpkg outputs, which contains the dependency versions
```
* Support Debug build and upload debug binaries
* Fix $ is missing
* Fix apt-get install failure
* Remove default LINK_STATIC build
* Use upload-artifact for Linux packages
0 commit comments