On 8/25/2014 4:03 PM, Ray Satiro wrote:
The conditionals from config-win32 could be rewritten in cmake language but then either time one was updated the other probably would need to be too. Another idea is some of the defines that are always the same not compiler specific or otherwise conditional for windows could go in a separate file that could be included by both cmake's curl_config.h and config-win32.h, but that kind of defeats the point of cmake I guess. For example you could test recvfrom in cmake but you're fairly certain it's going to be available so in config-win32 it is always on and that could go in a file shared by both. Or just always include config-win32 for (WIN32) although again this idea is defeating the point of cmake. I'll try adding a USE_WIN32_LARGE_FILES conditional to CMakeLists.txt tonight.

I made some changes to CMakeLists.txt to get curl_config.h output closer to what's in config-win32.h. There are a few things I couldn't resolve if anyone can pick up from here:

There is some inconsistency with the _TYPE_ARG macros, it looks like most expect the asterisk in the define but RECVFROM_TYPE_ARG macros you are expected to not have the asterisk when necessary because it's already in the prototype. For example look at curl_setup_once.h:229:
(RECVFROM_TYPE_ARG2 *)(b)
I accounted for that but it's confusing.

I did an override for all the _ARG macros with their actual type information. There is detection code in CMake/OtherTests.cmake but I noticed for me at least it was detecting argument types that were not the same as what is on msdn and in config-win32. Like size_t instead of int. Or int instead of SOCKET (which is a pointer in VS2010). I didn't have time to diagnose the detection code so I just put in overrides for all the ARG types so that they are correct and put a TODO in a comment.

I didn't add HAVE_GETADDRINFO_THREADSAFE. Is it always thread safe? I read this post which had me concerned.
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/2adc8097-05e6-458e-aad2-4e905fa86d01

I didn't add the machine string (define OS) for the version information. It just says "Windows". See the bottom of config-win32.h for how it can be implemented.

I have setvbuf (VS2010) but for some reason I couldn't figure out it's not detected so HAVE_SETVBUF is off.

