diff options
-rwxr-xr-x | CMake/FindCARES.cmake | 42 | ||||
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/libtest/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/server/CMakeLists.txt | 5 |
5 files changed, 63 insertions, 4 deletions
diff --git a/CMake/FindCARES.cmake b/CMake/FindCARES.cmake new file mode 100755 index 000000000..7e92a8e7c --- /dev/null +++ b/CMake/FindCARES.cmake @@ -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 + ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3663e454f..51349657a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4a5b0888a..372c86995 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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 diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 74d841e01..f0ee8cd2b 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -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 ) diff --git a/tests/server/CMakeLists.txt b/tests/server/CMakeLists.txt index 01db82401..99ec3d897 100644 --- a/tests/server/CMakeLists.txt +++ b/tests/server/CMakeLists.txt @@ -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 ) |