]> granicus.if.org Git - libevent/commitdiff
cmake: Fix detection of ssize_t/SSIZE_T
authorAzat Khuzhin <a3at.mail@gmail.com>
Thu, 7 Jan 2016 14:51:40 +0000 (17:51 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Thu, 7 Jan 2016 17:40:22 +0000 (20:40 +0300)
Since ssize_it is POSIX, windows/VS also have this but with BaseTsd.h, plus the
logic prefers "ssize_t" (lower) instead of "SSIZE_T" (upper) when the latest
only available -- fix this too.

Refs: #311

CMakeLists.txt

index 5deaae210b4926ec45e9ad02defd3101ac3d573a..4acb99612f69952dcb3dc2f0253e6a42f3ab2461 100644 (file)
@@ -420,21 +420,19 @@ CHECK_TYPE_SIZE("off_t" EVENT__SIZEOF_OFF_T LANGUAGE C)
 # XXX we should functionalize these size and type sets. --elley
 
 # Winssck.
-set(SSIZE_TMAP_ssize_t "ssize_t")
-set(SSIZE_TMAP_SSIZE_T "SSIZE_T")
-
-CHECK_TYPE_SIZE("ssize_t" EVENT__SIZEOF_SSIZE_T LANGUAGE C)
-CHECK_TYPE_SIZE("SSIZE_T" EVENT__SIZEOF_SSIZE_T LANGUAGE C)
-
-if (DEFINED EVENT__SIZEOF_SSIZE_T)
-       if (DEFINED SSIZE_TMAP_ssize_t)
-               set(EVENT__ssize_t "ssize_t")
-       elseif (DEFINED SSIZE_TMAP_SSIZE_T)
-               set(EVENT__ssize_t "SSIZE_T")
-       else()
-               set(EVENT__ssize_t "int")
-               set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_INT})
-       endif()
+if (_MSC_VER)
+    list(APPEND CMAKE_EXTRA_INCLUDE_FILES BaseTsd.h)
+endif()
+CHECK_TYPE_SIZE("ssize_t" EVENT__SIZEOF_SSIZE_T_LOWER LANGUAGE C)
+CHECK_TYPE_SIZE("SSIZE_T" EVENT__SIZEOF_SSIZE_T_UPPER LANGUAGE C)
+
+if (EVENT__SIZEOF_SSIZE_T_LOWER)
+    set(EVENT__ssize_t "ssize_t")
+elseif (EVENT__SIZEOF_SSIZE_T_UPPER)
+    set(EVENT__ssize_t "SSIZE_T")
+else()
+    set(EVENT__ssize_t "int")
+    set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_INT})
 endif()