Skip to content

Commit 9c497a1

Browse files
committed
Sync configuration with upstream win32/build/config.w32.h.in template
1 parent 9bae4d6 commit 9c497a1

File tree

5 files changed

+107
-28
lines changed

5 files changed

+107
-28
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ endif()
232232
# Check for socklen_t type.
233233
cmake_push_check_state(RESET)
234234
if(HAVE_SYS_SOCKET_H)
235-
set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
235+
list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
236+
endif()
237+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
238+
list(APPEND CMAKE_EXTRA_INCLUDE_FILES ws2tcpip.h)
236239
endif()
237240
check_type_size("socklen_t" SOCKLEN_T)
238241
cmake_pop_check_state()
@@ -374,7 +377,12 @@ check_symbol_exists(symlink unistd.h HAVE_SYMLINK)
374377
check_symbol_exists(tzset time.h HAVE_TZSET)
375378
check_symbol_exists(unsetenv stdlib.h HAVE_UNSETENV)
376379
check_symbol_exists(usleep unistd.h HAVE_USLEEP)
377-
check_symbol_exists(utime utime.h HAVE_UTIME)
380+
381+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
382+
check_symbol_exists(utime sys/utime.h HAVE_UTIME)
383+
else()
384+
check_symbol_exists(utime utime.h HAVE_UTIME)
385+
endif()
378386

379387
cmake_push_check_state(RESET)
380388
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)

cmake/cmake/platforms/Windows.cmake

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,99 @@ Specific configuration for Windows platform.
55
include_guard(GLOBAL)
66

77
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
8-
# Common compilation definitions.
9-
target_compile_definitions(
10-
php_config
11-
INTERFACE
12-
PHP_WIN32 # For PHP code
13-
_WIN32 # Defined by all compilers when targeting Windows. Left here
14-
# to match the native PHP Windows build system.
15-
WIN32 # Defined by Windows SDK and some compilers (GCC and Clang)
16-
# when targeting Windows. Left here for BC for possible PECL
17-
# extensions not being updated yet. In new code it is being
18-
# replaced with _WIN32.
19-
ZEND_WIN32 # For Zend Engine
20-
)
21-
228
# To speed up the Windows build experience with Visual Studio generators,
239
# these are always known on Windows systems.
24-
# TODO: Update and fix this better.
2510

11+
# Whether system has <alloca.h> header.
12+
set(HAVE_ALLOCA_H FALSE)
13+
14+
# Whether system has <dirent.h> header.
15+
set(HAVE_DIRENT_H FALSE)
16+
17+
# PHP has fnmatch() emulation implemented on Windows.
2618
set(HAVE_FNMATCH TRUE)
2719

28-
# PHP has unconditional getaddrinfo() support on Windows for now.
20+
# Whether system has flock().
21+
set(HAVE_FLOCK FALSE)
22+
23+
# PHP has ftok() emulation implemented on Windows.
24+
set(HAVE_FTOK TRUE)
25+
26+
# PHP has unconditional getaddrinfo() support on Windows.
2927
set(HAVE_GETADDRINFO TRUE)
3028

29+
# PHP has unconditional support for getcwd() on Windows.
30+
set(HAVE_GETCWD TRUE)
31+
3132
# PHP defines getpid as _getpid on Windows.
3233
set(HAVE_GETPID TRUE)
3334

34-
# PHP has custom glob() implemented on Windows.
35+
# PHP has getrusage() emulation implemented on Windows.
36+
set(HAVE_GETRUSAGE TRUE)
37+
38+
# PHP has gettimeofday() emulation implemented on Windows.
39+
set(HAVE_GETTIMEOFDAY TRUE)
40+
41+
# PHP has glob() emulation implemented on Windows.
3542
set(HAVE_GLOB TRUE)
3643

37-
# PHP has custom nanosleep for Windows platform.
44+
# Whether system has <grp.h> header.
45+
set(HAVE_GRP_H FALSE)
46+
47+
# Whether system has kill().
48+
set(HAVE_KILL FALSE)
49+
50+
# Windows has LoadLibrary().
51+
set(HAVE_LIBDL TRUE)
52+
53+
# PHP has nanosleep() emulation implemented on Windows.
3854
set(HAVE_NANOSLEEP TRUE)
3955

56+
# PHP has nice() emulation implemented on Windows.
4057
set(HAVE_NICE TRUE)
4158

42-
# PHP supports socketpair by the emulation in win32/sockets.c.
59+
# Whether system has <pwd.h> header.
60+
set(HAVE_PWD_H FALSE)
61+
62+
# Whether systems has setitimer().
63+
set(HAVE_SETITIMER FALSE)
64+
65+
# Windows has setjmp() in <setjmp.h> instead.
66+
set(HAVE_SIGSETJMP FALSE)
67+
68+
# PHP has socketpair() emulation implemented on Windows.
4369
set(HAVE_SOCKETPAIR TRUE)
4470

