httplibConfig.cmake.in 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_ZLIB @HTTPLIB_IS_USING_ZLIB@)
  7. set(HTTPLIB_IS_COMPILED @HTTPLIB_COMPILE@)
  8. set(HTTPLIB_IS_USING_BROTLI @HTTPLIB_IS_USING_BROTLI@)
  9. set(HTTPLIB_VERSION @PROJECT_VERSION@)
  10. include(CMakeFindDependencyMacro)
  11. # We add find_dependency calls here to not make the end-user have to call them.
  12. find_dependency(Threads)
  13. if(@HTTPLIB_IS_USING_OPENSSL@)
  14. # OpenSSL COMPONENTS were added in Cmake v3.11
  15. if(CMAKE_VERSION VERSION_LESS "3.11")
  16. find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@)
  17. else()
  18. # Once the COMPONENTS were added, they were made optional when not specified.
  19. # Since we use both, we need to search for both.
  20. find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL)
  21. endif()
  22. endif()
  23. if(@HTTPLIB_IS_USING_ZLIB@)
  24. find_dependency(ZLIB)
  25. endif()
  26. if(@HTTPLIB_IS_USING_BROTLI@)
  27. # Needed so we can use our own FindBrotli.cmake in this file.
  28. # Note that the FindBrotli.cmake file is installed in the same dir as this file.
  29. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
  30. set(BROTLI_USE_STATIC_LIBS @BROTLI_USE_STATIC_LIBS@)
  31. find_dependency(Brotli COMPONENTS common encoder decoder)
  32. endif()
  33. if(@HTTPLIB_IS_USING_ZSTD@)
  34. find_dependency(zstd)
  35. endif()
  36. # Mildly useful for end-users
  37. # Not really recommended to be used though
  38. set_and_check(HTTPLIB_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
  39. # Lets the end-user find the header path with the header appended
  40. # This is helpful if you're using Cmake's pre-compiled header feature
  41. set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h")
  42. # Consider each library support as a "component"
  43. set(httplib_OpenSSL_FOUND @HTTPLIB_IS_USING_OPENSSL@)
  44. set(httplib_ZLIB_FOUND @HTTPLIB_IS_USING_ZLIB@)
  45. set(httplib_Brotli_FOUND @HTTPLIB_IS_USING_BROTLI@)
  46. set(httplib_zstd_FOUND @HTTPLIB_IS_USING_ZSTD@)
  47. check_required_components(httplib)
  48. # Brings in the target library, but only if all required components are found
  49. if(NOT DEFINED httplib_FOUND OR httplib_FOUND)
  50. include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake")
  51. endif()
  52. # Outputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib)
  53. include(FindPackageMessage)
  54. if(TARGET httplib::httplib)
  55. set(HTTPLIB_FOUND TRUE)
  56. # Since the compiled version has a lib, show that in the message
  57. if(@HTTPLIB_COMPILE@)
  58. # The list of configurations is most likely just 1 unless they installed a debug & release
  59. get_target_property(_httplib_configs httplib::httplib "IMPORTED_CONFIGURATIONS")
  60. # Need to loop since the "IMPORTED_LOCATION" property isn't want we want.
  61. # Instead, we need to find the IMPORTED_LOCATION_RELEASE or IMPORTED_LOCATION_DEBUG which has the lib path.
  62. foreach(_httplib_conf "${_httplib_configs}")
  63. # Grab the path to the lib and sets it to HTTPLIB_LIBRARY
  64. get_target_property(HTTPLIB_LIBRARY httplib::httplib "IMPORTED_LOCATION_${_httplib_conf}")
  65. # Check if we found it
  66. if(HTTPLIB_LIBRARY)
  67. break()
  68. endif()
  69. endforeach()
  70. unset(_httplib_configs)
  71. unset(_httplib_conf)
  72. find_package_message(httplib "Found httplib: ${HTTPLIB_LIBRARY} (found version \"${HTTPLIB_VERSION}\")" "[${HTTPLIB_LIBRARY}][${HTTPLIB_HEADER_PATH}]")
  73. else()
  74. find_package_message(httplib "Found httplib: ${HTTPLIB_HEADER_PATH} (found version \"${HTTPLIB_VERSION}\")" "[${HTTPLIB_HEADER_PATH}]")
  75. endif()
  76. endif()