diff --git a/cmake/Zend/cmake/CheckDlsym.cmake b/cmake/Zend/cmake/CheckDlsym.cmake index df223412f..ae1c32c43 100644 --- a/cmake/Zend/cmake/CheckDlsym.cmake +++ b/cmake/Zend/cmake/CheckDlsym.cmake @@ -7,15 +7,18 @@ Some non-ELF platforms, such as OpenBSD, FreeBSD, NetBSD, Mac OSX (~10.3), needed underscore character (`_`) prefix for symbols, when using `dlsym()`. This module is obsolete on current platforms. -## Result variables +## Cache variables * `DLSYM_NEEDS_UNDERSCORE` - - Whether `dlsym()` requires a leading underscore in symbol names. #]=============================================================================] include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED DLSYM_NEEDS_UNDERSCORE) + return() +endif() + include(CheckIncludeFile) message( @@ -112,9 +115,17 @@ block() ) endblock() +set( + DLSYM_NEEDS_UNDERSCORE + "" + CACHE INTERNAL + "Whether 'dlsym()' requires a leading underscore in symbol names." +) + if(DLSYM_NEEDS_UNDERSCORE_COMPILED AND DLSYM_NEEDS_UNDERSCORE_EXITCODE EQUAL 2) - set(DLSYM_NEEDS_UNDERSCORE TRUE) + set_property(CACHE DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE TRUE) message(CHECK_PASS "yes") else() + set_property(CACHE DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE FALSE) message(CHECK_FAIL "no") endif() diff --git a/cmake/Zend/cmake/CheckGlobalRegisterVariables.cmake b/cmake/Zend/cmake/CheckGlobalRegisterVariables.cmake index a134518be..bae908fee 100644 --- a/cmake/Zend/cmake/CheckGlobalRegisterVariables.cmake +++ b/cmake/Zend/cmake/CheckGlobalRegisterVariables.cmake @@ -16,6 +16,11 @@ See also: [GCC global register variables](https://gcc.gnu.org/onlinedocs/gcc/Glo include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED HAVE_GCC_GLOBAL_REGS) + return() +endif() + include(CheckSourceCompiles) include(CMakePushCheckState) diff --git a/cmake/Zend/cmake/CheckStackDirection.cmake b/cmake/Zend/cmake/CheckStackDirection.cmake index a8ce5d167..3517c9e4f 100644 --- a/cmake/Zend/cmake/CheckStackDirection.cmake +++ b/cmake/Zend/cmake/CheckStackDirection.cmake @@ -12,6 +12,11 @@ Check whether the stack grows downwards. Assumes contiguous stack. include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED ZEND_CHECK_STACK_LIMIT) + return() +endif() + include(CheckSourceRuns) include(CMakePushCheckState) diff --git a/cmake/Zend/cmake/Fibers.cmake b/cmake/Zend/cmake/Fibers.cmake index 246d4db9f..fb1055dcc 100644 --- a/cmake/Zend/cmake/Fibers.cmake +++ b/cmake/Zend/cmake/Fibers.cmake @@ -35,30 +35,32 @@ include(CMakePushCheckState) add_library(zend_fibers INTERFACE) add_library(Zend::Fibers ALIAS zend_fibers) -message(CHECK_START "Whether syscall to create shadow stack exists") -cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_QUIET TRUE) - - check_source_runs(C [[ - #include - #include - int main(void) - { - void* base = (void *)syscall(451, 0, 0x20000, 0x1); - if (base != (void*)-1) { - munmap(base, 0x20000); - return 0; +if(NOT DEFINED SHADOW_STACK_SYSCALL) + message(CHECK_START "Whether syscall to create shadow stack exists") + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_QUIET TRUE) + + check_source_runs(C [[ + #include + #include + int main(void) + { + void* base = (void *)syscall(451, 0, 0x20000, 0x1); + if (base != (void*)-1) { + munmap(base, 0x20000); + return 0; + } + return 1; } - return 1; - } - ]] SHADOW_STACK_SYSCALL) -cmake_pop_check_state() -if(SHADOW_STACK_SYSCALL) - message(CHECK_PASS "yes") -else() - # If the syscall doesn't exist, we may block the final ELF from - # __PROPERTY_SHSTK via redefine macro as "-D__CET__=1". - message(CHECK_FAIL "no") + ]] SHADOW_STACK_SYSCALL) + cmake_pop_check_state() + if(SHADOW_STACK_SYSCALL) + message(CHECK_PASS "yes") + else() + # If the syscall doesn't exist, we may block the final ELF from + # __PROPERTY_SHSTK via redefine macro as "-D__CET__=1". + message(CHECK_FAIL "no") + endif() endif() block() diff --git a/cmake/Zend/cmake/MaxExecutionTimers.cmake b/cmake/Zend/cmake/MaxExecutionTimers.cmake index b540ddd96..3f05bab7d 100644 --- a/cmake/Zend/cmake/MaxExecutionTimers.cmake +++ b/cmake/Zend/cmake/MaxExecutionTimers.cmake @@ -16,7 +16,7 @@ Check whether to enable Zend max execution timers. * `ZEND_MAX_EXECUTION_TIMERS` A local variable based on the cache variable and thread safety to be able to - run consecutive configuration runs. When `ZEND_MAX_EXECUTION_TIMERS` cache + run consecutive configuration phases. When `ZEND_MAX_EXECUTION_TIMERS` cache variable is set to 'auto', local variable default value is set to the `PHP_THREAD_SAFETY` value. diff --git a/cmake/cmake/ConfigureChecks.cmake b/cmake/cmake/ConfigureChecks.cmake index 769637781..71711d3e0 100644 --- a/cmake/cmake/ConfigureChecks.cmake +++ b/cmake/cmake/ConfigureChecks.cmake @@ -138,8 +138,10 @@ cmake_pop_check_state() check_type_size("gid_t" SIZEOF_GID_T) if(NOT HAVE_SIZEOF_GID_T) set( - gid_t int - CACHE INTERNAL "Define as 'int' if doesn't define." + gid_t + int + CACHE INTERNAL + "Define as 'int' if not defined in ." ) endif() @@ -204,8 +206,10 @@ endif() check_type_size("uid_t" SIZEOF_UID_T) if(NOT HAVE_SIZEOF_UID_T) set( - uid_t int - CACHE INTERNAL "Define as 'int' if doesn't define." + uid_t + int + CACHE INTERNAL + "Define as 'int' if not defined in ." ) endif() @@ -438,9 +442,7 @@ endif() include(PHP/CheckByteOrder) # Check for IPv6 support. -if(PHP_IPV6) - include(PHP/CheckIPv6) -endif() +include(PHP/CheckIPv6) # Check how flush should be called. include(PHP/CheckFlushIo) diff --git a/cmake/cmake/modules/FindACL.cmake b/cmake/cmake/modules/FindACL.cmake index 571571245..79493daa9 100644 --- a/cmake/cmake/modules/FindACL.cmake +++ b/cmake/cmake/modules/FindACL.cmake @@ -125,8 +125,10 @@ if(NOT DEFINED ACL_IS_BUILT_IN) if(_acl_works) set( - ACL_IS_BUILT_IN TRUE - CACHE INTERNAL "Whether ACL is a part of the C library" + ACL_IS_BUILT_IN + TRUE + CACHE INTERNAL + "Whether ACL is a part of the C library." ) else() set(ACL_IS_BUILT_IN FALSE) diff --git a/cmake/cmake/modules/PHP/Bison.cmake b/cmake/cmake/modules/PHP/Bison.cmake index 1321c92f4..1717ee1d7 100644 --- a/cmake/cmake/modules/PHP/Bison.cmake +++ b/cmake/cmake/modules/PHP/Bison.cmake @@ -288,14 +288,14 @@ function(php_bison name input output) _php_bison_config() + # Skip consecutive find_package() calls when: + # - project calls php_bison() multiple times and Bison will be downloaded + # - the outer find_package() was called prior to php_bison() + # - running consecutive configuration phases and Bison will be downloaded if( - # Skip consecutive find_package() calls when: - # - project calls php_bison() multiple times and Bison will be downloaded: NOT TARGET Bison::Bison - # - the outer find_package() was called prior to php_bison(): AND NOT DEFINED BISON_FOUND - # - running consecutive configuration phases: - AND NOT BISON_EXECUTABLE + AND NOT _PHP_BISON_DOWNLOAD ) find_package(BISON ${PHP_BISON_VERSION} ${quiet}) endif() @@ -650,5 +650,12 @@ function(_php_bison_download) get_property(packagesFound GLOBAL PROPERTY PACKAGES_FOUND) set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND BISON) + set( + _PHP_BISON_DOWNLOAD + TRUE + CACHE INTERNAL + "Internal marker whether the Bison will be downloaded." + ) + return(PROPAGATE BISON_FOUND BISON_VERSION) endfunction() diff --git a/cmake/cmake/modules/PHP/CheckAVX512.cmake b/cmake/cmake/modules/PHP/CheckAVX512.cmake index 17649b8ee..a86632740 100644 --- a/cmake/cmake/modules/PHP/CheckAVX512.cmake +++ b/cmake/cmake/modules/PHP/CheckAVX512.cmake @@ -20,6 +20,11 @@ TODO: Adjust checks for MSVC. include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED PHP_HAVE_AVX512_SUPPORTS AND DEFINED PHP_HAVE_AVX512_VBMI_SUPPORTS) + return() +endif() + include(CheckSourceCompiles) include(CMakePushCheckState) diff --git a/cmake/cmake/modules/PHP/CheckAttribute.cmake b/cmake/cmake/modules/PHP/CheckAttribute.cmake index 991ded3af..1cbbdde28 100644 --- a/cmake/cmake/modules/PHP/CheckAttribute.cmake +++ b/cmake/cmake/modules/PHP/CheckAttribute.cmake @@ -103,6 +103,11 @@ function(_php_check_attribute what attribute result) message(FATAL_ERROR "Wrong argument passed: ${what}") endif() + # Skip in consecutive configuration phases. + if(DEFINED ${result}) + return() + endif() + message(CHECK_START "Checking for ${what} attribute ${attribute}") cmake_push_check_state(RESET) diff --git a/cmake/cmake/modules/PHP/CheckBrokenGccStrlenOpt.cmake b/cmake/cmake/modules/PHP/CheckBrokenGccStrlenOpt.cmake index ca22b4e41..65833b801 100644 --- a/cmake/cmake/modules/PHP/CheckBrokenGccStrlenOpt.cmake +++ b/cmake/cmake/modules/PHP/CheckBrokenGccStrlenOpt.cmake @@ -15,6 +15,11 @@ See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914 include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED PHP_HAVE_BROKEN_OPTIMIZE_STRLEN) + return() +endif() + include(CheckSourceRuns) include(CMakePushCheckState) diff --git a/cmake/cmake/modules/PHP/CheckBuiltin.cmake b/cmake/cmake/modules/PHP/CheckBuiltin.cmake index 1060ca457..fb0ef975a 100644 --- a/cmake/cmake/modules/PHP/CheckBuiltin.cmake +++ b/cmake/cmake/modules/PHP/CheckBuiltin.cmake @@ -27,6 +27,11 @@ include(CheckSourceCompiles) include(CMakePushCheckState) function(php_check_builtin builtin result) + # Skip in consecutive configuration phases. + if(DEFINED ${result}) + return() + endif() + message(CHECK_START "Checking for ${builtin}") if(builtin STREQUAL "__builtin_clz") diff --git a/cmake/cmake/modules/PHP/CheckByteOrder.cmake b/cmake/cmake/modules/PHP/CheckByteOrder.cmake index 6a07a0d5e..913b5d598 100644 --- a/cmake/cmake/modules/PHP/CheckByteOrder.cmake +++ b/cmake/cmake/modules/PHP/CheckByteOrder.cmake @@ -10,14 +10,30 @@ Check whether system byte ordering is big-endian. include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED WORDS_BIGENDIAN) + return() +endif() + include(CheckSourceRuns) message(CHECK_START "Checking byte ordering") if(CMAKE_C_BYTE_ORDER STREQUAL "BIG_ENDIAN") message(CHECK_PASS "big-endian") - set(WORDS_BIGENDIAN TRUE CACHE INTERNAL "Whether byte ordering is big-endian.") + set( + WORDS_BIGENDIAN + TRUE + CACHE INTERNAL + "Whether byte ordering is big-endian." + ) elseif(CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN") + set( + WORDS_BIGENDIAN + FALSE + CACHE INTERNAL + "Whether byte ordering is big-endian." + ) message(CHECK_PASS "little-endian") else() if( diff --git a/cmake/cmake/modules/PHP/CheckCompilerFlag.cmake b/cmake/cmake/modules/PHP/CheckCompilerFlag.cmake index d64b49a03..d2992cbea 100644 --- a/cmake/cmake/modules/PHP/CheckCompilerFlag.cmake +++ b/cmake/cmake/modules/PHP/CheckCompilerFlag.cmake @@ -65,6 +65,11 @@ function(php_check_compiler_flag lang flag result) message(FATAL_ERROR "Missing arguments.") endif() + # Skip in consecutive configuration phases. + if(DEFINED ${result}) + return() + endif() + if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Checking whether the ${lang} compiler accepts ${flag}") endif() diff --git a/cmake/cmake/modules/PHP/CheckCopyFileRange.cmake b/cmake/cmake/modules/PHP/CheckCopyFileRange.cmake index d8c0b6c37..a64e75e0c 100644 --- a/cmake/cmake/modules/PHP/CheckCopyFileRange.cmake +++ b/cmake/cmake/modules/PHP/CheckCopyFileRange.cmake @@ -14,6 +14,11 @@ only on Linux. include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED HAVE_COPY_FILE_RANGE) + return() +endif() + include(CheckSourceCompiles) include(CMakePushCheckState) diff --git a/cmake/cmake/modules/PHP/CheckFlushIo.cmake b/cmake/cmake/modules/PHP/CheckFlushIo.cmake index 4867d6c51..45237e964 100644 --- a/cmake/cmake/modules/PHP/CheckFlushIo.cmake +++ b/cmake/cmake/modules/PHP/CheckFlushIo.cmake @@ -6,12 +6,15 @@ Check if flush should be called explicitly after buffered io. ## Cache variables * `HAVE_FLUSHIO` - - Whether flush should be called explicitly after a buffered io. #]=============================================================================] include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED HAVE_FLUSHIO) + return() +endif() + include(CheckIncludeFile) include(CheckSourceRuns) include(CMakePushCheckState) @@ -22,7 +25,12 @@ message(CHECK_START if(CMAKE_SYSTEM_NAME STREQUAL "Windows") message(CHECK_FAIL "no") - set(HAVE_FLUSHIO FALSE CACHE INTERNAL "") + set( + HAVE_FLUSHIO + FALSE + CACHE INTERNAL + "Whether flush should be called explicitly after a buffered io." + ) return() endif() diff --git a/cmake/cmake/modules/PHP/CheckFopencookie.cmake b/cmake/cmake/modules/PHP/CheckFopencookie.cmake index 4bd2add61..f42285c17 100644 --- a/cmake/cmake/modules/PHP/CheckFopencookie.cmake +++ b/cmake/cmake/modules/PHP/CheckFopencookie.cmake @@ -47,6 +47,11 @@ if(NOT HAVE_FOPENCOOKIE) return() endif() +# Skip in consecutive configuration phases. +if(DEFINED COOKIE_SEEKER_USES_OFF64_T) + return() +endif() + # GNU C library can have a different seeker definition using off64_t. message(CHECK_START "Checking whether fopencookie seeker uses off64_t") diff --git a/cmake/cmake/modules/PHP/CheckIPv6.cmake b/cmake/cmake/modules/PHP/CheckIPv6.cmake index bb503f3cd..b5266884c 100644 --- a/cmake/cmake/modules/PHP/CheckIPv6.cmake +++ b/cmake/cmake/modules/PHP/CheckIPv6.cmake @@ -3,20 +3,25 @@ Check for IPv6 support. -## Cache variables +## Result variables * `HAVE_IPV6` - Whether IPv6 support is enabled. + Whether IPv6 support is supported and enabled. #]=============================================================================] -include_guard(GLOBAL) - include(CheckSourceCompiles) include(CMakePushCheckState) +set(HAVE_IPV6 FALSE) + message(CHECK_START "Checking for IPv6 support") +if(NOT PHP_IPV6) + message(CHECK_FAIL "no") + return() +endif() + cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) @@ -36,10 +41,11 @@ cmake_push_check_state(RESET) return 0; } - ]] HAVE_IPV6) + ]] _PHP_HAVE_IPV6) cmake_pop_check_state() -if(HAVE_IPV6) +if(_PHP_HAVE_IPV6) + set(HAVE_IPV6 TRUE) message(CHECK_PASS "yes") else() message(CHECK_FAIL "no") diff --git a/cmake/cmake/modules/PHP/CheckInline.cmake b/cmake/cmake/modules/PHP/CheckInline.cmake index c6f6f4fed..1c2e5e63b 100644 --- a/cmake/cmake/modules/PHP/CheckInline.cmake +++ b/cmake/cmake/modules/PHP/CheckInline.cmake @@ -80,7 +80,7 @@ if(NOT INLINE_KEYWORD_DEFINITION) INLINE_KEYWORD_DEFINITION "${INLINE_STRING}" CACHE INTERNAL - "Compiler inline keyword definition" + "Compiler inline keyword definition." ) unset(INLINE_STRING) diff --git a/cmake/cmake/modules/PHP/CheckReentrantFunctions.cmake b/cmake/cmake/modules/PHP/CheckReentrantFunctions.cmake index 33bfbd32d..75276a326 100644 --- a/cmake/cmake/modules/PHP/CheckReentrantFunctions.cmake +++ b/cmake/cmake/modules/PHP/CheckReentrantFunctions.cmake @@ -30,8 +30,6 @@ functions on current systems and this module might be obsolete in the future. Whether `strtok_r()` is available. -## Result variables - * `MISSING_ASCTIME_R_DECL` Whether `asctime_r()` is not declared. @@ -64,6 +62,10 @@ include(CMakePushCheckState) function(_php_check_reentrant_function symbol header) string(TOUPPER "${symbol}" const) + if(DEFINED PHP_HAVE_DECL_${const}) + return() + endif() + # Check if linker sees the function. check_function_exists(${symbol} HAVE_${const}) @@ -76,11 +78,18 @@ function(_php_check_reentrant_function symbol header) if(NOT PHP_HAVE_DECL_${const}) message(CHECK_FAIL "missing") - - set(MISSING_${const}_DECL TRUE) + set(isMissing TRUE) else() message(CHECK_PASS "found") + set(isMissing FALSE) endif() + + set( + MISSING_${const}_DECL + ${isMissing} + CACHE INTERNAL + "Whether the ${symbol}() is not declared." + ) endfunction() _php_check_reentrant_function(asctime_r time.h) diff --git a/cmake/cmake/modules/PHP/CheckSysMacros.cmake b/cmake/cmake/modules/PHP/CheckSysMacros.cmake index 54c3fc94e..001872e62 100644 --- a/cmake/cmake/modules/PHP/CheckSysMacros.cmake +++ b/cmake/cmake/modules/PHP/CheckSysMacros.cmake @@ -64,6 +64,11 @@ int main(void) include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED _PHP_HAVE_SYS_MACROS_CHECKED) + return() +endif() + include(CheckIncludeFile) include(CheckSymbolExists) @@ -96,3 +101,10 @@ if(HAVE_MAKEDEV) else() message(CHECK_FAIL "not found") endif() + +set( + _PHP_HAVE_SYS_MACROS_CHECKED + TRUE + CACHE INTERNAL + "Internal marker whether 'major', 'minor' and 'makedev' have been checked." +) diff --git a/cmake/cmake/modules/PHP/CheckTimeR.cmake b/cmake/cmake/modules/PHP/CheckTimeR.cmake index 8dc00036b..ba5e5a8c6 100644 --- a/cmake/cmake/modules/PHP/CheckTimeR.cmake +++ b/cmake/cmake/modules/PHP/CheckTimeR.cmake @@ -17,6 +17,11 @@ POSIX. include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED PHP_HPUX_TIME_R OR DEFINED PHP_IRIX_TIME_R) + return() +endif() + include(CheckSourceRuns) message(CHECK_START "Checking type of reentrant time-related functions") diff --git a/cmake/cmake/modules/PHP/CheckWrite.cmake b/cmake/cmake/modules/PHP/CheckWrite.cmake index 967bb2852..d65328efa 100644 --- a/cmake/cmake/modules/PHP/CheckWrite.cmake +++ b/cmake/cmake/modules/PHP/CheckWrite.cmake @@ -12,6 +12,11 @@ Check whether writing to stdout works. include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED PHP_WRITE_STDOUT) + return() +endif() + include(CheckIncludeFile) include(CheckSourceRuns) include(CMakePushCheckState) diff --git a/cmake/cmake/modules/PHP/Extensions.cmake b/cmake/cmake/modules/PHP/Extensions.cmake index a9013dd93..ef9c961f5 100644 --- a/cmake/cmake/modules/PHP/Extensions.cmake +++ b/cmake/cmake/modules/PHP/Extensions.cmake @@ -503,10 +503,11 @@ function(php_extensions_configure_headers) file(READ ${binaryDir}/config.h current) endif() - string(STRIP "${template}\n${current}" config) - # Finalize extension's config.h header file. - file(CONFIGURE OUTPUT ${binaryDir}/config.h CONTENT "${config}\n") + if(NOT current MATCHES "(#undef|#define) ${macro}") + string(STRIP "${template}\n${current}" config) + file(CONFIGURE OUTPUT ${binaryDir}/config.h CONTENT "${config}\n") + endif() endforeach() endfunction() diff --git a/cmake/cmake/modules/PHP/Re2c.cmake b/cmake/cmake/modules/PHP/Re2c.cmake index fcc77e036..81ca4859f 100644 --- a/cmake/cmake/modules/PHP/Re2c.cmake +++ b/cmake/cmake/modules/PHP/Re2c.cmake @@ -296,14 +296,14 @@ function(php_re2c name input output) _php_re2c_config() + # Skip consecutive find_package() calls when: + # - project calls php_re2c() multiple times and re2c will be downloaded + # - the outer find_package() was called prior to php_re2c() + # - running consecutive configuration phases and re2c will be downloaded if( - # Skip consecutive find_package() calls when: - # - project calls php_re2c() multiple times and re2c will be downloaded: NOT TARGET RE2C::RE2C - # - the outer find_package() was called prior to php_re2c(): AND NOT DEFINED RE2C_FOUND - # - running consecutive configuration phases: - AND NOT RE2C_EXECUTABLE + AND NOT _PHP_RE2C_DOWNLOAD ) find_package(RE2C ${PHP_RE2C_VERSION} ${quiet}) endif() @@ -653,5 +653,12 @@ function(_php_re2c_download) get_property(packagesFound GLOBAL PROPERTY PACKAGES_FOUND) set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND RE2C) + set( + _PHP_RE2C_DOWNLOAD + TRUE + CACHE INTERNAL + "Internal marker whether the re2c will be downloaded." + ) + return(PROPAGATE RE2C_FOUND RE2C_VERSION) endfunction() diff --git a/cmake/cmake/modules/PHP/SearchLibraries.cmake b/cmake/cmake/modules/PHP/SearchLibraries.cmake index 962f9d5d2..3662e30e6 100644 --- a/cmake/cmake/modules/PHP/SearchLibraries.cmake +++ b/cmake/cmake/modules/PHP/SearchLibraries.cmake @@ -325,8 +325,10 @@ function(php_search_libraries) # Store found library in a cache variable for internal purpose. set( - ${libraryInternalVariable} ${library} - CACHE INTERNAL "Library required to use '${symbol}'." + ${libraryInternalVariable} + ${library} + CACHE INTERNAL + "Library required to use '${symbol}'." ) _php_search_libraries_populate() diff --git a/cmake/cmake/modules/PHP/StandardLibrary.cmake b/cmake/cmake/modules/PHP/StandardLibrary.cmake index c9afdb997..7def6c8e2 100644 --- a/cmake/cmake/modules/PHP/StandardLibrary.cmake +++ b/cmake/cmake/modules/PHP/StandardLibrary.cmake @@ -3,7 +3,7 @@ Determine the C standard library used for the build. -## Result variables +## Cache variables * `PHP_C_STANDARD_LIBRARY` @@ -16,14 +16,22 @@ Determine the C standard library used for the build. * `musl` * `uclibc` -* `__MUSL__` - Whether C standard library is musl. + If library cannot be determined, it is set to empty string. + +* `__MUSL__` - Whether the C standard library is musl. #]=============================================================================] include_guard(GLOBAL) +if(DEFINED PHP_C_STANDARD_LIBRARY) + return() +endif() + include(CheckSymbolExists) include(CMakePushCheckState) +set(PHP_C_STANDARD_LIBRARY "" CACHE INTERNAL "The C standard library.") + message(CHECK_START "Checking C standard library") # The uClibc and its maintained fork uClibc-ng behave like minimalistic GNU C @@ -34,7 +42,7 @@ cmake_push_check_state(RESET) check_symbol_exists(__UCLIBC__ features.h _PHP_C_STANDARD_LIBRARY_UCLIBC) cmake_pop_check_state() if(_PHP_C_STANDARD_LIBRARY_UCLIBC) - set(PHP_C_STANDARD_LIBRARY "uclibc") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "uclibc") message(CHECK_PASS "uClibc") return() endif() @@ -45,7 +53,7 @@ cmake_push_check_state(RESET) check_symbol_exists(__dietlibc__ features.h _PHP_C_STANDARD_LIBRARY_DIETLIBC) cmake_pop_check_state() if(_PHP_C_STANDARD_LIBRARY_DIETLIBC) - set(PHP_C_STANDARD_LIBRARY "dietlibc") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "dietlibc") message(CHECK_PASS "diet libc") return() endif() @@ -57,7 +65,7 @@ cmake_push_check_state(RESET) check_symbol_exists(__GLIBC__ features.h _PHP_C_STANDARD_LIBRARY_GLIBC) cmake_pop_check_state() if(_PHP_C_STANDARD_LIBRARY_GLIBC) - set(PHP_C_STANDARD_LIBRARY "glibc") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "glibc") message(CHECK_PASS "GNU C (glibc)") return() endif() @@ -68,7 +76,7 @@ cmake_push_check_state(RESET) check_symbol_exists(__LLVM_LIBC__ features.h _PHP_C_STANDARD_LIBRARY_LLVM) cmake_pop_check_state() if(_PHP_C_STANDARD_LIBRARY_LLVM) - set(PHP_C_STANDARD_LIBRARY "llvm") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "llvm") message(CHECK_PASS "LLVM libc") return() endif() @@ -79,7 +87,7 @@ cmake_push_check_state(RESET) check_symbol_exists(_MSC_VER stdio.h _PHP_C_STANDARD_LIBRARY_MSCRT) cmake_pop_check_state() if(_PHP_C_STANDARD_LIBRARY_MSCRT) - set(PHP_C_STANDARD_LIBRARY "mscrt") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "mscrt") message(CHECK_PASS "MS C runtime library (CRT)") return() endif() @@ -91,10 +99,10 @@ cmake_push_check_state(RESET) check_symbol_exists(__DEFINED_va_list stdarg.h _PHP_C_STANDARD_LIBRARY_MUSL) cmake_pop_check_state() if(_PHP_C_STANDARD_LIBRARY_MUSL) - set(PHP_C_STANDARD_LIBRARY "musl") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "musl") else() # Otherwise, try determining musl libc with ldd. - block(PROPAGATE PHP_C_STANDARD_LIBRARY) + block() execute_process( COMMAND ldd --version OUTPUT_VARIABLE version @@ -103,12 +111,12 @@ else() ) if(version MATCHES ".*musl libc.*") - set(PHP_C_STANDARD_LIBRARY "musl") + set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "musl") endif() endblock() endif() if(PHP_C_STANDARD_LIBRARY STREQUAL "musl") - set(__MUSL__ TRUE) + set(__MUSL__ TRUE CACHE INTERNAL "Whether the C standard library is musl.") message(CHECK_PASS "musl") return() endif() diff --git a/cmake/cmake/modules/PHP/SystemExtensions.cmake b/cmake/cmake/modules/PHP/SystemExtensions.cmake index 1ef2ace74..5f21de625 100644 --- a/cmake/cmake/modules/PHP/SystemExtensions.cmake +++ b/cmake/cmake/modules/PHP/SystemExtensions.cmake @@ -85,7 +85,11 @@ string(APPEND CMAKE_C_FLAGS " -D=1 ")` # Set configuration header code for consecutive module inclusions, if needed. if(NOT PHP_SYSTEM_EXTENSIONS_CODE) - get_property(PHP_SYSTEM_EXTENSIONS_CODE GLOBAL PROPERTY _PHP_SYSTEM_EXTENSIONS_CODE) + get_property( + PHP_SYSTEM_EXTENSIONS_CODE + GLOBAL + PROPERTY _PHP_SYSTEM_EXTENSIONS_CODE + ) endif() include_guard(GLOBAL) diff --git a/cmake/ext/session/cmake/CheckPreadPwrite.cmake b/cmake/ext/session/cmake/CheckPreadPwrite.cmake index db4b3121b..a7c4fc8a2 100644 --- a/cmake/ext/session/cmake/CheckPreadPwrite.cmake +++ b/cmake/ext/session/cmake/CheckPreadPwrite.cmake @@ -34,6 +34,11 @@ check_symbol_exists( unistd.h HAVE_) include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED _PHP_HAVE_PREAD AND DEFINED _PHP_HAVE_PWRITE) + return() +endif() + include(CheckFunctionExists) include(CheckSourceRuns) include(CMakePushCheckState) @@ -49,10 +54,10 @@ function(_php_check_pread) # Check if linker sees the pread(). cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) - check_function_exists(pread _HAVE_PREAD) + check_function_exists(pread _PHP_HAVE_PREAD) cmake_pop_check_state() - if(NOT _HAVE_PREAD) + if(NOT _PHP_HAVE_PREAD) message(CHECK_FAIL "no (not found)") return() endif() @@ -136,7 +141,7 @@ function(_php_check_pread) cmake_pop_check_state() if(PHP_PREAD_64) - set(HAVE_PREAD TRUE CACHE INTERNAL "Whether pread() works") + set(HAVE_PREAD TRUE CACHE INTERNAL "Whether pread() works.") endif() endif() @@ -157,10 +162,10 @@ function(_php_check_pwrite) # Check if linker sees the pwrite(). cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) - check_function_exists(pwrite _HAVE_PWRITE) + check_function_exists(pwrite _PHP_HAVE_PWRITE) cmake_pop_check_state() - if(NOT _HAVE_PWRITE) + if(NOT _PHP_HAVE_PWRITE) message(CHECK_FAIL "no (not found)") return() endif() @@ -243,7 +248,7 @@ function(_php_check_pwrite) cmake_pop_check_state() if(PHP_PWRITE_64) - set(HAVE_PWRITE TRUE CACHE INTERNAL "Whether pwrite() works") + set(HAVE_PWRITE TRUE CACHE INTERNAL "Whether pwrite() works.") endif() endif() diff --git a/cmake/ext/standard/cmake/CheckCrypt.cmake b/cmake/ext/standard/cmake/CheckCrypt.cmake index b225b837a..d2540cc7d 100644 --- a/cmake/ext/standard/cmake/CheckCrypt.cmake +++ b/cmake/ext/standard/cmake/CheckCrypt.cmake @@ -133,8 +133,10 @@ function(_php_check_crypt_r result) if(CRYPT_R_GNU_SOURCE) set( - CRYPT_R_STRUCT_CRYPT_DATA TRUE - CACHE INTERNAL "Define if crypt_r uses struct crypt_data" + CRYPT_R_STRUCT_CRYPT_DATA + TRUE + CACHE INTERNAL + "Whether 'crypt_r()' uses 'struct crypt_data'." ) message(CHECK_PASS "GNU struct crypt_data") @@ -157,8 +159,10 @@ function(_php_check_crypt_r result) if(_CRYPT_R_STRUCT_CRYPT_DATA) set( - CRYPT_R_STRUCT_CRYPT_DATA TRUE - CACHE INTERNAL "Define if crypt_r uses struct crypt_data" + CRYPT_R_STRUCT_CRYPT_DATA + TRUE + CACHE INTERNAL + "Whether 'crypt_r()' uses 'struct crypt_data'." ) message(CHECK_PASS "struct crypt_data") diff --git a/cmake/ext/standard/cmake/CheckFclose.cmake b/cmake/ext/standard/cmake/CheckFclose.cmake index 6b105ed0e..499ca3017 100644 --- a/cmake/ext/standard/cmake/CheckFclose.cmake +++ b/cmake/ext/standard/cmake/CheckFclose.cmake @@ -6,13 +6,16 @@ like SunOS has. This check is obsolete on current Solaris/illumos versions. ## Result variables -* MISSING_FCLOSE_DECL - - Whether `fclose` declaration is missing. +* `MISSING_FCLOSE_DECL` #]=============================================================================] include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED MISSING_FCLOSE_DECL) + return() +endif() + include(CheckSymbolExists) include(CMakePushCheckState) @@ -21,12 +24,20 @@ message(CHECK_START "Checking fclose declaration") # Checking if symbol exists also checks if it is declared. cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) - check_symbol_exists(fclose stdio.h _HAVE_FCLOSE) + check_symbol_exists(fclose stdio.h _PHP_HAVE_FCLOSE) cmake_pop_check_state() -if(NOT _HAVE_FCLOSE) - message(CHECK_FAIL "missing") - set(MISSING_FCLOSE_DECL TRUE) -else() +set( + MISSING_FCLOSE_DECL + "" + CACHE INTERNAL + "Whether the 'fclose()' declaration is missing." +) + +if(_PHP_HAVE_FCLOSE) message(CHECK_PASS "found") + set_property(CACHE MISSING_FCLOSE_DECL PROPERTY VALUE FALSE) +else() + message(CHECK_FAIL "missing") + set_property(CACHE MISSING_FCLOSE_DECL PROPERTY VALUE TRUE) endif() diff --git a/cmake/ext/standard/cmake/CheckFnmatch.cmake b/cmake/ext/standard/cmake/CheckFnmatch.cmake index 5191605fb..a57463b0d 100644 --- a/cmake/ext/standard/cmake/CheckFnmatch.cmake +++ b/cmake/ext/standard/cmake/CheckFnmatch.cmake @@ -19,6 +19,11 @@ https://www.gnu.org/software/gnulib/MODULES.html#module=fnmatch include_guard(GLOBAL) +# Skip in consecutive configuration phases. +if(DEFINED HAVE_FNMATCH) + return() +endif() + include(CheckSourceRuns) include(CMakePushCheckState)