Added a feature test to auto enable/disable CPPHTTPLIB_USE_NON_BLOCKI… - #2578
Added a feature test to auto enable/disable CPPHTTPLIB_USE_NON_BLOCKI…#2578TobiasWallner wants to merge 1 commit into
Conversation
|
@sum01 @jimmy-park @Tachi107 this PR looks good to me. Could you please take a look at it? |
|
@TobiasWallner could you take a look at the CI failures of |
|
|
||
| if(NOT HTTPLIB_HAVE_GETADDRINFOEXCANCEL) | ||
| set(HTTPLIB_IS_USING_NON_BLOCKING_GETADDRINFO FALSE) | ||
| message(STATUS "GetAddrInfoExCancel is unavailable; disabling non-blocking getaddrinfo.") |
There was a problem hiding this comment.
Wouldn't it probably be better to use either WARNING or even FATAL_ERROR here?
I'm not sure what people would prefer personally, but having the build stop makes some sense to me, as it's an explicitly enabled option that will not work/be supported.
There was a problem hiding this comment.
Good point, i would use a warning, because the user might still want to compile it and provide the function by itself or link something that cmake does not see at this point.
|
@TobiasWallner, since the master branch has progressed quite a bit, please run |
Summary
Add CMake feature detection for
CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFOon Windows.When
HTTPLIB_USE_NON_BLOCKING_GETADDRINFOis enabled, CMake now checks whetherGetAddrInfoExCancelis available before exportingCPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFOthrough thehttplib::httplibtarget. If the symbol is not available, the non-blocking getaddrinfo support is disabled automatically.Motivation
Some Windows machines/toolchains do not provide
GetAddrInfoExCancel, which causes downstream projects using cpp-httplib via CMake to fail compilation whenCPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFOis exported unconditionally.Previously, consumers had to work around this by manually removing the interface compile definition from
httplib::httplib. With this change, cpp-httplib configures itself correctly out of the box.Testing
Verified on a Windows machine where
GetAddrInfoExCancelis unavailable:GetAddrInfoExCancel - not foundHTTPLIB_IS_USING_NON_BLOCKING_GETADDRINFOis set toFALSECPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFOis not present on the consumer compile line