FindCURL.cmake 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # - Find curl
  2. # Find the native CURL headers and libraries.
  3. #
  4. # CURL_INCLUDE_DIRS - where to find curl/curl.h, etc.
  5. # CURL_LIBRARIES - List of libraries when using curl.
  6. # CURL_FOUND - True if curl found.
  7. # CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8)
  8. #=============================================================================
  9. # Copyright 2006-2009 Kitware, Inc.
  10. # Copyright 2012 Rolf Eike Beer <[email protected]>
  11. #
  12. # Distributed under the OSI-approved BSD License (the "License");
  13. # see accompanying file Copyright.txt for details.
  14. #
  15. # This software is distributed WITHOUT ANY WARRANTY; without even the
  16. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. # See the License for more information.
  18. #=============================================================================
  19. # (To distribute this file outside of CMake, substitute the full
  20. # License text for the above reference.)
  21. # Look for the header file.
  22. find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
  23. mark_as_advanced(CURL_INCLUDE_DIR)
  24. # Look for the library (sorted from most current/relevant entry to least).
  25. find_library(CURL_LIBRARY NAMES
  26. curl
  27. # Windows MSVC prebuilts:
  28. curllib
  29. libcurl_imp
  30. curllib_static
  31. # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
  32. libcurl
  33. )
  34. mark_as_advanced(CURL_LIBRARY)
  35. if(CURL_INCLUDE_DIR)
  36. foreach(_curl_version_header curlver.h curl.h)
  37. if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
  38. file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
  39. string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
  40. unset(curl_version_str)
  41. break()
  42. endif()
  43. endforeach()
  44. endif()
  45. # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if
  46. # all listed variables are TRUE
  47. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  48. FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL
  49. REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
  50. VERSION_VAR CURL_VERSION_STRING)
  51. if(CURL_FOUND)
  52. set(CURL_LIBRARIES ${CURL_LIBRARY})
  53. set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
  54. endif()