curl-config.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
  2. if(NOT CURL_FIND_COMPONENTS)
  3. set(CURL_FIND_COMPONENTS curl libcurl)
  4. if(CURL_FIND_REQUIRED)
  5. set(CURL_FIND_REQUIRED_curl TRUE)
  6. set(CURL_FIND_REQUIRED_libcurl TRUE)
  7. endif()
  8. endif()
  9. set(_curl_missing_components)
  10. foreach(_comp ${CURL_FIND_COMPONENTS})
  11. if(EXISTS "${_DIR}/${_comp}-target.cmake")
  12. include("${_DIR}/${_comp}-target.cmake")
  13. set(CURL_${_comp}_FOUND TRUE)
  14. else()
  15. set(CURL_${_comp}_FOUND FALSE)
  16. if(CURL_FIND_REQUIRED_${_comp})
  17. set(CURL_FOUND FALSE)
  18. list(APPEND _curl_missing_components ${_comp})
  19. endif()
  20. endif()
  21. endforeach()
  22. if(_curl_missing_components)
  23. set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components})
  24. else()
  25. if(TARGET CURL::libcurl)
  26. string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config)
  27. if(NOT _curl_current_config)
  28. set(_curl_current_config "NOCONFIG")
  29. endif()
  30. get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS)
  31. list(FIND _curl_configurations "${_curl_current_config}" _i)
  32. if(_i LESS 0)
  33. set(_curl_config "RELEASE")
  34. list(FIND _curl_configurations "${_curl_current_config}" _i)
  35. if(_i LESS 0)
  36. set(_curl_config "NOCONFIG")
  37. list(FIND _curl_configurations "${_curl_current_config}" _i)
  38. endif()
  39. endif()
  40. if(_i LESS 0)
  41. set(_curl_current_config "") # let CMake pick config at random
  42. else()
  43. set(_curl_current_config "_${_curl_current_config}")
  44. endif()
  45. get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES)
  46. get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}")
  47. set(_curl_current_config)
  48. set(_curl_configurations)
  49. set(_i)
  50. endif()
  51. endif()
  52. unset(_curl_missing_components)