@@ -193,37 +193,46 @@ set(CTIMESTAMP_PATH_SRC ${CMAKE_SOURCE_DIR}/libs/c-timestamp CACHE PATH
193
193
aux_source_directory (${CTIMESTAMP_PATH_SRC} / DRV_SRC )
194
194
195
195
#
196
- # add libcurl to the project
196
+ # add libcurl (and zlib) to the project
197
197
#
198
198
set (LIBCURL_PATH_SRC ${CMAKE_SOURCE_DIR} /libs/curl CACHE PATH
199
199
"Lib curl source path" )
200
- set (LIBCURL_LINK_MODE static CACHE STRING
201
- "Lib curl linking mode: static (default) or dll" )
202
200
set (LIBCURL_BUILD_TYPE debug CACHE STRING
203
201
"Lib curl build type: debug (default) or release" )
204
202
203
+ # zlib paths
204
+ set (ZLIB_PATH_SRC ${CMAKE_SOURCE_DIR} /libs/zlib CACHE PATH
205
+ "Lib zlib source path" )
206
+ set (ZLIB_PATH_INST ${CMAKE_BINARY_DIR} /zlib CACHE PATH
207
+ "Lib zlib install path" )
208
+
205
209
if (${LIBCURL_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg] )
206
210
set (LIBCURL_DEBUG_ENABLED yes )
207
211
set (LIBCURL_BUILD_TYPE debug )
208
212
set (LIBCURL_BUILD_SUFFIX _debug )
213
+ # zlib's nmake-based "win32" build system contains a default,
214
+ # non-modifiable "-MD". Setting ZLIB_LOC will override it, which will
215
+ # issue a compiler warning (that can be ignored, can't be supressed).
216
+ set (ZLIB_LOC -MDd )
209
217
else (${LIBCURL_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg] )
210
218
set (LIBCURL_DEBUG_ENABLED no )
211
219
set (LIBCURL_BUILD_TYPE release )
212
220
# empty LIBCURL_BUILD_SUFFIX
221
+ # empty ZLIB_LOC
213
222
endif (${LIBCURL_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg] )
214
223
215
224
set (LIBCURL_LD_PATH
216
225
# Curl "installs" the .dll and .lib in different directories -> use the
217
226
# build dir to find both files in same directory instead of installing.
218
227
# Curl's win build root directory is not configurable.
219
- # The path built below is only constant for the subtree tag (current:
220
- # 7.61.0) and default/below nmake options (only with: IPv6, SSPI, WinSSL) .
221
- ${LIBCURL_PATH_SRC} /builds/libcurl-vc-${TARCH}-${LIBCURL_BUILD_TYPE}-${LIBCURL_LINK_MODE} -ipv6-sspi-winssl-obj-lib/
228
+ # The path built below is only constant for the subtree tag and the nmake
229
+ # options below: ZLIB, IPv6, SSPI, WinSSL, plus IDN, not echoed in name .
230
+ ${LIBCURL_PATH_SRC} /builds/libcurl-vc-${TARCH}-${LIBCURL_BUILD_TYPE}-static-zlib-static -ipv6-sspi-winssl-obj-lib/
222
231
CACHE PATH "Lib curl load library path" )
223
232
set (LIBCURL_INC_PATH ${LIBCURL_PATH_SRC} /include CACHE PATH
224
233
"Lib curl include path" )
225
234
226
- # Build libcurl.
235
+ # Build zlib, then libcurl.
227
236
# Note: this happens at config time as a pre-requisite, for now. This might
228
237
# be changed to a build target later (possibly as a CMake subproject: re-link
229
238
# only if out-of-date, skip building the .exe, allow disabling non-HTTP
@@ -232,14 +241,38 @@ set(LIBCURL_INC_PATH ${LIBCURL_PATH_SRC}/include CACHE PATH
232
241
# entire build "single-config", since the build type (rel/dbg) is decided at
233
242
# CMake-generation, not along the MSBuild invocation.
234
243
if (NOT IS_DIRECTORY ${LIBCURL_LD_PATH} )
244
+ # build zlib first.
245
+ message ("Building zlib library in ${ZLIB_PATH_SRC} " )
246
+ execute_process (COMMAND
247
+ # zlib's "win32" makefile builds in situ => always clean before
248
+ # building, potentially removing builds of different architecture than
249
+ # current's build.
250
+ nmake /f win32 /Makefile.msc clean zlib.lib LOC=${ZLIB_LOC}
251
+ RESULT_VARIABLE CMD_RETURN
252
+ WORKING_DIRECTORY "${ZLIB_PATH_SRC} "
253
+ )
254
+ if (${CMD_RETURN} )
255
+ message (FATAL_ERROR "Building zlib failed." )
256
+ endif (${CMD_RETURN} )
257
+ # libcurl expects a /lib and a /include folder under the location provided
258
+ # as the path to zlib. zlib/win32's makefile has no install target, so
259
+ # we'll just cmake-install them under the building dir.
260
+ file (INSTALL ${ZLIB_PATH_SRC} /zlib.lib DESTINATION ${ZLIB_PATH_INST} /lib )
261
+ file (GLOB ZLIB_H_FILES LIST_DIRECTORIES false ${ZLIB_PATH_SRC}
262
+ ${ZLIB_PATH_SRC} /*.h )
263
+ file (INSTALL ${ZLIB_H_FILES} DESTINATION ${ZLIB_PATH_INST} /include )
264
+
265
+ # build libcurl second: config first, build afterwards..
266
+ message ("Building curl library in ${LIBCURL_PATH_SRC} " )
235
267
execute_process (COMMAND buildconf.bat
236
268
RESULT_VARIABLE CMD_RETURN
237
269
WORKING_DIRECTORY "${LIBCURL_PATH_SRC} "
238
270
)
239
271
if (NOT ${CMD_RETURN} )
240
272
execute_process (COMMAND
241
- nmake /f Makefile.vc mode=${LIBCURL_LINK_MODE} MACHINE=${TARCH}
273
+ nmake /f Makefile.vc mode=static MACHINE=${TARCH}
242
274
ENABLE_WINSSL=yes ENABLE_IDN=yes ENABLE_IPV6=yes ENABLE_SSPI=yes
275
+ WITH_ZLIB=static ZLIB_PATH=${ZLIB_PATH_INST}
243
276
# build type needs to be synchronized (to link in the same CRT)
244
277
DEBUG=${LIBCURL_DEBUG_ENABLED}
245
278
# This "sneaks in" a define to disable all other protocols than
@@ -260,32 +293,31 @@ endif(NOT IS_DIRECTORY ${LIBCURL_LD_PATH})
260
293
261
294
# add libcurl as dependency
262
295
if (${WIN32} )
263
- if (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll] )
264
- add_library (libcurl SHARED IMPORTED )
265
- set_property (TARGET libcurl PROPERTY IMPORTED_LOCATION
266
- ${LIBCURL_LD_PATH} /libcurl${LIBCURL_BUILD_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX} )
267
- set_property (TARGET libcurl PROPERTY IMPORTED_IMPLIB
268
- ${LIBCURL_LD_PATH} /libcurl${LIBCURL_BUILD_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX} )
269
- # empty LIBCURL_WIN_LIBS
270
- else (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll] )
271
- add_library (libcurl STATIC IMPORTED )
272
- set_property (TARGET libcurl PROPERTY IMPORTED_LOCATION
273
- ${LIBCURL_LD_PATH} /libcurl_a${LIBCURL_BUILD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} )
274
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DCURL_STATICLIB" )
275
- # Libraries that libcurl/WinSSL links against.
276
- # Removed: wldap32 advapi32 gdi32 user32 (unused with current config)
277
- set (LIBCURL_WIN_LIBS ws2_32 crypt32 normaliz )
278
- endif (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll] )
296
+ add_library (zlib STATIC IMPORTED )
297
+ set_property (TARGET zlib PROPERTY IMPORTED_LOCATION
298
+ ${ZLIB_PATH_INST} /lib/zlib.lib )
299
+
300
+ add_library (libcurl STATIC IMPORTED )
301
+ set_property (TARGET libcurl PROPERTY IMPORTED_LOCATION
302
+ ${LIBCURL_LD_PATH} /libcurl_a${LIBCURL_BUILD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} )
303
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DCURL_STATICLIB" )
304
+ # Libraries that libcurl/WinSSL links against.
305
+ # Removed: wldap32 advapi32 gdi32 user32 (unused with current config)
306
+ set (LIBCURL_WIN_LIBS ws2_32 crypt32 normaliz )
279
307
else (${WIN32} )
280
308
set_property (TARGET libcurl PROPERTY IMPORTED_LOCATION
281
309
${LIBCURL_LD_PATH} /libcurl${CMAKE_SHARED_LIBRARY_SUFFIX} )
282
310
endif (${WIN32} )
283
311
284
312
add_custom_target (curlclean
285
- COMMAND nmake /f Makefile.vc mode=${LIBCURL_LINK_MODE} clean
313
+ COMMAND nmake /f Makefile.vc mode=static clean
286
314
COMMAND ../buildconf.bat -clean
287
315
WORKING_DIRECTORY "${LIBCURL_PATH_SRC} /winbuild"
288
316
)
317
+ add_custom_target (zlibclean
318
+ COMMAND nmake /f win32 /Makefile.msc clean
319
+ WORKING_DIRECTORY "${ZLIB_PATH_SRC} "
320
+ )
289
321
290
322
#
291
323
# add tinycbor to the project
@@ -376,7 +408,7 @@ include_directories(${ODBC_INC} ${DRV_SRC_DIR} ${LIBCURL_INC_PATH}
376
408
${DSNEDITOR_INC_PATH} )
377
409
target_link_libraries (${DRV_NAME} odbccp32 legacy_stdio_definitions
378
410
${DSNBND_LIB_BIN_DIR_BASE} -$<CONFIG>/esdsnbnd${BARCH}${CMAKE_IMPORT_LIBRARY_SUFFIX}
379
- libcurl ${LIBCURL_WIN_LIBS} )
411
+ zlib libcurl ${LIBCURL_WIN_LIBS} )
380
412
381
413
382
414
#
@@ -405,12 +437,6 @@ install(FILES
405
437
LICENSE.rtf LICENSE.txt ${CMAKE_BINARY_DIR} /NOTICE.txt
406
438
DESTINATION ${INSTALL_DIR} )
407
439
# add libcurl if build dynamically
408
- if (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll] )
409
- install (FILES
410
- # need to use FILE : https://public.kitware.com/Bug/view.php?id=14311
411
- ${LIBCURL_LD_PATH} /libcurl${LIBCURL_BUILD_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
412
- DESTINATION ${INSTALL_DIR} )
413
- endif (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll] )
414
440
# add editor DLLs
415
441
install (FILES
416
442
${DSNBND_LIB_BIN_DIR_BASE} -$<CONFIG>/esdsnedt${CMAKE_SHARED_LIBRARY_SUFFIX}
0 commit comments