Skip to content

Commit dfd36d3

Browse files
committed
cmake: apply WIN32_LEAN_AND_MEAN to all feature checks
Enable `WIN32_LEAN_AND_MEAN` for all feature detections on Windows. (Also drop it from individual detections.) Cherry-picked from curl#15164
1 parent 8e34505 commit dfd36d3

File tree

3 files changed

+2
-19
lines changed

3 files changed

+2
-19
lines changed

CMake/CurlTests.c

-18
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ int main(void) { return 0; }
166166
#ifdef HAVE_IOCTLSOCKET
167167
/* includes start */
168168
#ifdef _WIN32
169-
# ifndef WIN32_LEAN_AND_MEAN
170-
# define WIN32_LEAN_AND_MEAN
171-
# endif
172169
# include <winsock2.h>
173170
#endif
174171
int main(void)
@@ -185,9 +182,6 @@ int main(void)
185182
#ifdef HAVE_IOCTLSOCKET_CAMEL
186183
/* includes start */
187184
#ifdef _WIN32
188-
# ifndef WIN32_LEAN_AND_MEAN
189-
# define WIN32_LEAN_AND_MEAN
190-
# endif
191185
# include <winsock2.h>
192186
#endif
193187
int main(void)
@@ -203,9 +197,6 @@ int main(void)
203197
#ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
204198
/* includes start */
205199
#ifdef _WIN32
206-
# ifndef WIN32_LEAN_AND_MEAN
207-
# define WIN32_LEAN_AND_MEAN
208-
# endif
209200
# include <winsock2.h>
210201
#endif
211202
int main(void)
@@ -222,9 +213,6 @@ int main(void)
222213
#ifdef HAVE_IOCTLSOCKET_FIONBIO
223214
/* includes start */
224215
#ifdef _WIN32
225-
# ifndef WIN32_LEAN_AND_MEAN
226-
# define WIN32_LEAN_AND_MEAN
227-
# endif
228216
# include <winsock2.h>
229217
#endif
230218
int main(void)
@@ -297,9 +285,6 @@ int main(void)
297285
#ifdef HAVE_SETSOCKOPT_SO_NONBLOCK
298286
/* includes start */
299287
#ifdef _WIN32
300-
# ifndef WIN32_LEAN_AND_MEAN
301-
# define WIN32_LEAN_AND_MEAN
302-
# endif
303288
# include <winsock2.h>
304289
#endif
305290
/* includes start */
@@ -410,9 +395,6 @@ int main(void)
410395
#ifdef HAVE_WIN32_WINNT
411396
/* includes start */
412397
#ifdef _WIN32
413-
# ifndef WIN32_LEAN_AND_MEAN
414-
# define WIN32_LEAN_AND_MEAN
415-
# endif
416398
# ifndef NOGDI
417399
# define NOGDI
418400
# endif

CMake/OtherTests.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ if(NOT DEFINED HAVE_STRUCT_SOCKADDR_STORAGE)
3939
unset(CMAKE_EXTRA_INCLUDE_FILES)
4040
if(WIN32)
4141
set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h")
42-
set(CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN")
4342
set(CMAKE_REQUIRED_LIBRARIES "ws2_32")
4443
elseif(HAVE_SYS_SOCKET_H)
4544
set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ if(WIN32)
165165
endif()
166166
endif()
167167

168+
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN") # Apply to all feature checks
169+
168170
set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
169171
if(CURL_TARGET_WINDOWS_VERSION)
170172
add_definitions("-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")

0 commit comments

Comments
 (0)