ENH: add optional support for c-ares

This commit is contained in:
Bill Hoffman 2009-07-14 19:03:31 +00:00
parent 6dade671ad
commit a8ea1e9ef4
5 changed files with 63 additions and 4 deletions

42
CMake/FindCARES.cmake Executable file
View File

@ -0,0 +1,42 @@
# - Find c-ares
# Find the c-ares includes and library
# This module defines
# CARES_INCLUDE_DIR, where to find ares.h, etc.
# CARES_LIBRARIES, the libraries needed to use c-ares.
# CARES_FOUND, If false, do not try to use c-ares.
# also defined, but not for general use are
# CARES_LIBRARY, where to find the c-ares library.
FIND_PATH(CARES_INCLUDE_DIR ares.h
/usr/local/include
/usr/include
)
SET(CARES_NAMES ${CARES_NAMES} cares)
FIND_LIBRARY(CARES_LIBRARY
NAMES ${CARES_NAMES}
PATHS /usr/lib /usr/local/lib
)
IF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
SET(CARES_LIBRARIES ${CARES_LIBRARY})
SET(CARES_FOUND "YES")
ELSE (CARES_LIBRARY AND CARES_INCLUDE_DIR)
SET(CARES_FOUND "NO")
ENDIF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
IF (CARES_FOUND)
IF (NOT CARES_FIND_QUIETLY)
MESSAGE(STATUS "Found c-ares: ${CARES_LIBRARIES}")
ENDIF (NOT CARES_FIND_QUIETLY)
ELSE (CARES_FOUND)
IF (CARES_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find c-ares library")
ENDIF (CARES_FIND_REQUIRED)
ENDIF (CARES_FOUND)
MARK_AS_ADVANCED(
CARES_LIBRARY
CARES_INCLUDE_DIR
)

View File

@ -68,6 +68,17 @@ endif()
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)
# initialize CURL_LIBS
set(CURL_LIBS "")
if(CURL_USE_ARES)
set(USE_ARES ${CURL_USE_ARES})
find_package(CARES REQUIRED)
list(APPEND CURL_LIBS ${CARES_LIBRARY} )
message("CURL_LIBS = ${CURL_LIBS}")
set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
endif()
option(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of cURL builds here http://www.cdash.org/CDashPublic/index.php?project=CURL" OFF)
if(BUILD_DASHBOARD_REPORTS)
@ -188,7 +199,6 @@ endif(WIN32)
# This macro checks if the symbol exists in the library and if it
# does, it appends library to the list.
set(CURL_LIBS "")
macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} ""
${VARIABLE})

View File

@ -5,7 +5,6 @@ configure_file(${CURL_SOURCE_DIR}/include/curl/curlbuild.h.cmake
configure_file(curl_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
@ -77,6 +76,9 @@ 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)
include_directories(${CARES_INCLUDE_DIR})
endif()
if(CURL_STATICLIB)
# Static lib

View File

@ -9,7 +9,9 @@ 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)
include_directories(${CARES_INCLUDE_DIR})
endif()
setup_curl_dependencies(${TEST_NAME})
target_link_libraries( ${TEST_NAME} libcurl )

View File

@ -9,7 +9,10 @@ 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)
include_directories(${CARES_INCLUDE_DIR})
endif()
# resolve test needs this
setup_curl_dependencies(${TEST_NAME})
#TARGET_LINK_LIBRARIES( ${TEST_NAME} libcurl )