FindCURL.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # FindCURL
  5. # --------
  6. #
  7. # Find curl
  8. #
  9. # Find the native CURL headers and libraries.
  10. #
  11. # ::
  12. #
  13. # CURL_INCLUDE_DIRS - where to find curl/curl.h, etc.
  14. # CURL_LIBRARIES - List of libraries when using curl.
  15. # CURL_FOUND - True if curl found.
  16. # CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8)
  17. # Look for the header file.
  18. find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
  19. mark_as_advanced(CURL_INCLUDE_DIR)
  20. # Look for the library (sorted from most current/relevant entry to least).
  21. find_library(CURL_LIBRARY NAMES
  22. curl
  23. # Windows MSVC prebuilts:
  24. curllib
  25. libcurl_imp
  26. curllib_static
  27. # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
  28. libcurl
  29. )
  30. mark_as_advanced(CURL_LIBRARY)
  31. if(CURL_INCLUDE_DIR)
  32. foreach(_curl_version_header curlver.h curl.h)
  33. if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
  34. file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
  35. string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
  36. unset(curl_version_str)
  37. break()
  38. endif()
  39. endforeach()
  40. endif()
  41. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  42. FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL
  43. REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
  44. VERSION_VAR CURL_VERSION_STRING)
  45. if(CURL_FOUND)
  46. set(CURL_LIBRARIES ${CURL_LIBRARY})
  47. set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
  48. endif()