diff options
author | Viktor Szakats <commit@vsz.me> | 2022-08-31 11:57:24 +0000 |
---|---|---|
committer | Viktor Szakats <commit@vsz.me> | 2022-08-31 11:57:24 +0000 |
commit | 7cd400a4d257a080ea3c1cbeb644e4be62f6d2c5 (patch) | |
tree | 5bcb20af45e9ae694ddf3a38a7e6a47f588396df /CMakeLists.txt | |
parent | 93d092867f0f2c78571983040ef75e078ee1a4c4 (diff) | |
download | curl-7cd400a4d257a080ea3c1cbeb644e4be62f6d2c5.tar.gz |
cmake: fix original MinGW builds
1. Re-enable `HAVE_GETADDRINFO` detection on Windows
Commit d08ee3c83d6bd416aef62ff844c98e47c4682429 (in 2013) added logic
that automatically assumed `getaddrinfo()` to be present for builds
with IPv6 enabled. As it turns out, certain toolchains (e.g. original
MinGW) by default target older Windows versions, and thus do not
support `getaddrinfo()` out of the box. The issue was masked for
a while by CMake builds forcing a newer Windows version, but that
logic got deleted in commit 8ba22ffb2030ed91312fc8634e29516cdf0a9761.
Since then, some CI builds started failing due to IPv6 enabled,
`HAVE_GETADDRINFO` set, but `getaddrinfo()` in fact missing.
It also turns out that IPv6 works without `getaddrinfo()` since commit
67a08dca27a6a07b36c7f97252e284ca957ff1a5 (from 2019, via #4662). So,
to resolve all this, we can now revert the initial commit, thus
restoring `getaddrinfo()` detection and support IPv6 regardless of its
outcome.
Reported-by: Daniel Stenberg
2. Omit `bcrypt` with original MinGW
Original (aka legacy/old) MinGW versions do not support `bcrypt`
(introduced with Vista). We already have logic to handle that in
`lib/rand.c` and autotools builds, where we do not call the
unsupported API and do not link `bcrypt`, respectively, when using
original MinGW.
This patch ports that logic to CMake, fixing the link error:
`c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbcrypt`
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/44624888/job/40vle84cn4vle7s0#L508
Regression since 76172511e7adcf720f4c77bd91f49278300ec97e
Fixes #9214
Fixes #9393
Fixes #9395
Closes #9396
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f8cdf1aab..cb597ca8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1291,7 +1291,22 @@ if(WIN32) list(APPEND CURL_LIBS "advapi32" "crypt32") endif() - list(APPEND CURL_LIBS "bcrypt") + # Matching logic used for Curl_win32_random() + if(MINGW) + check_c_source_compiles(" + #include <_mingw.h> + #if defined(__MINGW64_VERSION_MAJOR) + #error + #endif + int main(void) { + return 0; + }" + HAVE_MINGW_ORIGINAL) + endif() + + if(NOT HAVE_MINGW_ORIGINAL) + list(APPEND CURL_LIBS "bcrypt") + endif() endif() if(MSVC) |