Commit 2d8ef847 authored by Simon Giesecke's avatar Simon Giesecke

Problem: CMAKE_REQUIRED_INCLUDES used in a wrong way, check_function_exists is problematic

Solution: use check_cxx_symbol_exists resp. check_type_size instead
parent 3e5843d0
...@@ -15,10 +15,9 @@ include(CheckCSourceCompiles) ...@@ -15,10 +15,9 @@ include(CheckCSourceCompiles)
include(CheckCSourceRuns) include(CheckCSourceRuns)
include(CMakeDependentOption) include(CMakeDependentOption)
include(CheckCXXSymbolExists) include(CheckCXXSymbolExists)
include(CheckSymbolExists) include(CheckTypeSize)
include(FindThreads) include(FindThreads)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckTypeSize) include(CheckTypeSize)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
...@@ -154,21 +153,17 @@ set(POLLER "" CACHE STRING "Choose polling system for I/O threads. valid values ...@@ -154,21 +153,17 @@ set(POLLER "" CACHE STRING "Choose polling system for I/O threads. valid values
if(NOT MSVC) if(NOT MSVC)
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
set(CMAKE_REQUIRED_INCLUDES sys/event.h) check_cxx_symbol_exists(kqueue sys/event.h HAVE_KQUEUE)
check_function_exists(kqueue HAVE_KQUEUE)
set(CMAKE_REQUIRED_INCLUDES)
if(HAVE_KQUEUE) if(HAVE_KQUEUE)
set(POLLER "kqueue") set(POLLER "kqueue")
endif() endif()
endif() endif()
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
set(CMAKE_REQUIRED_INCLUDES sys/epoll.h) check_cxx_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL)
check_function_exists(epoll_create HAVE_EPOLL)
set(CMAKE_REQUIRED_INCLUDES)
if(HAVE_EPOLL) if(HAVE_EPOLL)
set(POLLER "epoll") set(POLLER "epoll")
check_function_exists(epoll_create1 HAVE_EPOLL_CLOEXEC) check_cxx_symbol_exists(epoll_create1 sys/epoll.h HAVE_EPOLL_CLOEXEC)
if(HAVE_EPOLL_CLOEXEC) if(HAVE_EPOLL_CLOEXEC)
set(ZMQ_IOTHREAD_POLLER_USE_EPOLL_CLOEXEC 1) set(ZMQ_IOTHREAD_POLLER_USE_EPOLL_CLOEXEC 1)
endif() endif()
...@@ -176,27 +171,23 @@ if(NOT MSVC) ...@@ -176,27 +171,23 @@ if(NOT MSVC)
endif() endif()
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
set(CMAKE_REQUIRED_INCLUDES sys/devpoll.h) set(CMAKE_EXTRA_INCLUDE_FILES sys/devpoll.h)
check_type_size("struct pollfd" DEVPOLL) check_type_size("struct pollfd" DEVPOLL)
set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_EXTRA_INCLUDE_FILES)
if(HAVE_DEVPOLL) if(HAVE_DEVPOLL)
set(POLLER "devpoll") set(POLLER "devpoll")
endif() endif()
endif() endif()
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
set(CMAKE_REQUIRED_INCLUDES sys/pollset.h) check_cxx_symbol_exists(pollset_create sys/pollset.h HAVE_POLLSET)
check_function_exists(pollset_create HAVE_POLLSET)
set(CMAKE_REQUIRED_INCLUDES)
if(HAVE_POLLSET) if(HAVE_POLLSET)
set(POLLER "pollset") set(POLLER "pollset")
endif() endif()
endif() endif()
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
set(CMAKE_REQUIRED_INCLUDES poll.h) check_cxx_symbol_exists(poll poll.h HAVE_POLL)
check_function_exists(poll HAVE_POLL)
set(CMAKE_REQUIRED_INCLUDES)
if(HAVE_POLL) if(HAVE_POLL)
set(POLLER "poll") set(POLLER "poll")
endif() endif()
...@@ -205,12 +196,9 @@ endif() ...@@ -205,12 +196,9 @@ endif()
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
if(WIN32) if(WIN32)
set(CMAKE_REQUIRED_INCLUDES winsock2.h)
set(HAVE_SELECT 1) set(HAVE_SELECT 1)
else() else()
set(CMAKE_REQUIRED_INCLUDES sys/select.h) check_cxx_symbol_exists(select sys/select.h HAVE_SELECT)
check_function_exists(select HAVE_SELECT)
set(CMAKE_REQUIRED_INCLUDES)
endif() endif()
if(HAVE_SELECT) if(HAVE_SELECT)
set(POLLER "select") set(POLLER "select")
...@@ -358,13 +346,13 @@ endif() ...@@ -358,13 +346,13 @@ endif()
if(ZMQ_HAVE_WINDOWS) if(ZMQ_HAVE_WINDOWS)
# Cannot use check_library_exists because the symbol is always declared as char(*)(void) # Cannot use check_library_exists because the symbol is always declared as char(*)(void)
set(CMAKE_REQUIRED_LIBRARIES "ws2_32.lib") set(CMAKE_REQUIRED_LIBRARIES "ws2_32.lib")
check_symbol_exists(WSAStartup "winsock2.h" HAVE_WS2_32) check_cxx_symbol_exists(WSAStartup "winsock2.h" HAVE_WS2_32)
set(CMAKE_REQUIRED_LIBRARIES "rpcrt4.lib") set(CMAKE_REQUIRED_LIBRARIES "rpcrt4.lib")
check_symbol_exists(UuidCreateSequential "rpc.h" HAVE_RPCRT4) check_cxx_symbol_exists(UuidCreateSequential "rpc.h" HAVE_RPCRT4)
set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib") set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib")
check_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI) check_cxx_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI)
set(CMAKE_REQUIRED_LIBRARIES "") set(CMAKE_REQUIRED_LIBRARIES "")
# TODO: This not the symbol we're looking for. What is the symbol? # TODO: This not the symbol we're looking for. What is the symbol?
...@@ -397,28 +385,14 @@ endif() ...@@ -397,28 +385,14 @@ endif()
if(NOT MSVC) if(NOT MSVC)
set(CMAKE_REQUIRED_LIBRARIES rt) set(CMAKE_REQUIRED_LIBRARIES rt)
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) check_cxx_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES unistd.h) check_cxx_symbol_exists(fork unistd.h HAVE_FORK)
check_function_exists(fork HAVE_FORK) check_cxx_symbol_exists(gethrtimei sys/time.h HAVE_GETHRTIME)
set(CMAKE_REQUIRED_INCLUDES) check_cxx_symbol_exists(mkdtemp stdlib.h HAVE_MKDTEMP)
check_cxx_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
set(CMAKE_REQUIRED_INCLUDES sys/time.h) check_cxx_symbol_exists(strnlen string.h HAVE_STRNLEN)
check_function_exists(gethrtime HAVE_GETHRTIME)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_INCLUDES stdlib.h)
check_function_exists(mkdtemp HAVE_MKDTEMP)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_INCLUDES sys/socket.h)
check_function_exists(accept4 HAVE_ACCEPT4)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_INCLUDES string.h)
check_function_exists(strnlen HAVE_STRNLEN)
set(CMAKE_REQUIRED_INCLUDES)
endif() endif()
add_definitions(-D_REENTRANT -D_THREAD_SAFE) add_definitions(-D_REENTRANT -D_THREAD_SAFE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment