FindCURL.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Find CURL
  2. #
  3. # Find the curl includes and library
  4. #
  5. # if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
  6. #
  7. # This module defines
  8. # CURL_INCLUDE_DIRS, where to find header, etc.
  9. # CURL_LIBRARIES, the libraries needed to use curl.
  10. # CURL_FOUND, If false, do not try to use curl.
  11. # only look in default directories
  12. find_path(
  13. CURL_INCLUDE_DIR
  14. NAMES curl/curl.h
  15. DOC "curl include dir"
  16. )
  17. find_library(
  18. CURL_LIBRARY
  19. # names from cmake's FindCURL
  20. NAMES curl curllib libcurl_imp curllib_static libcurl
  21. DOC "curl library"
  22. )
  23. set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
  24. set(CURL_LIBRARIES ${CURL_LIBRARY})
  25. # debug library on windows
  26. # same naming convention as in qt (appending debug library with d)
  27. # boost is using the same "hack" as us with "optimized" and "debug"
  28. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  29. find_library(
  30. CURL_LIBRARY_DEBUG
  31. NAMES curld libcurld
  32. DOC "curl debug library"
  33. )
  34. set(CURL_LIBRARIES optimized ${CURL_LIBRARIES} debug ${CURL_LIBRARY_DEBUG})
  35. # prepare dlls
  36. string(REPLACE ".lib" ".dll" CURL_DLL "${CURL_LIBRARY}")
  37. string(REPLACE "/lib/" "/bin/" CURL_DLL "${CURL_DLL}")
  38. string(REPLACE ".lib" ".dll" CURL_DLL_DEBUG "${CURL_LIBRARY_DEBUG}")
  39. string(REPLACE "/lib/" "/bin/" CURL_DLL_DEBUG "${CURL_DLL_DEBUG}")
  40. set(CURL_DLLS optimized "${CURL_DLL}" debug "${CURL_DLL_DEBUG}")
  41. endif()
  42. # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE
  43. # if all listed variables are TRUE, hide their existence from configuration view
  44. include(FindPackageHandleStandardArgs)
  45. find_package_handle_standard_args(CURL DEFAULT_MSG
  46. CURL_LIBRARY CURL_INCLUDE_DIR)
  47. mark_as_advanced (CURL_INCLUDE_DIR CURL_LIBRARY)