cmake: fix/add missing feature detections for Windows/MS-DOS#16278
Closed
vszakats wants to merge 12 commits intocurl:masterfrom
Closed
cmake: fix/add missing feature detections for Windows/MS-DOS#16278vszakats wants to merge 12 commits intocurl:masterfrom
vszakats wants to merge 12 commits intocurl:masterfrom
Conversation
e514ca7 to
435cbb3
Compare
This comment was marked as outdated.
This comment was marked as outdated.
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Feb 10, 2025
Almost all feature detection results are pre-filled on Windows for performance, so none of the issues fixed here affected builds. But, for good measure, this patch add missing detections and fixes others to make sure they work even when omitting the pre-fill. - fix `HAVE_STRUCT_TIMEVAL` detection for MSVC. Follow-up to c1bc090 curl#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 8e34505 curl#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 8e34505 curl#15164 Also: - move IPv6-related detections so that pre-filling applies to them. - add debug option to test without pre-filling. - fix compiler warnings happening in feature detections to reduce log noise. (uninitialized/unused variables, missing static, missing const, constant conditional, macro redef, OpenSSL 3 deprecation warning.) Closes curl#16278
2 tasks
Follow-up to c1bc090 curl#12495
To make the cache affect HAVE_SOCKADDR_IN6_* detections
Regression from 8e34505 curl#15164
```
cl /c /ID:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\ /I"Generated Files\\\\" /IcmTC_a5c0f.dir\\Debug\\ /Zi /W4 /WX- /diagnostics:column /sdl /MP /Od /Ob0 /Oy- /D _UNICODE /D UNICODE /D _DEBUG /D WINAPI_FAMILY=WINAPI_FAMILY_APP /D __WRL_NO_DEFAULT_LIB__ /D WINAPI_FAMILY=WINAPI_FAMILY_PC_APP /D HAVE_IOCTLSOCKET /D HAVE_STDBOOL_H /D HAVE_SYS_TYPES_H /D WIN32_LEAN_AND_MEAN /D _CRT_NONSTDC_NO_DEPRECATE /D "CMAKE_INTDIR=\\"Debug\\"" /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_a5c0f.dir\\Debug\\\\" /Fd"cmTC_a5c0f.dir\\Debug\\vc143.pdb" /external:W4 /Gd /TC /FU"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\lib\\x86\\store\\references\\platform.winmd" /analyze- /errorReport:queue D:\\a\\curl\\curl\\CMake\\CurlTests.c
CurlTests.c
D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,17): warning C4189: 'flags': local variable is initialized but not referenced [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_a5c0f.vcxproj]
D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,1): error C4700: uninitialized local variable 'socket' used [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_a5c0f.vcxproj]
Done Building Project "D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_a5c0f.vcxproj" (default targets) -- FAILED.
Build FAILED.
```
https://github.com/curl/curl/actions/runs/13215270720/job/36893785770?pr=16238#step:7:12099
vs non-UWP:
```
cl /c /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /Zi /W4 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D HAVE_IOCTLSOCKET /D HAVE_STDBOOL_H /D HAVE_SYS_TYPES_H /D WIN32_LEAN_AND_MEAN /D _CRT_NONSTDC_NO_DEPRECATE /D "CMAKE_INTDIR=\\"Debug\\"" /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_41ff3.dir\\Debug\\\\" /Fd"cmTC_41ff3.dir\\Debug\\vc143.pdb" /external:W4 /Gd /TC /errorReport:queue D:\\a\\curl\\curl\\CMake\\CurlTests.c
CurlTests.c
D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,17): warning C4189: 'flags': local variable is initialized but not referenced [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj]
D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,1): warning C4700: uninitialized local variable 'socket' used [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj]
Link:
C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\link.exe /ERRORREPORT:QUEUE /OUT:"D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\Debug\\cmTC_41ff3.exe" /INCREMENTAL /ILK:"cmTC_41ff3.dir\\Debug\\cmTC_41ff3.ilk" /NOLOGO ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"D:/a/curl/curl/bld/CMakeFiles/CMakeTmp/Debug/cmTC_41ff3.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:/a/curl/curl/bld/CMakeFiles/CMakeTmp/Debug/cmTC_41ff3.lib" /MACHINE:X64 cmTC_41ff3.dir\\Debug\\CurlTests.obj
cmTC_41ff3.vcxproj -> D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\Debug\\cmTC_41ff3.exe
FinalizeBuildStatus:
Deleting file "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\unsuccessfulbuild".
Touching "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\cmTC_41ff3.lastbuildstate".
Done Building Project "D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj" (default targets).
Build succeeded.
```
https://github.com/curl/curl/actions/runs/13215270720/job/36893785770?pr=16238#step:7:12099
This is declared via iphlpapi.h and needs iphlpapi implib. In MSVC UWP it gets detected, presumably because iphlpapi is linked by default (?), and the commit below switched detection to 'function' (vs 'symbol') to match ./configure. This results in an unwanted detection for MSVC UWP, because we normally don't want to use this function on Windows in curl. The mis-detection is even stranger because this function is not declared by the SDK for UWP. https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-if_nametoindex Normally we pre-cache this value to FALSE, so it wasn't causing any issue. Regression from 8e34505 ``` kind: "try_compile-v1" backtrace: - "CMake/Macros.cmake:51 (try_compile)" - "CMakeLists.txt:1815 (curl_internal_test)" directories: source: "D:/a/curl/curl/bld/CMakeFiles/CMakeTmp" binary: "D:/a/curl/curl/bld/CMakeFiles/CMakeTmp" cmakeVariables: CMAKE_C_FLAGS: " -W4 -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include -IC:/vcpkg/installed/x64-windows/debug/../include" CMAKE_C_FLAGS_DEBUG: "/Zi /Ob0 /Od /RTC1" CMAKE_EXE_LINKER_FLAGS: "-INCREMENTAL:NO" CMAKE_MODULE_PATH: "D:/a/curl/curl/CMake" VCPKG_INSTALLED_DIR: "C:/vcpkg/installed" VCPKG_PREFER_SYSTEM_LIBS: "OFF" VCPKG_TARGET_TRIPLET: "x64-windows" Z_VCPKG_ROOT_DIR: "C:/vcpkg" buildResult: variable: "HAVE_IOCTLSOCKET" cached: true stdout: | Change Dir: 'D:/a/curl/curl/bld/CMakeFiles/CMakeTmp' Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe" cmTC_41ff3.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n MSBuild version 17.12.12+1cce77968 for .NET Framework Build started 2/8/2025 11:40:41 AM. Project "D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "cmTC_41ff3.dir\\Debug\\". Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details. Creating directory "D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\Debug\\". Creating directory "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\". InitializeBuildStatus: Creating "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\unsuccessfulbuild" because "AlwaysCreate" was specified. Touching "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\unsuccessfulbuild". ClCompile: C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\CL.exe /c /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /Zi /W4 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D HAVE_IOCTLSOCKET /D HAVE_STDBOOL_H /D HAVE_SYS_TYPES_H /D WIN32_LEAN_AND_MEAN /D _CRT_NONSTDC_NO_DEPRECATE /D "CMAKE_INTDIR=\\"Debug\\"" /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_41ff3.dir\\Debug\\\\" /Fd"cmTC_41ff3.dir\\Debug\\vc143.pdb" /external:W4 /Gd /TC /errorReport:queue D:\\a\\curl\\curl\\CMake\\CurlTests.c Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34436 for x64 Copyright (C) Microsoft Corporation. All rights reserved. cl /c /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /I"C:\\vcpkg\\installed\\x64-windows\\debug\\..\\include" /Zi /W4 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D HAVE_IOCTLSOCKET /D HAVE_STDBOOL_H /D HAVE_SYS_TYPES_H /D WIN32_LEAN_AND_MEAN /D _CRT_NONSTDC_NO_DEPRECATE /D "CMAKE_INTDIR=\\"Debug\\"" /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_41ff3.dir\\Debug\\\\" /Fd"cmTC_41ff3.dir\\Debug\\vc143.pdb" /external:W4 /Gd /TC /errorReport:queue D:\\a\\curl\\curl\\CMake\\CurlTests.c CurlTests.c D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,17): warning C4189: 'flags': local variable is initialized but not referenced [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj] D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,1): warning C4700: uninitialized local variable 'socket' used [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj] Link: C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\link.exe /ERRORREPORT:QUEUE /OUT:"D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\Debug\\cmTC_41ff3.exe" /INCREMENTAL /ILK:"cmTC_41ff3.dir\\Debug\\cmTC_41ff3.ilk" /NOLOGO ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"D:/a/curl/curl/bld/CMakeFiles/CMakeTmp/Debug/cmTC_41ff3.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:/a/curl/curl/bld/CMakeFiles/CMakeTmp/Debug/cmTC_41ff3.lib" /MACHINE:X64 cmTC_41ff3.dir\\Debug\\CurlTests.obj cmTC_41ff3.vcxproj -> D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\Debug\\cmTC_41ff3.exe FinalizeBuildStatus: Deleting file "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\unsuccessfulbuild". Touching "cmTC_41ff3.dir\\Debug\\cmTC_41ff3.tlog\\cmTC_41ff3.lastbuildstate". Done Building Project "D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj" (default targets). Build succeeded. "D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj" (default target) (1) -> (ClCompile target) -> D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,17): warning C4189: 'flags': local variable is initialized but not referenced [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj] D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,1): warning C4700: uninitialized local variable 'socket' used [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj] 2 Warning(s) 0 Error(s) Time Elapsed 00:00:00.62 exitCode: 0 ``` https://github.com/curl/curl/actions/runs/13215270720/job/36893785298?pr=16238#step:7:7163
225af9d to
9883588
Compare
This reverts commit 0228716.
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Feb 11, 2025
Almost all feature detection results are pre-filled on Windows for performance, so none of the issues fixed here affected builds. But, for good measure, this patch add missing detections and fixes others to make sure they work even when omitting the pre-fill. - fix `HAVE_STRUCT_TIMEVAL` detection for MSVC. Follow-up to c1bc090 curl#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 8e34505 curl#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 8e34505 curl#15164 Also: - move IPv6 detections so that pre-filling applies to them. - add debug option to test without pre-filling. - replace `NOT LESS` with `GREATER_EQUAL` Closes curl#16278
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
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 c1bc090 curl#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 8e34505 curl#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 8e34505 curl#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 a3585c9 curl#15543 Also: - add debug option to test without pre-filling. - replace `NOT LESS` with `GREATER_EQUAL` Closes curl#16278
vszakats
added a commit
that referenced
this pull request
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
HAVE_STRUCT_TIMEVALdetection for MSVC.Follow-up to c1bc090 windows: simplify detecting and using system headers #12495
HAVE_SOCKADDR_IN6_SIN6_SCOPE_IDdetection for Windows.HAVE_STRDUPdetection for MSVC.HAVE_SNPRINTFdetection for Windows.Regression from 8e34505 cmake: untangle feature detection interdependencies #15164
HAVE_IOCTLSOCKETdetection for non-UWP MSVC.if_nametoindexdetection for Windows.Although it exists on Windows, detection, usage and availability is
complicated, and curl doesn't use it on this platform.
Regression from 8e34505 cmake: untangle feature detection interdependencies #15164
configuration applies to them. This fixes
HAVE_SOCKADDR_IN6_SIN6_SCOPE_IDdetection with MS-DOS.Ref: https://github.com/curl/curl/actions/runs/13260511764/job/37015877585#step:7:306
Follow-up to a3585c9 Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) #15543
Also:
NOT LESSwithGREATER_EQUALw/o whitespace: https://github.com/curl/curl/pull/16278/files?w=1