httplibConfig.cmake.in 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # Generates a macro to auto-configure everything
  2. @PACKAGE_INIT@
  3. # Setting these here so they're accessible after install.
  4. # Might be useful for some users to check which settings were used.
  5. set(HTTPLIB_IS_USING_OPENSSL @HTTPLIB_IS_USING_OPENSSL@)
  6. set(HTTPLIB_IS_USING_WOLFSSL @HTTPLIB_IS_USING_WOLFSSL@)
  7. set(HTTPLIB_IS_USING_MBEDTLS @HTTPLIB_IS_USING_MBEDTLS@)
  8. set(HTTPLIB_IS_USING_ZLIB @HTTPLIB_IS_USING_ZLIB@)
  9. set(HTTPLIB_IS_COMPILED @HTTPLIB_COMPILE@)
  10. set(HTTPLIB_IS_USING_BROTLI @HTTPLIB_IS_USING_BROTLI@)
  11. set(HTTPLIB_IS_USING_NON_BLOCKING_GETADDRINFO @HTTPLIB_IS_USING_NON_BLOCKING_GETADDRINFO@)
  12. set(HTTPLIB_VERSION @PROJECT_VERSION@)
  13. include(CMakeFindDependencyMacro)
  14. # We add find_dependency calls here to not make the end-user have to call them.
  15. find_dependency(Threads)
  16. if(@HTTPLIB_IS_USING_OPENSSL@)
  17. # OpenSSL COMPONENTS were added in Cmake v3.11
  18. if(CMAKE_VERSION VERSION_LESS "3.11")
  19. find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@)
  20. else()
  21. # Once the COMPONENTS were added, they were made optional when not specified.
  22. # Since we use both, we need to search for both.
  23. find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL)
  24. endif()
  25. set(httplib_OpenSSL_FOUND ${OpenSSL_FOUND})
  26. endif()
  27. if(@HTTPLIB_IS_USING_ZLIB@)
  28. find_dependency(ZLIB)
  29. set(httplib_ZLIB_FOUND ${ZLIB_FOUND})
  30. endif()
  31. if(@HTTPLIB_IS_USING_WOLFSSL@)
  32. find_dependency(wolfssl)
  33. set(httplib_wolfssl_FOUND ${wolfssl_FOUND})
  34. endif()
  35. if(@HTTPLIB_IS_USING_MBEDTLS@)
  36. find_dependency(MbedTLS)
  37. set(httplib_MbedTLS_FOUND ${MbedTLS_FOUND})
  38. endif()
  39. if(@HTTPLIB_IS_USING_BROTLI@)
  40. # Needed so we can use our own FindBrotli.cmake in this file.
  41. # Note that the FindBrotli.cmake file is installed in the same dir as this file.
  42. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
  43. set(BROTLI_USE_STATIC_LIBS @BROTLI_USE_STATIC_LIBS@)
  44. find_dependency(Brotli COMPONENTS common encoder decoder)
  45. set(httplib_Brotli_FOUND ${Brotli_FOUND})
  46. endif()
  47. if(@HTTPLIB_IS_USING_ZSTD@)
  48. set(httplib_fd_zstd_quiet_arg)
  49. if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  50. set(httplib_fd_zstd_quiet_arg QUIET)
  51. endif()
  52. set(httplib_fd_zstd_required_arg)
  53. if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
  54. set(httplib_fd_zstd_required_arg REQUIRED)
  55. endif()
  56. find_package(zstd QUIET)
  57. if(NOT zstd_FOUND)
  58. find_package(PkgConfig ${httplib_fd_zstd_quiet_arg} ${httplib_fd_zstd_required_arg})
  59. if(PKG_CONFIG_FOUND)
  60. pkg_check_modules(zstd ${httplib_fd_zstd_quiet_arg} ${httplib_fd_zstd_required_arg} IMPORTED_TARGET libzstd)
  61. if(TARGET PkgConfig::zstd)
  62. add_library(zstd::libzstd ALIAS PkgConfig::zstd)
  63. endif()
  64. endif()
  65. endif()
  66. set(httplib_zstd_FOUND ${zstd_FOUND})
  67. endif()
  68. # Mildly useful for end-users
  69. # Not really recommended to be used though
  70. set_and_check(HTTPLIB_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
  71. # Lets the end-user find the header path with the header appended
  72. # This is helpful if you're using Cmake's pre-compiled header feature
  73. set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h")
  74. check_required_components(httplib)
  75. # Brings in the target library, but only if all required components are found
  76. if(NOT DEFINED httplib_FOUND OR httplib_FOUND)
  77. include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake")
  78. endif()
  79. # Outputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib)
  80. include(FindPackageMessage)
  81. if(TARGET httplib::httplib)
  82. set(HTTPLIB_FOUND TRUE)
  83. # Since the compiled version has a lib, show that in the message
  84. if(@HTTPLIB_COMPILE@)
  85. # The list of configurations is most likely just 1 unless they installed a debug & release
  86. get_target_property(_httplib_configs httplib::httplib "IMPORTED_CONFIGURATIONS")
  87. # Need to loop since the "IMPORTED_LOCATION" property isn't want we want.
  88. # Instead, we need to find the IMPORTED_LOCATION_RELEASE or IMPORTED_LOCATION_DEBUG which has the lib path.
  89. foreach(_httplib_conf "${_httplib_configs}")
  90. # Grab the path to the lib and sets it to HTTPLIB_LIBRARY
  91. get_target_property(HTTPLIB_LIBRARY httplib::httplib "IMPORTED_LOCATION_${_httplib_conf}")
  92. # Check if we found it
  93. if(HTTPLIB_LIBRARY)
  94. break()
  95. endif()
  96. endforeach()
  97. unset(_httplib_configs)
  98. unset(_httplib_conf)
  99. find_package_message(httplib "Found httplib: ${HTTPLIB_LIBRARY} (found version \"${HTTPLIB_VERSION}\")" "[${HTTPLIB_LIBRARY}][${HTTPLIB_HEADER_PATH}]")
  100. else()
  101. find_package_message(httplib "Found httplib: ${HTTPLIB_HEADER_PATH} (found version \"${HTTPLIB_VERSION}\")" "[${HTTPLIB_HEADER_PATH}]")
  102. endif()
  103. endif()