summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-11-06 01:32:45 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-11-10 09:09:25 +0100
commit17d27805f9e68fb3fa62e1ed817d2b9f44885ee2 (patch)
tree335e511d63d30239039297e1a805ed483113203e
parent767aaf587ce93720951d3c081acb4d61d5280755 (diff)
downloadgnurl-17d27805f9e68fb3fa62e1ed817d2b9f44885ee2.tar.gz
gnurl-17d27805f9e68fb3fa62e1ed817d2b9f44885ee2.tar.bz2
gnurl-17d27805f9e68fb3fa62e1ed817d2b9f44885ee2.zip
cmake: add ENABLE_THREADED_RESOLVER, rename ARES
Fix detection of the AsynchDNS feature which not just depends on pthreads support, but also on whether USE_POSIX_THREADS is set or not. Caught by test 1014. This patch adds a new ENABLE_THREADED_RESOLVER option (corresponding to --enable-threaded-resolver of autotools) which also needs a check for HAVE_PTHREAD_H. For symmetry with autotools, CURL_USE_ARES is renamed to ENABLE_ARES (--enable-ares). Checks that test for the availability actually use USE_ARES instead as that is the result of whether a-res is available or not (in practice this does not matter as CARES is marked as required package, but nevertheless it is better to write the intent). Signed-off-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--CMakeLists.txt27
-rw-r--r--lib/CMakeLists.txt2
-rw-r--r--lib/curl_config.h.cmake6
-rw-r--r--tests/libtest/CMakeLists.txt2
-rw-r--r--tests/server/CMakeLists.txt2
5 files changed, 30 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a325d1c1c..57575f4a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,12 +74,17 @@ include_directories( ${CURL_SOURCE_DIR}/include )
option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON)
option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON)
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
-option(CURL_USE_ARES "Set to ON to enable c-ares support" OFF)
+option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
+option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF)
# initialize CURL_LIBS
set(CURL_LIBS "")
-if(CURL_USE_ARES)
- set(USE_ARES ${CURL_USE_ARES})
+if(ENABLE_THREADED_RESOLVER AND ENABLE_ARES)
+ message(FATAL_ERROR "Options ENABLE_THREADED_RESOLVER and ENABLE_ARES are mutually exclusive")
+endif()
+
+if(ENABLE_ARES)
+ set(USE_ARES 1)
find_package(CARES REQUIRED)
list(APPEND CURL_LIBS ${CARES_LIBRARY} )
set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
@@ -236,6 +241,18 @@ if(WIN32)
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake)
endif(WIN32)
+if(ENABLE_THREADED_RESOLVER)
+ check_include_file_concat("pthread.h" HAVE_PTHREAD_H)
+ if(HAVE_PTHREAD_H)
+ set(CMAKE_THREAD_PREFER_PTHREAD 1)
+ find_package(Threads)
+ if(CMAKE_USE_PTHREADS_INIT)
+ set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
+ set(USE_THREADS_POSIX 1)
+ endif()
+ endif()
+endif()
+
# Check for all needed libraries
check_library_exists_concat("dl" dlopen HAVE_LIBDL)
check_library_exists_concat("socket" connect HAVE_LIBSOCKET)
@@ -1003,9 +1020,7 @@ _add_if("SSL" SSL_ENABLED)
_add_if("IPv6" ENABLE_IPV6)
_add_if("unix-sockets" USE_UNIX_SOCKETS)
_add_if("libz" HAVE_LIBZ)
-find_package(Threads)
-# AsynchDNS depends or USE_ARES or pthreads (mutually exclusive)
-_add_if("AsynchDNS" USE_ARES OR CMAKE_USE_PTHREADS_INIT)
+_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX)
_add_if("IDN" HAVE_LIBIDN)
# TODO SSP1 (WinSSL) check is missing
_add_if("SSPI" USE_WINDOWS_SSPI)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 78fde4d8f..e7886ac55 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -57,7 +57,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-if(CURL_USE_ARES)
+if(USE_ARES)
include_directories(${CARES_INCLUDE_DIR})
endif()
diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake
index 32bae39bf..44014f5dd 100644
--- a/lib/curl_config.h.cmake
+++ b/lib/curl_config.h.cmake
@@ -467,6 +467,9 @@
/* Define to 1 if you have a working POSIX-style strerror_r function. */
#cmakedefine HAVE_POSIX_STRERROR_R 1
+/* Define to 1 if you have the <pthread.h> header file */
+#cmakedefine HAVE_PTHREAD_H 1
+
/* Define to 1 if you have the <pwd.h> header file. */
#cmakedefine HAVE_PWD_H 1
@@ -879,6 +882,9 @@
/* Define if you want to enable c-ares support */
#cmakedefine USE_ARES 1
+/* Define if you want to enable POSIX threaded DNS lookup */
+#cmakedefine USE_THREADS_POSIX 1
+
/* Define to disable non-blocking sockets. */
#cmakedefine USE_BLOCKING_SOCKETS 1
diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt
index ef73e553e..cc9d7e1f8 100644
--- a/tests/libtest/CMakeLists.txt
+++ b/tests/libtest/CMakeLists.txt
@@ -9,7 +9,7 @@ function(SETUP_TEST TEST_NAME) # ARGN are the files in the test
${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h"
)
- if(CURL_USE_ARES)
+ if(USE_ARES)
include_directories(${CARES_INCLUDE_DIR})
endif()
diff --git a/tests/server/CMakeLists.txt b/tests/server/CMakeLists.txt
index 031d81711..00f5242f9 100644
--- a/tests/server/CMakeLists.txt
+++ b/tests/server/CMakeLists.txt
@@ -9,7 +9,7 @@ function(SETUP_EXECUTABLE TEST_NAME) # ARGN are the files in the test
${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h"
)
- if(CURL_USE_ARES)
+ if(USE_ARES)
include_directories(${CARES_INCLUDE_DIR})
endif()