summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authoryuangongji <yuangongji@foxmail.com>2020-03-16 20:11:06 +0800
committerAzat Khuzhin <azat@libevent.org>2020-03-17 21:43:39 +0300
commit503ba1d36571e3cb01826d15dc462b7d8b5094de (patch)
treebe601e5accb1a2723fa6c9a7f3936051699a3b3b /cmake
parent61c5c19bfdabd2f16407a3ed615060c9d0502e82 (diff)
downloadlibevent-503ba1d36571e3cb01826d15dc462b7d8b5094de.tar.gz
cmake: fix getaddrinfo checking error
Using `CheckFunctionExists` on Windows to check `getaddrinfo` will get `not found`, but it actually exists. Using `CheckSymbolExists` with headers will get correct results. Other functions such as `getnameinfo`,`inet_ntop`,etc. have the same issue.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CheckSymbolsExist.cmake20
1 files changed, 20 insertions, 0 deletions
diff --git a/cmake/CheckSymbolsExist.cmake b/cmake/CheckSymbolsExist.cmake
new file mode 100644
index 00000000..2c3c5dc3
--- /dev/null
+++ b/cmake/CheckSymbolsExist.cmake
@@ -0,0 +1,20 @@
+# Check if each symbol in the symbol list exists,
+# and define PREFIX__HAVE_SYMNAME to 1 if yes.
+#
+
+include(CheckSymbolExists)
+
+# SYMLIST: list of symbols to check
+# HEADERS: header files to be included in check code
+# PREFIX: the prefix of definition
+macro(CHECK_SYMBOLS_EXIST SYMLIST HEADERS PREFIX)
+ foreach(SYMNAME ${SYMLIST})
+ string(TOUPPER "${SYMNAME}" SYMNAME_UPPER)
+ if("${PREFIX}" STREQUAL "")
+ set(HAVE_SYM_DEF "HAVE_${SYMNAME_UPPER}")
+ else()
+ set(HAVE_SYM_DEF "${PREFIX}__HAVE_${SYMNAME_UPPER}")
+ endif()
+ CHECK_SYMBOL_EXISTS(${SYMNAME} "${HEADERS}" ${HAVE_SYM_DEF})
+ endforeach()
+endmacro()