Added a feature test to auto enable/disable CPPHTTPLIB_USE_NON_BLOCKI… - #2578
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.
There was a problem hiding this comment.
Wouldn't it probably be better to use either
WARNINGor evenFATAL_ERRORhere?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.
Changed it to a warning
|
@TobiasWallner, since the master branch has progressed quite a bit, please run |
|
yes, sry i will, i just had not had the time and head for it lately |
|
@TobiasWallner could you please remove things unrelated to CMake such as b29d191? |
b29d191 to
07e7729
Compare
… non-blocking getaddrinfo.' into a warning
07e7729 to
522b60a
Compare
Sry, sure done |
Lets see if this correctly addresses that, I cannot reproduce the failure on my local machine, lets see what happens in CI. |
|
@TobiasWallner thanks for your fine contribution! |
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