File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1414
1515 -------------------------------------------------------------------------------
1616
17- After installation with Cmake, a find_package(httplib) is available.
18- This creates a httplib::httplib target (if found).
17+ After installation with Cmake, a find_package(httplib COMPONENTS OpenSSL ZLIB Brotli ) is available.
18+ This creates a httplib::httplib target (if found and if listed components are supported ).
1919 It can be linked like so:
2020
2121 target_link_libraries(your_exe httplib::httplib)
@@ -235,8 +235,6 @@ configure_package_config_file("${PROJECT_NAME}Config.cmake.in"
235235 INSTALL_DESTINATION "${_TARGET_INSTALL_CMAKEDIR} "
236236 # Passes the includedir install path
237237 PATH_VARS CMAKE_INSTALL_FULL_INCLUDEDIR
238- # There aren't any components, so don't use the macro
239- NO_CHECK_REQUIRED_COMPONENTS_MACRO
240238)
241239
242240if (HTTPLIB_COMPILE)
Original file line number Diff line number Diff line change @@ -42,8 +42,17 @@ set_and_check(HTTPLIB_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
4242# This is helpful if you're using Cmake's pre-compiled header feature
4343set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h" )
4444
45- # Brings in the target library
46- include ("${CMAKE_CURRENT_LIST_DIR} /httplibTargets.cmake" )
45+ # Consider each library support as a "component"
46+ set (httplib_OpenSSL_FOUND @HTTPLIB_IS_USING_OPENSSL@)
47+ set (httplib_ZLIB_FOUND @HTTPLIB_IS_USING_ZLIB@)
48+ set (httplib_Brotli_FOUND @HTTPLIB_IS_USING_BROTLI@)
49+
50+ check_required_components(httplib)
51+
52+ # Brings in the target library, but only if all required components are found
53+ if (NOT DEFINED httplib_FOUND OR httplib_FOUND)
54+ include ("${CMAKE_CURRENT_LIST_DIR} /httplibTargets.cmake" )
55+ endif ()
4756
4857# Ouputs a "found httplib /usr/include/httplib.h" message when using find_package(httplib)
4958include (FindPackageMessage)
You can’t perform that action at this time.
0 commit comments