Skip to content

Commit

Permalink
ENH: add optional support for c-ares
Browse files Browse the repository at this point in the history
  • Loading branch information
billhoffman committed Jul 14, 2009
1 parent 6dade67 commit a8ea1e9
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
42 changes: 42 additions & 0 deletions CMake/FindCARES.cmake
Original file line number Diff line number Diff line change
@@ -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
)
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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})
Expand Down
4 changes: 3 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/libtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand Down
5 changes: 4 additions & 1 deletion tests/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand Down

0 comments on commit a8ea1e9

Please sign in to comment.