diff --git a/cmake/cmake/modules/FindRE2C.cmake b/cmake/cmake/modules/FindRE2C.cmake index 9717e139..54478c50 100644 --- a/cmake/cmake/modules/FindRE2C.cmake +++ b/cmake/cmake/modules/FindRE2C.cmake @@ -156,17 +156,17 @@ if(RE2C_USE_COMPUTED_GOTOS) cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) - check_source_compiles(C " - int main(int argc, const char **argv) { - argc = argc; - argv = argv; + check_source_compiles(C [[ + int main(void) { label1: + ; label2: - static void *adr[] = { &&label1, &&label2}; + ; + static void *adr[] = { &&label1, &&label2 }; goto *adr[0]; return 0; } - " _RE2C_HAVE_COMPUTED_GOTOS) + ]] _RE2C_HAVE_COMPUTED_GOTOS) cmake_pop_check_state() if(_RE2C_HAVE_COMPUTED_GOTOS) diff --git a/cmake/cmake/modules/PHP/CheckFlushIo.cmake b/cmake/cmake/modules/PHP/CheckFlushIo.cmake index a6cc37d9..27f66e46 100644 --- a/cmake/cmake/modules/PHP/CheckFlushIo.cmake +++ b/cmake/cmake/modules/PHP/CheckFlushIo.cmake @@ -35,7 +35,7 @@ if(NOT CMAKE_CROSSCOMPILING) #endif #include - int main(int argc, char **argv) { + int main(void) { char *filename = tmpnam(NULL); char buffer[64]; int result = 1; diff --git a/cmake/cmake/modules/PHP/CheckFopencookie.cmake b/cmake/cmake/modules/PHP/CheckFopencookie.cmake index 0ef02dee..b6ddb7a4 100644 --- a/cmake/cmake/modules/PHP/CheckFopencookie.cmake +++ b/cmake/cmake/modules/PHP/CheckFopencookie.cmake @@ -43,20 +43,21 @@ if(NOT HAVE_FOPENCOOKIE) endif() # GNU C library can have a different seeker definition using off64_t. -message( - CHECK_START - "Checking whether fopencookie seeker uses off64_t" -) +message(CHECK_START "Checking whether fopencookie seeker uses off64_t") if( CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Linux" AND PHP_C_STANDARD_LIBRARY STREQUAL "glibc" ) + message(CHECK_PASS "yes (cross-compiling)") + set( COOKIE_SEEKER_USES_OFF64_T 1 CACHE INTERNAL "Whether fopencookie seeker uses off64_t" ) + + return() else() cmake_push_check_state(RESET) set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) @@ -107,9 +108,7 @@ else() cmake_pop_check_state() endif() -if(CMAKE_CROSSCOMPILING AND COOKIE_SEEKER_USES_OFF64_T) - message(CHECK_PASS "yes (cross-compiling)") -elseif(COOKIE_SEEKER_USES_OFF64_T) +if(COOKIE_SEEKER_USES_OFF64_T) message(CHECK_PASS "yes") else() message(CHECK_FAIL "no") diff --git a/cmake/cmake/modules/PHP/StandardLibrary.cmake b/cmake/cmake/modules/PHP/StandardLibrary.cmake index 480975f9..61388b28 100644 --- a/cmake/cmake/modules/PHP/StandardLibrary.cmake +++ b/cmake/cmake/modules/PHP/StandardLibrary.cmake @@ -1,5 +1,5 @@ #[=============================================================================[ -Determine C standard library that will be used for the build. +Determine the C standard library used for the build. Result variables: PHP_C_STANDARD_LIBRARY @@ -19,9 +19,9 @@ include(CMakePushCheckState) message(CHECK_START "Checking C standard library") -# Initial uClibc and its maintained fork uClibc-ng behave like minimalistic GNU -# C but aren't. These can be determined by the __UCLIBC__ symbol. They must be -# checked first because they also define the __GLIBC__ symbol. +# The uClibc and its maintained fork uClibc-ng behave like minimalistic GNU C +# library but have differences. They can be determined by the __UCLIBC__ symbol +# and must be checked first because they also define the __GLIBC__ symbol. cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) check_symbol_exists(__UCLIBC__ features.h _PHP_C_STANDARD_LIBRARY_UCLIBC) @@ -32,8 +32,8 @@ if(_PHP_C_STANDARD_LIBRARY_UCLIBC) return() endif() -# GNU C standard library has __GLIBC__ and __GLIBC_MINOR__ symbols synce the -# very early versions 2.0. +# The GNU C standard library has __GLIBC__ and __GLIBC_MINOR__ symbols since the +# very early version 2.0. cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) check_symbol_exists(__GLIBC__ features.h _PHP_C_STANDARD_LIBRARY_GLIBC) @@ -44,33 +44,33 @@ if(_PHP_C_STANDARD_LIBRARY_GLIBC) return() endif() -# The musl libc doesn't advertise itself specifically via symbols, so it must -# be guessed. +# The musl libc doesn't advertise itself with symbols, so it must be determined +# heuristically. cmake_push_check_state(RESET) set(CMAKE_REQUIRED_QUIET TRUE) 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") +else() + # Otherwise, try determining musl libc with ldd. + block(PROPAGATE PHP_C_STANDARD_LIBRARY) + execute_process( + COMMAND ldd --version + OUTPUT_VARIABLE version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(version MATCHES ".*musl libc.*") + set(PHP_C_STANDARD_LIBRARY "musl") + endif() + endblock() +endif() +if(PHP_C_STANDARD_LIBRARY STREQUAL "musl") + set(__MUSL__ 1 CACHE INTERNAL "Whether musl libc is used.") message(CHECK_PASS "musl") return() endif() -# Otherwise, try using ldd. -block(PROPAGATE PHP_C_STANDARD_LIBRARY) - execute_process( - COMMAND ldd --version - OUTPUT_VARIABLE version - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - if(version MATCHES ".*musl libc.*") - set(__MUSL__ 1 CACHE INTERNAL "Whether musl libc is used") - set(PHP_C_STANDARD_LIBRARY "musl") - message(CHECK_PASS "musl") - return() - endif() -endblock() - message(CHECK_FAIL "unknown") diff --git a/cmake/ext/curl/CMakeLists.txt b/cmake/ext/curl/CMakeLists.txt index daff4556..68df70a1 100644 --- a/cmake/ext/curl/CMakeLists.txt +++ b/cmake/ext/curl/CMakeLists.txt @@ -70,33 +70,40 @@ if(PHP_THREAD_SAFETY AND CURL_SSL_FOUND) #include #include - int main(int argc, char *argv[]) { + int main(void) { curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); if (data && data->ssl_version && *data->ssl_version) { const char *ptr = data->ssl_version; - while(*ptr == ' ') ++ptr; + while(*ptr == ' ') { + ++ptr; + } + int major, minor; - if (sscanf(ptr, "OpenSSL/%d", &major) == 1) { - if (major >= 3) { - /* OpenSSL version 3 or later */ - return 4; - } + + /* OpenSSL >= 3 */ + if (sscanf(ptr, "OpenSSL/%d", &major) == 1 && major >= 3) { + return 4; } - if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) { - if (major > 1 || (major == 1 && minor >= 1)) { - /* OpenSSL version 1.1 or later */ - return 3; - } + + /* OpenSSL >= 1.1 */ + if ( + sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2 && + (major > 1 || (major == 1 && minor >= 1)) + ) { + return 3; } + + /* OpenSSL < 1.1 */ if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) { - /* Old OpenSSL version */ return 0; } + /* Different SSL library */ return 2; } + /* No SSL support */ return 1; } @@ -118,13 +125,23 @@ if(PHP_THREAD_SAFETY AND CURL_SSL_FOUND) target_link_libraries(php_curl PRIVATE OpenSSL::Crypto) - check_include_file(openssl/crypto.h HAVE_OPENSSL_CRYPTO_H) + if(TARGET OpenSSL::Crypto) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_LIBRARIES OpenSSL::Crypto) + check_include_file(openssl/crypto.h HAVE_OPENSSL_CRYPTO_H) + cmake_pop_check_state() + endif() endif() endif() # Sanity check. if(TARGET CURL::libcurl) - check_library_exists(CURL::libcurl curl_easy_perform "" HAVE_CURL_EASY_PERFORM) + check_library_exists( + CURL::libcurl + curl_easy_perform + "" + HAVE_CURL_EASY_PERFORM + ) if(NOT HAVE_CURL_EASY_PERFORM) message( diff --git a/cmake/ext/gd/CMakeLists.txt b/cmake/ext/gd/CMakeLists.txt index 62523a38..5868093d 100644 --- a/cmake/ext/gd/CMakeLists.txt +++ b/cmake/ext/gd/CMakeLists.txt @@ -385,7 +385,10 @@ if(NOT EXT_GD_EXTERNAL) cmake_pop_check_state() if(NOT _GD_SANITY_CHECK_COMPILES) - message(FATAL_ERROR "GD build test failed. Please check logs for details.") + message( + FATAL_ERROR + "GD build test failed. Please check logs for details." + ) endif() endif() endblock() @@ -443,8 +446,8 @@ else() void exit1(int priority, const char *format, va_list args) { _exit(1); } - /* Override the default gd_error_method with one that actually causes - the program to return an error. */ + /* Override the default gd_error_method with one that actually + causes the program to return an error. */ int main(int argc, char** argv) { ${declaration}; gdSetErrorMethod(exit1); @@ -465,6 +468,11 @@ else() check_library_exists(GD::GD gdFontCacheShutdown "" HAVE_GD_FREETYPE) check_library_exists(GD::GD gdVersionString "" HAVE_GD_LIBVERSION) - check_library_exists(GD::GD gdImageGetInterpolationMethod "" HAVE_GD_GET_INTERPOLATION) + check_library_exists( + GD::GD + gdImageGetInterpolationMethod + "" + HAVE_GD_GET_INTERPOLATION + ) endif() endif()