httplibConfig.cmake.in 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_VERSION @PROJECT_VERSION@)
  9. include(CMakeFindDependencyMacro)
  10. # We add find_dependency calls here to not make the end-user have to call them.
  11. find_dependency(Threads REQUIRED)
  12. if(@HTTPLIB_IS_USING_OPENSSL@)
  13. # OpenSSL COMPONENTS were added in Cmake v3.11
  14. if(CMAKE_VERSION VERSION_LESS "3.11")
  15. find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ REQUIRED)
  16. else()
  17. # Once the COMPONENTS were added, they were made optional when not specified.
  18. # Since we use both, we need to search for both.
  19. find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL REQUIRED)
  20. endif()
  21. endif()
  22. if(@HTTPLIB_IS_USING_ZLIB@)
  23. find_dependency(ZLIB REQUIRED)
  24. endif()
  25. # Mildly useful for end-users
  26. # Not really recommended to be used though
  27. set_and_check(HTTPLIB_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
  28. # Lets the end-user find the header path with the header appended
  29. # This is helpful if you're using Cmake's pre-compiled header feature
  30. set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h")
  31. # Brings in the target library
  32. include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake")
  33. # Ouputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib)
  34. include(FindPackageMessage)
  35. if(TARGET httplib::httplib)
  36. set(HTTPLIB_FOUND TRUE)
  37. # Since the compiled version has a lib, show that in the message
  38. if(@HTTPLIB_COMPILE@)
  39. # The list of configurations is most likely just 1 unless they installed a debug & release
  40. get_target_property(_httplib_configs httplib::httplib "IMPORTED_CONFIGURATIONS")
  41. # Need to loop since the "IMPORTED_LOCATION" property isn't want we want.
  42. # Instead, we need to find the IMPORTED_LOCATION_RELEASE or IMPORTED_LOCATION_DEBUG which has the lib path.
  43. foreach(_httplib_conf "${_httplib_configs}")
  44. # Grab the path to the lib and sets it to HTTPLIB_LIBRARY
  45. get_target_property(HTTPLIB_LIBRARY httplib::httplib "IMPORTED_LOCATION_${_httplib_conf}")
  46. # Check if we found it
  47. if(HTTPLIB_LIBRARY)
  48. break()
  49. endif()
  50. endforeach()
  51. unset(_httplib_configs)
  52. unset(_httplib_conf)
  53. find_package_message(httplib "Found httplib: ${HTTPLIB_LIBRARY} (found version \"${HTTPLIB_VERSION}\")" "[${HTTPLIB_LIBRARY}][${HTTPLIB_HEADER_PATH}]")
  54. else()
  55. find_package_message(httplib "Found httplib: ${HTTPLIB_HEADER_PATH} (found version \"${HTTPLIB_VERSION}\")" "[${HTTPLIB_HEADER_PATH}]")
  56. endif()
  57. endif()