5
5
# | (__| |_| | _ <| |___
6
6
# \___|\___/|_| \_\_____|
7
7
#
8
- # Copyright (C) 1998 - 2017 , Daniel Stenberg, <[email protected] >, et al.
8
+ # Copyright (C) 1998 - 2018 , Daniel Stenberg, <[email protected] >, et al.
9
9
#
10
10
# This software is licensed as described in the file COPYING, which
11
11
# 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)
100
100
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT} " )
101
101
endif ()
102
102
endforeach ()
103
- endif (PICKY_COMPILER )
104
- endif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG )
103
+ endif ()
104
+ endif ()
105
105
106
106
if (ENABLE_DEBUG )
107
107
# DEBUGBUILD will be defined only for Debug builds
@@ -118,7 +118,9 @@ if (ENABLE_CURLDEBUG)
118
118
endif ()
119
119
120
120
# 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 ()
122
124
123
125
# initialize CURL_LIBS
124
126
set (CURL_LIBS "" )
@@ -230,22 +232,12 @@ endif()
230
232
# Disable warnings on Borland to avoid changing 3rd party code.
231
233
if (BORLAND )
232
234
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 ()
244
236
245
237
# If we are on AIX, do the _ALL_SOURCE magic
246
238
if (${CMAKE_SYSTEM_NAME} MATCHES AIX )
247
239
set (_ALL_SOURCE 1 )
248
- endif (${CMAKE_SYSTEM_NAME} MATCHES AIX )
240
+ endif ()
249
241
250
242
# Include all the necessary files for macros
251
243
include (CheckFunctionExists )
@@ -261,7 +253,7 @@ include (CMakeDependentOption)
261
253
if (WIN32 )
262
254
set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=" )
263
255
include (${CMAKE_CURRENT_SOURCE_DIR} /CMake/Platforms/WindowsCache.cmake )
264
- endif (WIN32 )
256
+ endif ()
265
257
266
258
if (ENABLE_THREADED_RESOLVER )
267
259
find_package (Threads REQUIRED )
@@ -284,17 +276,18 @@ if(BEOS)
284
276
set (NOT_NEED_LIBNSL 1 )
285
277
check_library_exists_concat ("bind" gethostbyname HAVE_LIBBIND )
286
278
check_library_exists_concat ("bnetapi" closesocket HAVE_LIBBNETAPI )
287
- endif (BEOS )
279
+ endif ()
288
280
289
281
if (NOT NOT_NEED_LIBNSL )
290
282
check_library_exists_concat ("nsl" gethostbyname HAVE_LIBNSL )
291
- endif (NOT NOT_NEED_LIBNSL )
283
+ endif ()
292
284
293
285
check_function_exists (gethostname HAVE_GETHOSTNAME )
294
286
295
287
if (WIN32 )
296
288
check_library_exists_concat ("ws2_32" getch HAVE_LIBWS2_32 )
297
289
check_library_exists_concat ("winmm" getch HAVE_LIBWINMM )
290
+ list (APPEND CURL_LIBS "advapi32" )
298
291
endif ()
299
292
300
293
# check SSL libraries
@@ -316,14 +309,14 @@ if(WIN32 OR CMAKE_USE_DARWINSSL OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS)
316
309
endif ()
317
310
option (CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ${openssl_default} )
318
311
319
- collect_true ( enabled_ssl_options enabled_ssl_options_count
312
+ count_true ( enabled_ssl_options_count
320
313
CMAKE_USE_WINSSL
321
314
CMAKE_USE_DARWINSSL
322
315
CMAKE_USE_OPENSSL
323
316
CMAKE_USE_MBEDTLS
324
317
)
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 )
327
320
endif ()
328
321
329
322
if (CMAKE_USE_WINSSL )
@@ -363,7 +356,6 @@ if(CMAKE_USE_OPENSSL)
363
356
include_directories (${OPENSSL_INCLUDE_DIR} )
364
357
set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
365
358
check_include_file ("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H )
366
- check_include_file ("openssl/engine.h" HAVE_OPENSSL_ENGINE_H )
367
359
check_include_file ("openssl/err.h" HAVE_OPENSSL_ERR_H )
368
360
check_include_file ("openssl/pem.h" HAVE_OPENSSL_PEM_H )
369
361
check_include_file ("openssl/rsa.h" HAVE_OPENSSL_RSA_H )
@@ -521,6 +513,18 @@ if(CURL_ZLIB)
521
513
endif ()
522
514
endif ()
523
515
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
+
524
528
#libSSH2
525
529
option (CMAKE_USE_LIBSSH2 "Use libSSH2" ON )
526
530
mark_as_advanced (CMAKE_USE_LIBSSH2 )
@@ -551,9 +555,8 @@ if(CMAKE_USE_LIBSSH2)
551
555
check_function_exists (libssh2_scp_send64 HAVE_LIBSSH2_SCP_SEND64 )
552
556
check_function_exists (libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE )
553
557
set (CMAKE_EXTRA_INCLUDE_FILES "" )
554
-
555
- endif (LIBSSH2_FOUND )
556
- endif (CMAKE_USE_LIBSSH2 )
558
+ endif ()
559
+ endif ()
557
560
558
561
option (CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF )
559
562
mark_as_advanced (CMAKE_USE_GSSAPI )
@@ -704,7 +707,7 @@ if(NOT UNIX)
704
707
if (NOT CURL_WINDOWS_SSPI AND USE_OPENSSL )
705
708
set (CURL_LIBS ${CURL_LIBS} "crypt32" )
706
709
endif ()
707
- endif (NOT UNIX )
710
+ endif ()
708
711
709
712
check_include_file_concat ("stdio.h" HAVE_STDIO_H )
710
713
check_include_file_concat ("inttypes.h" HAVE_INTTYPES_H )
@@ -787,17 +790,17 @@ check_type_size("time_t" SIZEOF_TIME_T)
787
790
if (NOT HAVE_SIZEOF_SSIZE_T )
788
791
if (SIZEOF_LONG EQUAL SIZEOF_SIZE_T )
789
792
set (ssize_t long )
790
- endif (SIZEOF_LONG EQUAL SIZEOF_SIZE_T )
793
+ endif ()
791
794
if (NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T )
792
795
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 ()
795
798
# off_t is sized later, after the HAVE_FILE_OFFSET_BITS test
796
799
797
800
if (HAVE_SIZEOF_LONG_LONG )
798
801
set (HAVE_LONGLONG 1 )
799
802
set (HAVE_LL 1 )
800
- endif (HAVE_SIZEOF_LONG_LONG )
803
+ endif ()
801
804
802
805
find_file (RANDOM_FILE urandom /dev )
803
806
mark_as_advanced (RANDOM_FILE )
@@ -829,7 +832,7 @@ check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
829
832
check_symbol_exists (alarm "${CURL_INCLUDES} " HAVE_ALARM )
830
833
if (NOT HAVE_STRNCMPI )
831
834
set (HAVE_STRCMPI )
832
- endif (NOT HAVE_STRNCMPI )
835
+ endif ()
833
836
check_symbol_exists (gethostbyaddr "${CURL_INCLUDES} " HAVE_GETHOSTBYADDR )
834
837
check_symbol_exists (gethostbyaddr_r "${CURL_INCLUDES} " HAVE_GETHOSTBYADDR_R )
835
838
check_symbol_exists (gettimeofday "${CURL_INCLUDES} " HAVE_GETTIMEOFDAY )
@@ -845,6 +848,7 @@ check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
845
848
check_symbol_exists (getpass_r "${CURL_INCLUDES} " HAVE_GETPASS_R )
846
849
check_symbol_exists (strlcat "${CURL_INCLUDES} " HAVE_STRLCAT )
847
850
check_symbol_exists (getpwuid "${CURL_INCLUDES} " HAVE_GETPWUID )
851
+ check_symbol_exists (getpwuid_r "${CURL_INCLUDES} " HAVE_GETPWUID_R )
848
852
check_symbol_exists (geteuid "${CURL_INCLUDES} " HAVE_GETEUID )
849
853
check_symbol_exists (utime "${CURL_INCLUDES} " HAVE_UTIME )
850
854
check_symbol_exists (gmtime_r "${CURL_INCLUDES} " HAVE_GMTIME_R )
@@ -857,7 +861,7 @@ check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
857
861
check_symbol_exists (SIGALRM "${CURL_INCLUDES} " HAVE_SIGNAL_MACRO )
858
862
if (HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO )
859
863
set (HAVE_SIGNAL 1 )
860
- endif (HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO )
864
+ endif ()
861
865
check_symbol_exists (uname "${CURL_INCLUDES} " HAVE_UNAME )
862
866
check_symbol_exists (strtoll "${CURL_INCLUDES} " HAVE_STRTOLL )
863
867
check_symbol_exists (_strtoi64 "${CURL_INCLUDES} " HAVE__STRTOI64 )
@@ -897,29 +901,29 @@ endif()
897
901
check_symbol_exists (fsetxattr "${CURL_INCLUDES} " HAVE_FSETXATTR )
898
902
if (HAVE_FSETXATTR )
899
903
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 ()
903
907
904
908
# sigaction and sigsetjmp are special. Use special mechanism for
905
909
# detecting those, but only if previous attempt failed.
906
910
if (HAVE_SIGNAL_H )
907
911
check_symbol_exists (sigaction "signal.h" HAVE_SIGACTION )
908
- endif (HAVE_SIGNAL_H )
912
+ endif ()
909
913
910
914
if (NOT HAVE_SIGSETJMP )
911
915
if (HAVE_SETJMP_H )
912
916
check_symbol_exists (sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP )
913
917
if (HAVE_MACRO_SIGSETJMP )
914
918
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 ()
918
922
919
923
# If there is no stricmp(), do not allow LDAP to parse URLs
920
924
if (NOT HAVE_STRICMP )
921
925
set (HAVE_LDAP_URL_PARSE 1 )
922
- endif (NOT HAVE_STRICMP )
926
+ endif ()
923
927
924
928
# Do curl specific tests
925
929
foreach (CURL_TEST
@@ -957,12 +961,12 @@ foreach(CURL_TEST
957
961
HAVE_FILE_OFFSET_BITS
958
962
)
959
963
curl_internal_test (${CURL_TEST} )
960
- endforeach (CURL_TEST )
964
+ endforeach ()
961
965
962
966
if (HAVE_FILE_OFFSET_BITS )
963
967
set (_FILE_OFFSET_BITS 64 )
964
968
set (CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64" )
965
- endif (HAVE_FILE_OFFSET_BITS )
969
+ endif ()
966
970
check_type_size ("off_t" SIZEOF_OFF_T )
967
971
968
972
# include this header to get the type
@@ -977,8 +981,8 @@ foreach(CURL_TEST
977
981
HAVE_GLIBC_STRERROR_R
978
982
HAVE_POSIX_STRERROR_R
979
983
)
980
- curl_internal_test_run (${CURL_TEST} )
981
- endforeach (CURL_TEST )
984
+ curl_internal_test (${CURL_TEST} )
985
+ endforeach ()
982
986
983
987
# Check for reentrant
984
988
foreach (CURL_TEST
@@ -992,9 +996,9 @@ foreach(CURL_TEST
992
996
if (NOT ${CURL_TEST} )
993
997
if (${CURL_TEST} _REENTRANT )
994
998
set (NEED_REENTRANT 1 )
995
- endif (${CURL_TEST} _REENTRANT )
996
- endif (NOT ${CURL_TEST} )
997
- endforeach (CURL_TEST )
999
+ endif ()
1000
+ endif ()
1001
+ endforeach ()
998
1002
999
1003
if (NEED_REENTRANT )
1000
1004
foreach (CURL_TEST
@@ -1007,32 +1011,32 @@ if(NEED_REENTRANT)
1007
1011
set (${CURL_TEST} 0 )
1008
1012
if (${CURL_TEST} _REENTRANT )
1009
1013
set (${CURL_TEST} 1 )
1010
- endif (${CURL_TEST} _REENTRANT )
1011
- endforeach (CURL_TEST )
1012
- endif (NEED_REENTRANT )
1014
+ endif ()
1015
+ endforeach ()
1016
+ endif ()
1013
1017
1014
1018
if (HAVE_INET_NTOA_R_DECL_REENTRANT )
1015
1019
set (HAVE_INET_NTOA_R_DECL 1 )
1016
1020
set (NEED_REENTRANT 1 )
1017
- endif (HAVE_INET_NTOA_R_DECL_REENTRANT )
1021
+ endif ()
1018
1022
1019
1023
# Some other minor tests
1020
1024
1021
1025
if (NOT HAVE_IN_ADDR_T )
1022
1026
set (in_addr_t "unsigned long" )
1023
- endif (NOT HAVE_IN_ADDR_T )
1027
+ endif ()
1024
1028
1025
1029
# Fix libz / zlib.h
1026
1030
1027
1031
if (NOT CURL_SPECIAL_LIBZ )
1028
1032
if (NOT HAVE_LIBZ )
1029
1033
set (HAVE_ZLIB_H 0 )
1030
- endif (NOT HAVE_LIBZ )
1034
+ endif ()
1031
1035
1032
1036
if (NOT HAVE_ZLIB_H )
1033
1037
set (HAVE_LIBZ 0 )
1034
- endif (NOT HAVE_ZLIB_H )
1035
- endif (NOT CURL_SPECIAL_LIBZ )
1038
+ endif ()
1039
+ endif ()
1036
1040
1037
1041
# Check for nonblocking
1038
1042
set (HAVE_DISABLED_NONBLOCKING 1 )
@@ -1041,16 +1045,13 @@ if(HAVE_FIONBIO OR
1041
1045
HAVE_IOCTLSOCKET_CASE OR
1042
1046
HAVE_O_NONBLOCK )
1043
1047
set (HAVE_DISABLED_NONBLOCKING )
1044
- endif (HAVE_FIONBIO OR
1045
- HAVE_IOCTLSOCKET OR
1046
- HAVE_IOCTLSOCKET_CASE OR
1047
- HAVE_O_NONBLOCK )
1048
+ endif ()
1048
1049
1049
1050
if (RETSIGTYPE_TEST )
1050
1051
set (RETSIGTYPE void )
1051
- else (RETSIGTYPE_TEST )
1052
+ else ()
1052
1053
set (RETSIGTYPE int )
1053
- endif (RETSIGTYPE_TEST )
1054
+ endif ()
1054
1055
1055
1056
if (CMAKE_COMPILER_IS_GNUCC AND APPLE )
1056
1057
include (CheckCCompilerFlag )
@@ -1060,13 +1061,13 @@ if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
1060
1061
get_source_file_property (MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS )
1061
1062
if (MPRINTF_COMPILE_FLAGS )
1062
1063
set (MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double" )
1063
- else (MPRINTF_COMPILE_FLAGS )
1064
+ else ()
1064
1065
set (MPRINTF_COMPILE_FLAGS "-Wno-long-double" )
1065
- endif (MPRINTF_COMPILE_FLAGS )
1066
+ endif ()
1066
1067
set_source_files_properties (mprintf.c PROPERTIES
1067
1068
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 ()
1070
1071
1071
1072
if (HAVE_SOCKLEN_T )
1072
1073
set (CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t" )
@@ -1101,19 +1102,34 @@ include(CMake/OtherTests.cmake)
1101
1102
1102
1103
add_definitions (-DHAVE_CONFIG_H )
1103
1104
1104
- # For windows , all compilers used by cmake should support large files
1105
+ # For Windows , all compilers used by CMake should support large files
1105
1106
if (WIN32 )
1106
1107
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 ()
1108
1112
1109
1113
if (MSVC )
1114
+ # Disable default manifest added by CMake
1115
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO" )
1116
+
1110
1117
add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE )
1111
1118
if (CMAKE_C_FLAGS MATCHES "/W[0-4]" )
1112
1119
string (REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS} " )
1113
- else (CMAKE_C_FLAGS MATCHES "/W[0-4]" )
1120
+ else ()
1114
1121
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 ()
1117
1133
1118
1134
# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
1119
1135
function (TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE )
0 commit comments