45-
# PHP defines strcasecmp in zend_config.w32.h.
71+
# PHP defines strcasecmp in Zend/zend_config.w32.h.
4672
set(HAVE_STRCASECMP TRUE)
4773

48-
# PHP has custom syslog.h for Windows platform.
74+
# Whether system has symlink().
75+
set(HAVE_SYMLINK FALSE)
76+
77+
# Whether system has <sys/file.h> header.
78+
set(HAVE_SYS_FILE_H FALSE)
79+
80+
# Whether system has <sys/socket.h> header.
81+
set(HAVE_SYS_SOCKET_H FALSE)
82+
83+
# Whether system has <sys/time.h> header.
84+
set(HAVE_SYS_TIME_H FALSE)
85+
86+
# Whether system has <sys/wait.h> header.
87+
set(HAVE_SYS_WAIT_H FALSE)
88+
89+
# PHP has syslog.h emulation implemented on Windows.
4990
set(HAVE_SYSLOG_H TRUE)
5091

51-
# PHP has custom usleep for Windows platform.
92+
# Whether 'st_blksize' is a member of 'struct stat'.
93+
set(HAVE_STRUCT_STAT_ST_BLKSIZE FALSE)
94+
95+
# Whether 'st_blocks' is a member of 'struct stat'.
96+
set(HAVE_STRUCT_STAT_ST_BLOCKS FALSE)
97+
98+
# Whether system has <unistd.h>.
99+
set(HAVE_UNISTD_H FALSE)
100+
101+
# PHP has usleep() emulation implemented on Windows.
52102
set(HAVE_USLEEP TRUE)
53103
endif()

cmake/ext/standard/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ endif()
327327
message(CHECK_START "Checking if OS can spawn processes with inherited handles")
328328
check_symbol_exists(fork unistd.h HAVE_FORK)
329329
if(NOT HAVE_FORK)
330-
check_symbol_exists(CreateProcess windows.h HAVE_CREATEPROCESS)
330+
check_symbol_exists(CreateProcess windows.h PHP_HAS_CREATEPROCESS)
331331
endif()
332-
if(HAVE_FORK OR HAVE_CREATEPROCESS)
332+
if(HAVE_FORK OR PHP_HAS_CREATEPROCESS)
333333
set(PHP_CAN_SUPPORT_PROC_OPEN TRUE)
334334

335335
message(CHECK_PASS "yes")

cmake/main/cmake/php_config.h.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define @PHP_CONFIG_HEADER_GUARD@
33

44
#if @PHP_CONFIG_H_WINDOWS@
5-
/* Define the minimum supported version */
5+
/* Define the minimum supported version. */
66
# undef _WIN32_WINNT
77
# undef NTDDI_VERSION
88
# define _WIN32_WINNT 0x0602
@@ -25,6 +25,8 @@
2525
<BaseTsd.h>. */
2626
# define ssize_t SSIZE_T
2727

28+
/* On program startup, the integer file descriptors associated with the streams
29+
stdin, stdout, and stderr are 0, 1, and 2. */
2830
# define STDIN_FILENO 0
2931
# define STDOUT_FILENO 1
3032
# define STDERR_FILENO 2
@@ -249,7 +251,9 @@
249251
/* Define to 1 if you have the 'lchown' function. */
250252
#cmakedefine HAVE_LCHOWN 1
251253

252-
/* Define to 1 if you have the 'dl' library (-ldl). */
254+
/* Define to 1 if system has some form of loading functions, such as dlopen()
255+
and other functions, for example, via the 'dl' library (-ldl), or
256+
LoadLibrary(), for example, on Windows. */
253257
#cmakedefine HAVE_LIBDL 1
254258

255259
/* Define to 1 if you have the <linux/sock_diag.h> header file. */

cmake/win32/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,26 @@ target_link_libraries(php_windows PRIVATE PHP::config)
7878
target_compile_definitions(
7979
php_config
8080
INTERFACE
81+
# Marks that target system is Windows. For PHP code.
82+
PHP_WIN32
83+
84+
# This preprocessor macro is also defined by all compilers when targeting
85+
# Windows. It is left here to match the native PHP Windows build system.
86+
_WIN32
87+
88+
# This preprocessor macro is also defined by Windows SDK and some compilers
89+
# (GCC and Clang) when targeting Windows. Left here for BC for possible PECL
90+
# extensions not being updated yet. In new code it is being replaced with
91+
# _WIN32.
92+
WIN32
93+
94+
# For Zend Engine, same as PHP_WIN32.
95+
ZEND_WIN32
96+
8197
_MBCS
8298
_USE_MATH_DEFINES
8399
PHP_EXPORTS
100+
84101
# The time_t defaults to 64-bit. Force 32-bit time_t on 32-bit architecture.
85102
# This was historically added to PHP as Visual Studio 2005 set 64-bit time_t
86103
# by default and it would break 3rdParty libs that were built with older

0 commit comments

Comments
 (0)