cmake: fix/add missing feature detections for Windows/MS-DOS

Almost all feature detection results are pre-filled on Windows
for performance, so none of the issues fixed here affected builds.

For good measure, this patch add missing detections and fixes others
to make sure they work even when omitting the pre-fill.

It also fixes detecting IPv6 for MS-DOS.

- fix `HAVE_STRUCT_TIMEVAL` detection for MSVC.
  Follow-up to c1bc090d65 #12495
- add `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection for Windows.
- fix `HAVE_STRDUP` detection for MSVC.
- fix `HAVE_SNPRINTF` detection for Windows.
  Regression from 8e34505776 #15164
- fix `HAVE_IOCTLSOCKET` detection for non-UWP MSVC.
- exclude `if_nametoindex` detection for Windows.
  Although it exists on Windows, detection, usage and availability is
  complicated, and curl doesn't use it on this platform.
  Regression from 8e34505776 #15164
- move IPv6 detections so that pre-filling and MS-DOS Watt-32
  configuration applies to them. This fixes
  `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection with MS-DOS.
  Ref: https://github.com/curl/curl/actions/runs/13260511764/job/37015877585#step:7:306
  Follow-up to a3585c9576 #15543

Also:
- add debug option to test without pre-filling.
- replace `NOT LESS` with `GREATER_EQUAL`

Closes #16278
This commit is contained in:
Viktor Szakats 2025-02-08 03:20:02 +01:00
parent e520493742
commit 6ab1fa423b
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
5 changed files with 66 additions and 52 deletions

View file

@ -167,7 +167,7 @@ int main(void) { return 0; }
int main(void)
{
/* ioctlsocket source code */
int socket;
int socket = -1;
unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
;
return 0;

View file

@ -65,6 +65,9 @@ endif()
set(_source_epilogue "#undef inline")
curl_add_header_include(HAVE_SYS_TIME_H "sys/time.h")
check_c_source_compiles("${_source_epilogue}
#ifdef _MSC_VER
#include <winsock2.h>
#endif
#include <time.h>
int main(void)
{

View file

@ -74,12 +74,12 @@ else()
set(HAVE_UNISTD_H 0)
set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size()
set(HAVE_STDATOMIC_H 0)
if(NOT MSVC_VERSION LESS 1600)
if(MSVC_VERSION GREATER_EQUAL 1600)
set(HAVE_STDINT_H 1) # detected by CMake internally in check_type_size()
else()
set(HAVE_STDINT_H 0) # detected by CMake internally in check_type_size()
endif()
if(NOT MSVC_VERSION LESS 1800)
if(MSVC_VERSION GREATER_EQUAL 1800)
set(HAVE_STDBOOL_H 1)
set(HAVE_STRTOLL 1)
else()
@ -87,7 +87,7 @@ else()
set(HAVE_STRTOLL 0)
endif()
set(HAVE_BOOL_T "${HAVE_STDBOOL_H}")
if(NOT MSVC_VERSION LESS 1900)
if(MSVC_VERSION GREATER_EQUAL 1900)
set(HAVE_SNPRINTF 1)
else()
set(HAVE_SNPRINTF 0)