FindCURL.cmake 2.3 KB

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