@@ -42,6 +42,21 @@ set(PHP_C_STANDARD_LIBRARY "" CACHE INTERNAL "The C standard library.")
4242
4343message (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 ()
101116endif ()
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.
116120cmake_push_check_state(RESET)
0 commit comments