FindCURL.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Makefile:
  24. libcurl_a
  25. # Windows MSVC prebuilts:
  26. curllib
  27. libcurl_imp
  28. curllib_static
  29. # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
  30. libcurl
  31. )
  32. mark_as_advanced(CURL_LIBRARY)
  33. if(CURL_INCLUDE_DIR)
  34. foreach(_curl_version_header curlver.h curl.h)
  35. if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
  36. file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
  37. string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
  38. unset(curl_version_str)
  39. break()
  40. endif()
  41. endforeach()
  42. endif()
  43. find_package_handle_standard_args(CURL
  44. REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
  45. VERSION_VAR CURL_VERSION_STRING)
  46. if(CURL_FOUND)
  47. set(CURL_LIBRARIES ${CURL_LIBRARY})
  48. set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
  49. message(STATUS " Curl libraries: = ${CURL_LIBRARIES}")
  50. message(STATUS " Curl include dirs: = ${CURL_INCLUDE_DIRS}")
  51. endif()