FindCURL.cmake 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.
  25. find_library(CURL_LIBRARY NAMES
  26. curl
  27. # Windows MSVC prebuilts:
  28. curllib
  29. libcurl_imp
  30. curllib_static
  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. # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if
  44. # all listed variables are TRUE
  45. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  46. FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL
  47. REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
  48. VERSION_VAR CURL_VERSION_STRING)
  49. if(CURL_FOUND)
  50. set(CURL_LIBRARIES ${CURL_LIBRARY})
  51. set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
  52. endif()