Commit 93a44c8
authored
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 packages1 parent 42a425f commit 93a44c8
File tree
6 files changed
+219
-70
lines changed- .github/workflows
- lib
- win-examples
6 files changed
+219
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
| 78 | + | |
| 79 | + | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 81 | + | |
| 82 | + | |
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
| 90 | + | |
93 | 91 | | |
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
97 | 95 | | |
98 | 96 | | |
99 | | - | |
100 | | - | |
| 97 | + | |
101 | 98 | | |
102 | 99 | | |
103 | 100 | | |
104 | 101 | | |
105 | 102 | | |
106 | | - | |
107 | | - | |
| 103 | + | |
108 | 104 | | |
109 | 105 | | |
110 | 106 | | |
| |||
145 | 141 | | |
146 | 142 | | |
147 | 143 | | |
148 | | - | |
| 144 | + | |
149 | 145 | | |
150 | 146 | | |
151 | 147 | | |
| |||
154 | 150 | | |
155 | 151 | | |
156 | 152 | | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
| 156 | + | |
| 157 | + | |
159 | 158 | | |
160 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
177 | 185 | | |
178 | | - | |
| 186 | + | |
179 | 187 | | |
180 | | - | |
| 188 | + | |
181 | 189 | | |
182 | | - | |
183 | | - | |
| 190 | + | |
| 191 | + | |
184 | 192 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 193 | + | |
| 194 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
| 98 | + | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
| |||
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
140 | | - | |
141 | | - | |
| 139 | + | |
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
145 | 143 | | |
146 | | - | |
| 144 | + | |
147 | 145 | | |
148 | 146 | | |
149 | | - | |
| 147 | + | |
| 148 | + | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
153 | | - | |
| 152 | + | |
154 | 153 | | |
155 | 154 | | |
156 | 155 | | |
157 | | - | |
| 156 | + | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
164 | 165 | | |
165 | | - | |
166 | 166 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
171 | 178 | | |
172 | 179 | | |
173 | | - | |
| 180 | + | |
174 | 181 | | |
175 | 182 | | |
176 | 183 | | |
177 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
178 | 193 | | |
179 | 194 | | |
180 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
| |||
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
96 | | - | |
| 101 | + | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
| |||
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
171 | | - | |
| 176 | + | |
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
| |||
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
198 | 234 | | |
199 | 235 | | |
200 | 236 | | |
| |||
211 | 247 | | |
212 | 248 | | |
213 | 249 | | |
214 | | - | |
| 250 | + | |
215 | 251 | | |
216 | 252 | | |
217 | 253 | | |
| |||
220 | 256 | | |
221 | 257 | | |
222 | 258 | | |
223 | | - | |
| 259 | + | |
224 | 260 | | |
225 | 261 | | |
226 | 262 | | |
227 | 263 | | |
228 | 264 | | |
229 | 265 | | |
230 | 266 | | |
231 | | - | |
| 267 | + | |
232 | 268 | | |
233 | 269 | | |
234 | 270 | | |
| |||
295 | 331 | | |
296 | 332 | | |
297 | 333 | | |
298 | | - | |
| 334 | + | |
299 | 335 | | |
300 | 336 | | |
301 | 337 | | |
| |||
307 | 343 | | |
308 | 344 | | |
309 | 345 | | |
310 | | - | |
311 | | - | |
312 | | - | |
| 346 | + | |
313 | 347 | | |
314 | | - | |
315 | | - | |
316 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
317 | 365 | | |
318 | 366 | | |
319 | 367 | | |
| |||
0 commit comments