Despite getting OpenSSL working (I had to make some directory junctions to get cmake's openssl detection module detecting it) these macros weren't defined: HAVE_RAND_SCREEN, HAVE_RAND_STATUS, HAVE_CRYPTO_CLEANUP_ALL_EX_DATA. I have all of those functions and cmake is getting the headers and libraries properly and does testing for them and openssl is on so I don't know why that is. Going to https websites works anyway but I'm not sure of any security issues here.

I built with OpenSSL 1.0.1 and IPv6 options on master branch commit ee40b68 20140808. I don't have IPv6 setup on this computer so I didn't test that.
curl 7.38.0-DEV (Windows) libcurl/7.38.0-DEV OpenSSL/1.0.1i
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM SSL

I didn't test LDAP or libssh or any cmake options other than IPv6 and OpenSSL.

If anyone wants to pursue cmake support for windows the above stuff would be a good place to start.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 845c330..9f2e787 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -471,6 +471,7 @@ check_include_file_concat("netinet/tcp.h"    
HAVE_NETINET_TCP_H)
 
 check_include_file_concat("pem.h"            HAVE_PEM_H)
 check_include_file_concat("poll.h"           HAVE_POLL_H)
+check_include_file_concat("process.h"        HAVE_PROCESS_H)
 check_include_file_concat("pwd.h"            HAVE_PWD_H)
 check_include_file_concat("rsa.h"            HAVE_RSA_H)
 check_include_file_concat("setjmp.h"         HAVE_SETJMP_H)
@@ -589,12 +590,15 @@ check_symbol_exists(strcasecmp    "${CURL_INCLUDES}" 
HAVE_STRCASECMP)
 check_symbol_exists(stricmp       "${CURL_INCLUDES}" HAVE_STRICMP)
 check_symbol_exists(strcmpi       "${CURL_INCLUDES}" HAVE_STRCMPI)
 check_symbol_exists(strncmpi      "${CURL_INCLUDES}" HAVE_STRNCMPI)
+check_symbol_exists(strnicmp      "${CURL_INCLUDES}" HAVE_STRNICMP)
 check_symbol_exists(alarm         "${CURL_INCLUDES}" HAVE_ALARM)
 if(NOT HAVE_STRNCMPI)
   set(HAVE_STRCMPI)
 endif(NOT HAVE_STRNCMPI)
 check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
 check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
+check_symbol_exists(gethostname   "${CURL_INCLUDES}" HAVE_GETHOSTNAME)
+check_symbol_exists(getservbyname "${CURL_INCLUDES}" HAVE_GETSERVBYNAME)
 check_symbol_exists(gettimeofday  "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
 check_symbol_exists(inet_addr     "${CURL_INCLUDES}" HAVE_INET_ADDR)
 check_symbol_exists(inet_ntoa     "${CURL_INCLUDES}" HAVE_INET_NTOA)
@@ -603,6 +607,7 @@ check_symbol_exists(tcsetattr     "${CURL_INCLUDES}" 
HAVE_TCSETATTR)
 check_symbol_exists(tcgetattr     "${CURL_INCLUDES}" HAVE_TCGETATTR)
 check_symbol_exists(perror        "${CURL_INCLUDES}" HAVE_PERROR)
 check_symbol_exists(closesocket   "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
+check_symbol_exists(setmode       "${CURL_INCLUDES}" HAVE_SETMODE)
 check_symbol_exists(setvbuf       "${CURL_INCLUDES}" HAVE_SETVBUF)
 check_symbol_exists(sigsetjmp     "${CURL_INCLUDES}" HAVE_SIGSETJMP)
 check_symbol_exists(getpass_r     "${CURL_INCLUDES}" HAVE_GETPASS_R)
@@ -653,6 +658,9 @@ check_symbol_exists(setrlimit      "${CURL_INCLUDES}" 
HAVE_SETRLIMIT)
 check_symbol_exists(fcntl          "${CURL_INCLUDES}" HAVE_FCNTL)
 check_symbol_exists(ioctl          "${CURL_INCLUDES}" HAVE_IOCTL)
 check_symbol_exists(setsockopt     "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
+check_symbol_exists(recvfrom       "${CURL_INCLUDES}" HAVE_RECVFROM)
+check_symbol_exists(getaddrinfo    "${CURL_INCLUDES}" HAVE_GETADDRINFO)
+check_symbol_exists(getnameinfo    "${CURL_INCLUDES}" HAVE_GETNAMEINFO)
 
 # symbol exists in win32, but function does not.
 check_function_exists(inet_pton HAVE_INET_PTON)
@@ -858,15 +866,68 @@ set(CURL_PULL_INTTYPES_H ${HAVE_INTTYPES_H})
 
 include(CMake/OtherTests.cmake)
 
+# Override the prototype extractions in OtherTests for some Windows functions
+# TODO: Fix OtherTests so this override isn't necessary.
+if(WIN32)
+  if(HAVE_WS2TCPIP_H)
+    set (GETNAMEINFO_QUAL_ARG1 "const")
+    set (GETNAMEINFO_TYPE_ARG1 "struct sockaddr *")
+    set (GETNAMEINFO_TYPE_ARG2 "socklen_t")
+    set (GETNAMEINFO_TYPE_ARG46 "DWORD")
+    set (GETNAMEINFO_TYPE_ARG7 "int")
+  endif()
+
+  set (RECV_TYPE_ARG1 "SOCKET")
+  set (RECV_TYPE_ARG2 "char *")
+  set (RECV_TYPE_ARG3 "int")
+  set (RECV_TYPE_ARG4 "int")
+  set (RECV_TYPE_RETV "int")
+
+  #For RECVFROM_TYPE_ARG macros the asterisk in 2,5,6 does not go in the macro
+  set (RECVFROM_TYPE_ARG1 "SOCKET")
+  set (RECVFROM_TYPE_ARG2 "char")
+  set (RECVFROM_TYPE_ARG3 "int")
+  set (RECVFROM_TYPE_ARG4 "int")
+  set (RECVFROM_TYPE_ARG5 "struct sockaddr")
+  set (RECVFROM_TYPE_ARG6 "int")
+  set (RECVFROM_TYPE_RETV "int")
+
+  set (SEND_TYPE_ARG1 "SOCKET")
+  set (SEND_QUAL_ARG2 "const")
+  set (SEND_TYPE_ARG2 "char *")
+  set (SEND_TYPE_ARG3 "int")
+  set (SEND_TYPE_ARG4 "int")
+  set (SEND_TYPE_RETV "int")
+endif(WIN32)
+
 add_definitions(-DHAVE_CONFIG_H)
 
-# For windows, do not allow the compiler to use default target (Vista).
 if(WIN32)
+  # For windows, do not allow the compiler to use default target (Vista).
   add_definitions(-D_WIN32_WINNT=0x0501)
+
+  set (HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1)
+  set (HAVE_STRUCT_SOCKADDR_STORAGE 1)
+  set (USE_MANUAL 1)
+
+  if(NOT CURL_USE_ARES)
+    #This is to use asynchronous DNS without ares.
+    #If synchronous DNS is needed USE_THREADS_WIN32 shouldn't be defined.
+    set (USE_THREADS_WIN32 1)
+  endif()
+
+  if(NOT (MSVC_VERSION LESS 900))
+    set (USE_WIN32_LARGE_FILES 1)
+  else()
+    set (USE_WIN32_SMALL_FILES 1)
+  endif()
 endif(WIN32)
 
 if(MSVC)
   add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
+  if((MSVC_VERSION GREATER 1400) OR (MSVC_VERSION EQUAL 1400))
+    set (HAVE_VARIADIC_MACROS_C99 1)
+  endif()
 endif(MSVC)
 
 # Sets up the dependencies (zlib, OpenSSL, etc.) of a cURL subproject 
according to options.
diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake
index 32bae39..5ff772c 100644
--- a/lib/curl_config.h.cmake
+++ b/lib/curl_config.h.cmake
@@ -220,6 +220,9 @@
 /* Define to 1 if you have the `getrlimit' function. */
 #cmakedefine HAVE_GETRLIMIT 1
 
+/* Define to 1 if you have the getservbyname function. */
+#cmakedefine HAVE_GETSERVBYNAME 1
+
 /* Define to 1 if you have the getservbyport_r function. */
 #cmakedefine HAVE_GETSERVBYPORT_R 1
 
@@ -512,6 +515,9 @@
 /* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
 #cmakedefine HAVE_SETSOCKOPT_SO_NONBLOCK 1
 
+/* Define to 1 if you have the setvbuf function. */
+#cmakedefine HAVE_SETVBUF 1
+
 /* Define to 1 if you have the <sgtty.h> header file. */
 #cmakedefine HAVE_SGTTY_H 1
 
@@ -575,6 +581,9 @@
 /* Define to 1 if you have the strerror_r function. */
 #cmakedefine HAVE_STRERROR_R 1
 
+/* Define to 1 if you have the strftime function. */
+#cmakedefine HAVE_STRFTIME 1
+
 /* Define to 1 if you have the stricmp function. */
 #cmakedefine HAVE_STRICMP 1
 
@@ -906,6 +915,9 @@
 /* if SSL is enabled */
 #cmakedefine USE_SSLEAY 1
 
+/* if use windows threads */
+#cmakedefine USE_THREADS_WIN32 1
+
 /* Define to 1 if you are building a Windows target without large file
    support. */
 #cmakedefine USE_WIN32_LARGE_FILES 1
@@ -953,3 +965,11 @@
 
 /* the signed version of size_t */
 #cmakedefine ssize_t ${ssize_t}
+
+#if defined(HAVE_WINSOCK2_H) && defined(_WIN32_WINNT) && (_WIN32_WINNT >= 
0x0600)
+#define HAVE_STRUCT_POLLFD 1
+#endif
+
+#if defined(USE_ARES) && defined(USE_THREADS_WIN32)
+#  error "Only one DNS lookup specialty may be defined at most"
+#endif
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to