Skip to content

Commit b04c86e

Browse files
committed
PHP/StandardLibrary: Move mscrt library check to speed up Windows build
1 parent f753d29 commit b04c86e

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

cmake/cmake/modules/PHP/StandardLibrary.cmake

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ set(PHP_C_STANDARD_LIBRARY "" CACHE INTERNAL "The C standard library.")
4242

4343
message(CHECK_START "Checking C standard library")
4444

45+
# The MS C runtime library (CRT).
46+
if(MSVC)
47+
set(_PHP_C_STANDARD_LIBRARY_MSCRT TRUE)
48+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
49+
cmake_push_check_state(RESET)
50+
set(CMAKE_REQUIRED_QUIET TRUE)
51+
check_symbol_exists(_MSC_VER stdio.h _PHP_C_STANDARD_LIBRARY_MSCRT)
52+
cmake_pop_check_state()
53+
endif()
54+
if(_PHP_C_STANDARD_LIBRARY_MSCRT)
55+
set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "mscrt")
56+
message(CHECK_PASS "MS C runtime library (CRT)")
57+
return()
58+
endif()
59+
4560
# The uClibc and its maintained fork uClibc-ng behave like minimalistic GNU C
4661
# library but have differences. They can be determined by the __UCLIBC__ symbol
4762
# and must be checked first because they also define the __GLIBC__ symbol.
@@ -100,17 +115,6 @@ if(_PHP_C_STANDARD_LIBRARY_LLVM)
100115
return()
101116
endif()
102117

103-
# The MS C runtime library (CRT).
104-
cmake_push_check_state(RESET)
105-
set(CMAKE_REQUIRED_QUIET TRUE)
106-
check_symbol_exists(_MSC_VER stdio.h _PHP_C_STANDARD_LIBRARY_MSCRT)
107-
cmake_pop_check_state()
108-
if(_PHP_C_STANDARD_LIBRARY_MSCRT)
109-
set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "mscrt")
110-
message(CHECK_PASS "MS C runtime library (CRT)")
111-
return()
112-
endif()
113-
114118
# The musl libc doesn't advertise itself with symbols, so it must be determined
115119
# heuristically.
116120
cmake_push_check_state(RESET)

0 commit comments

Comments
 (0)