From: Azat Khuzhin Date: Thu, 7 Jan 2016 14:51:40 +0000 (+0300) Subject: cmake: Fix detection of ssize_t/SSIZE_T X-Git-Tag: release-2.1.6-beta~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7707f6b03a12430f811a45b352efca57190e69c9;p=libevent cmake: Fix detection of ssize_t/SSIZE_T 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5deaae21..4acb9961 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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()