55# | (__| |_| | _ <| |___
66# \___|\___/|_| \_\_____|
77#
8- # Copyright (C) 1998 - 2017 , Daniel Stenberg, <daniel@haxx.se>, et al.
8+ # Copyright (C) 1998 - 2018 , Daniel Stenberg, <daniel@haxx.se>, et al.
99#
1010# This software is licensed as described in the file COPYING, which
1111# you should have received as part of this distribution. The terms
@@ -100,8 +100,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
100100 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT} " )
101101 endif ()
102102 endforeach ()
103- endif (PICKY_COMPILER )
104- endif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG )
103+ endif ()
104+ endif ()
105105
106106if (ENABLE_DEBUG)
107107 # DEBUGBUILD will be defined only for Debug builds
@@ -118,7 +118,9 @@ if (ENABLE_CURLDEBUG)
118118endif ()
119119
120120# For debug libs and exes, add "-d" postfix
121- set (CMAKE_DEBUG_POSTFIX "-d" CACHE STRING "Set debug library postfix" )
121+ if (NOT DEFINED CMAKE_DEBUG_POSTFIX )
122+ set (CMAKE_DEBUG_POSTFIX "-d" )
123+ endif ()
122124
123125# initialize CURL_LIBS
124126set (CURL_LIBS "" )
@@ -230,22 +232,12 @@ endif()
230232# Disable warnings on Borland to avoid changing 3rd party code.
231233if (BORLAND )
232234 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-" )
233- endif (BORLAND )
234-
235- if (CURL_WERROR)
236- if (MSVC_VERSION )
237- set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX" )
238- set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX" )
239- else ()
240- # this assumes clang or gcc style options
241- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror" )
242- endif ()
243- endif (CURL_WERROR)
235+ endif ()
244236
245237# If we are on AIX, do the _ALL_SOURCE magic
246238if (${CMAKE_SYSTEM_NAME} MATCHES AIX)
247239 set (_ALL_SOURCE 1)
248- endif (${CMAKE_SYSTEM_NAME} MATCHES AIX )
240+ endif ()
249241
250242# Include all the necessary files for macros
251243include (CheckFunctionExists)
@@ -261,7 +253,7 @@ include (CMakeDependentOption)
261253if (WIN32 )
262254 set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=" )
263255 include (${CMAKE_CURRENT_SOURCE_DIR} /CMake/Platforms/WindowsCache.cmake)
264- endif (WIN32 )
256+ endif ()
265257
266258if (ENABLE_THREADED_RESOLVER)
267259 find_package (Threads REQUIRED)
@@ -284,17 +276,18 @@ if(BEOS)
284276 set (NOT_NEED_LIBNSL 1)
285277 check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
286278 check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
287- endif (BEOS )
279+ endif ()
288280
289281if (NOT NOT_NEED_LIBNSL)
290282 check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL)
291- endif (NOT NOT_NEED_LIBNSL )
283+ endif ()
292284
293285check_function_exists(gethostname HAVE_GETHOSTNAME)
294286
295287if (WIN32 )
296288 check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32)
297289 check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
290+ list (APPEND CURL_LIBS "advapi32" )
298291endif ()
299292
300293# check SSL libraries
@@ -316,14 +309,14 @@ if(WIN32 OR CMAKE_USE_DARWINSSL OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS)
316309endif ()
317310option (CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ${openssl_default} )
318311
319- collect_true(enabled_ssl_options enabled_ssl_options_count
312+ count_true( enabled_ssl_options_count
320313 CMAKE_USE_WINSSL
321314 CMAKE_USE_DARWINSSL
322315 CMAKE_USE_OPENSSL
323316 CMAKE_USE_MBEDTLS
324317)
325- if (enabled_ssl_options_count GREATER 1 )
326- message (FATAL_ERROR "Multiple SSL options specified: ${enabled_ssl_options} . Please pick at most one and disable the rest." )
318+ if (enabled_ssl_options_count GREATER "1" )
319+ set (CURL_WITH_MULTI_SSL ON )
327320endif ()
328321
329322if (CMAKE_USE_WINSSL)
@@ -363,7 +356,6 @@ if(CMAKE_USE_OPENSSL)
363356 include_directories (${OPENSSL_INCLUDE_DIR} )
364357 set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
365358 check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
366- check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
367359 check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H)
368360 check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H)
369361 check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
@@ -521,6 +513,18 @@ if(CURL_ZLIB)
521513 endif ()
522514endif ()
523515
516+ option (CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF )
517+ set (HAVE_BROTLI OFF )
518+ if (CURL_BROTLI)
519+ find_package (BROTLI QUIET )
520+ if (BROTLI_FOUND)
521+ set (HAVE_BROTLI ON )
522+ list (APPEND CURL_LIBS ${BROTLI_LIBRARIES} )
523+ include_directories (${BROTLI_INCLUDE_DIRS} )
524+ list (APPEND CMAKE_REQUIRED_INCLUDES ${BROTLI_INCLUDE_DIRS} )
525+ endif ()
526+ endif ()
527+
524528#libSSH2
525529option (CMAKE_USE_LIBSSH2 "Use libSSH2" ON )
526530mark_as_advanced (CMAKE_USE_LIBSSH2)
@@ -551,9 +555,8 @@ if(CMAKE_USE_LIBSSH2)
551555 check_function_exists(libssh2_scp_send64 HAVE_LIBSSH2_SCP_SEND64)
552556 check_function_exists(libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE)
553557 set (CMAKE_EXTRA_INCLUDE_FILES "" )
554-
555- endif (LIBSSH2_FOUND)
556- endif (CMAKE_USE_LIBSSH2)
558+ endif ()
559+ endif ()
557560
558561option (CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF )
559562mark_as_advanced (CMAKE_USE_GSSAPI)
@@ -704,7 +707,7 @@ if(NOT UNIX)
704707 if (NOT CURL_WINDOWS_SSPI AND USE_OPENSSL)
705708 set (CURL_LIBS ${CURL_LIBS} "crypt32" )
706709 endif ()
707- endif (NOT UNIX )
710+ endif ()
708711
709712check_include_file_concat("stdio.h" HAVE_STDIO_H)
710713check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
@@ -787,17 +790,17 @@ check_type_size("time_t" SIZEOF_TIME_T)
787790if (NOT HAVE_SIZEOF_SSIZE_T)
788791 if (SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
789792 set (ssize_t long)
790- endif (SIZEOF_LONG EQUAL SIZEOF_SIZE_T )
793+ endif ()
791794 if (NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
792795 set (ssize_t __int64)
793- endif (NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T )
794- endif (NOT HAVE_SIZEOF_SSIZE_T )
796+ endif ()
797+ endif ()
795798# off_t is sized later, after the HAVE_FILE_OFFSET_BITS test
796799
797800if (HAVE_SIZEOF_LONG_LONG)
798801 set (HAVE_LONGLONG 1)
799802 set (HAVE_LL 1)
800- endif (HAVE_SIZEOF_LONG_LONG )
803+ endif ()
801804
802805find_file (RANDOM_FILE urandom /dev)
803806mark_as_advanced (RANDOM_FILE)
@@ -829,7 +832,7 @@ check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
829832check_symbol_exists(alarm "${CURL_INCLUDES} " HAVE_ALARM)
830833if (NOT HAVE_STRNCMPI)
831834 set (HAVE_STRCMPI)
832- endif (NOT HAVE_STRNCMPI )
835+ endif ()
833836check_symbol_exists(gethostbyaddr "${CURL_INCLUDES} " HAVE_GETHOSTBYADDR)
834837check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES} " HAVE_GETHOSTBYADDR_R)
835838check_symbol_exists(gettimeofday "${CURL_INCLUDES} " HAVE_GETTIMEOFDAY)
@@ -845,6 +848,7 @@ check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
845848check_symbol_exists(getpass_r "${CURL_INCLUDES} " HAVE_GETPASS_R)
846849check_symbol_exists(strlcat "${CURL_INCLUDES} " HAVE_STRLCAT)
847850check_symbol_exists(getpwuid "${CURL_INCLUDES} " HAVE_GETPWUID)
851+ check_symbol_exists(getpwuid_r "${CURL_INCLUDES} " HAVE_GETPWUID_R)
848852check_symbol_exists(geteuid "${CURL_INCLUDES} " HAVE_GETEUID)
849853check_symbol_exists(utime "${CURL_INCLUDES} " HAVE_UTIME)
850854check_symbol_exists(gmtime_r "${CURL_INCLUDES} " HAVE_GMTIME_R)
@@ -857,7 +861,7 @@ check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
857861check_symbol_exists(SIGALRM "${CURL_INCLUDES} " HAVE_SIGNAL_MACRO)
858862if (HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
859863 set (HAVE_SIGNAL 1)
860- endif (HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO )
864+ endif ()
861865check_symbol_exists(uname "${CURL_INCLUDES} " HAVE_UNAME)
862866check_symbol_exists(strtoll "${CURL_INCLUDES} " HAVE_STRTOLL)
863867check_symbol_exists(_strtoi64 "${CURL_INCLUDES} " HAVE__STRTOI64)
@@ -897,29 +901,29 @@ endif()
897901check_symbol_exists(fsetxattr "${CURL_INCLUDES} " HAVE_FSETXATTR)
898902if (HAVE_FSETXATTR)
899903 foreach (CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6)
900- curl_internal_test_run (${CURL_TEST} )
901- endforeach (CURL_TEST )
902- endif (HAVE_FSETXATTR )
904+ curl_internal_test (${CURL_TEST} )
905+ endforeach ()
906+ endif ()
903907
904908# sigaction and sigsetjmp are special. Use special mechanism for
905909# detecting those, but only if previous attempt failed.
906910if (HAVE_SIGNAL_H)
907911 check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
908- endif (HAVE_SIGNAL_H )
912+ endif ()
909913
910914if (NOT HAVE_SIGSETJMP)
911915 if (HAVE_SETJMP_H)
912916 check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
913917 if (HAVE_MACRO_SIGSETJMP)
914918 set (HAVE_SIGSETJMP 1)
915- endif (HAVE_MACRO_SIGSETJMP )
916- endif (HAVE_SETJMP_H )
917- endif (NOT HAVE_SIGSETJMP )
919+ endif ()
920+ endif ()
921+ endif ()
918922
919923# If there is no stricmp(), do not allow LDAP to parse URLs
920924if (NOT HAVE_STRICMP)
921925 set (HAVE_LDAP_URL_PARSE 1)
922- endif (NOT HAVE_STRICMP )
926+ endif ()
923927
924928# Do curl specific tests
925929foreach (CURL_TEST
@@ -957,12 +961,12 @@ foreach(CURL_TEST
957961 HAVE_FILE_OFFSET_BITS
958962 )
959963 curl_internal_test(${CURL_TEST} )
960- endforeach (CURL_TEST )
964+ endforeach ()
961965
962966if (HAVE_FILE_OFFSET_BITS)
963967 set (_FILE_OFFSET_BITS 64)
964968 set (CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64" )
965- endif (HAVE_FILE_OFFSET_BITS )
969+ endif ()
966970check_type_size("off_t" SIZEOF_OFF_T)
967971
968972# include this header to get the type
@@ -977,8 +981,8 @@ foreach(CURL_TEST
977981 HAVE_GLIBC_STRERROR_R
978982 HAVE_POSIX_STRERROR_R
979983 )
980- curl_internal_test_run (${CURL_TEST} )
981- endforeach (CURL_TEST )
984+ curl_internal_test (${CURL_TEST} )
985+ endforeach ()
982986
983987# Check for reentrant
984988foreach (CURL_TEST
@@ -992,9 +996,9 @@ foreach(CURL_TEST
992996 if (NOT ${CURL_TEST} )
993997 if (${CURL_TEST} _REENTRANT)
994998 set (NEED_REENTRANT 1)
995- endif (${CURL_TEST} _REENTRANT )
996- endif (NOT ${CURL_TEST} )
997- endforeach (CURL_TEST )
999+ endif ()
1000+ endif ()
1001+ endforeach ()
9981002
9991003if (NEED_REENTRANT)
10001004 foreach (CURL_TEST
@@ -1007,32 +1011,32 @@ if(NEED_REENTRANT)
10071011 set (${CURL_TEST} 0)
10081012 if (${CURL_TEST} _REENTRANT)
10091013 set (${CURL_TEST} 1)
1010- endif (${CURL_TEST} _REENTRANT )
1011- endforeach (CURL_TEST )
1012- endif (NEED_REENTRANT )
1014+ endif ()
1015+ endforeach ()
1016+ endif ()
10131017
10141018if (HAVE_INET_NTOA_R_DECL_REENTRANT)
10151019 set (HAVE_INET_NTOA_R_DECL 1)
10161020 set (NEED_REENTRANT 1)
1017- endif (HAVE_INET_NTOA_R_DECL_REENTRANT )
1021+ endif ()
10181022
10191023# Some other minor tests
10201024
10211025if (NOT HAVE_IN_ADDR_T)
10221026 set (in_addr_t "unsigned long" )
1023- endif (NOT HAVE_IN_ADDR_T )
1027+ endif ()
10241028
10251029# Fix libz / zlib.h
10261030
10271031if (NOT CURL_SPECIAL_LIBZ)
10281032 if (NOT HAVE_LIBZ)
10291033 set (HAVE_ZLIB_H 0)
1030- endif (NOT HAVE_LIBZ )
1034+ endif ()
10311035
10321036 if (NOT HAVE_ZLIB_H)
10331037 set (HAVE_LIBZ 0)
1034- endif (NOT HAVE_ZLIB_H )
1035- endif (NOT CURL_SPECIAL_LIBZ )
1038+ endif ()
1039+ endif ()
10361040
10371041# Check for nonblocking
10381042set (HAVE_DISABLED_NONBLOCKING 1)
@@ -1041,16 +1045,13 @@ if(HAVE_FIONBIO OR
10411045 HAVE_IOCTLSOCKET_CASE OR
10421046 HAVE_O_NONBLOCK)
10431047 set (HAVE_DISABLED_NONBLOCKING)
1044- endif (HAVE_FIONBIO OR
1045- HAVE_IOCTLSOCKET OR
1046- HAVE_IOCTLSOCKET_CASE OR
1047- HAVE_O_NONBLOCK)
1048+ endif ()
10481049
10491050if (RETSIGTYPE_TEST)
10501051 set (RETSIGTYPE void)
1051- else (RETSIGTYPE_TEST )
1052+ else ()
10521053 set (RETSIGTYPE int)
1053- endif (RETSIGTYPE_TEST )
1054+ endif ()
10541055
10551056if (CMAKE_COMPILER_IS_GNUCC AND APPLE )
10561057 include (CheckCCompilerFlag)
@@ -1060,13 +1061,13 @@ if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
10601061 get_source_file_property (MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS )
10611062 if (MPRINTF_COMPILE_FLAGS)
10621063 set (MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double" )
1063- else (MPRINTF_COMPILE_FLAGS )
1064+ else ()
10641065 set (MPRINTF_COMPILE_FLAGS "-Wno-long-double" )
1065- endif (MPRINTF_COMPILE_FLAGS )
1066+ endif ()
10661067 set_source_files_properties (mprintf.c PROPERTIES
10671068 COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS} )
1068- endif (HAVE_C_FLAG_Wno_long_double )
1069- endif (CMAKE_COMPILER_IS_GNUCC AND APPLE )
1069+ endif ()
1070+ endif ()
10701071
10711072if (HAVE_SOCKLEN_T)
10721073 set (CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t" )
@@ -1101,19 +1102,34 @@ include(CMake/OtherTests.cmake)
11011102
11021103add_definitions (-DHAVE_CONFIG_H)
11031104
1104- # For windows , all compilers used by cmake should support large files
1105+ # For Windows , all compilers used by CMake should support large files
11051106if (WIN32 )
11061107 set (USE_WIN32_LARGE_FILES ON )
1107- endif (WIN32 )
1108+
1109+ # Use the manifest embedded in the Windows Resource
1110+ set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST" )
1111+ endif ()
11081112
11091113if (MSVC )
1114+ # Disable default manifest added by CMake
1115+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO" )
1116+
11101117 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
11111118 if (CMAKE_C_FLAGS MATCHES "/W[0-4]" )
11121119 string (REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS} " )
1113- else (CMAKE_C_FLAGS MATCHES "/W[0-4]" )
1120+ else ()
11141121 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4" )
1115- endif (CMAKE_C_FLAGS MATCHES "/W[0-4]" )
1116- endif (MSVC )
1122+ endif ()
1123+ endif ()
1124+
1125+ if (CURL_WERROR)
1126+ if (MSVC_VERSION )
1127+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX" )
1128+ else ()
1129+ # this assumes clang or gcc style options
1130+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror" )
1131+ endif ()
1132+ endif ()
11171133
11181134# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
11191135function (TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
0 commit comments