Skip to content

cmake: only validate component when the required library is found #2112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions cmake/httplibConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ if(@HTTPLIB_IS_USING_OPENSSL@)
# Since we use both, we need to search for both.
find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL)
endif()
set(httplib_OpenSSL_FOUND ${OpenSSL_FOUND})
endif()
if(@HTTPLIB_IS_USING_ZLIB@)
find_dependency(ZLIB)
set(httplib_ZLIB_FOUND ${ZLIB_FOUND})
endif()

if(@HTTPLIB_IS_USING_BROTLI@)
Expand All @@ -33,10 +35,12 @@ if(@HTTPLIB_IS_USING_BROTLI@)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
set(BROTLI_USE_STATIC_LIBS @BROTLI_USE_STATIC_LIBS@)
find_dependency(Brotli COMPONENTS common encoder decoder)
set(httplib_Brotli_FOUND ${Brotli_FOUND})
endif()

if(@HTTPLIB_IS_USING_ZSTD@)
find_dependency(zstd)
set(httplib_zstd_FOUND ${zstd_FOUND})
endif()

# Mildly useful for end-users
Expand All @@ -46,12 +50,6 @@ set_and_check(HTTPLIB_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
# This is helpful if you're using Cmake's pre-compiled header feature
set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h")

# Consider each library support as a "component"
set(httplib_OpenSSL_FOUND @HTTPLIB_IS_USING_OPENSSL@)
set(httplib_ZLIB_FOUND @HTTPLIB_IS_USING_ZLIB@)
set(httplib_Brotli_FOUND @HTTPLIB_IS_USING_BROTLI@)
set(httplib_zstd_FOUND @HTTPLIB_IS_USING_ZSTD@)

check_required_components(httplib)

# Brings in the target library, but only if all required components are found
Expand Down
Loading