diff --git a/bin/init.cmake b/bin/init.cmake index 2c2c31508..d51b08fac 100755 --- a/bin/init.cmake +++ b/bin/init.cmake @@ -51,7 +51,7 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -if(NOT GIT_BRANCH MATCHES "^PHP-[0-9]+\.[0-9]+$") +if(NOT GIT_BRANCH MATCHES [[^PHP-[0-9]+\.[0-9]+$]]) set(GIT_BRANCH "master") endif() diff --git a/bin/php.cmake b/bin/php.cmake index 4d6702a4d..1524edb78 100755 --- a/bin/php.cmake +++ b/bin/php.cmake @@ -85,7 +85,7 @@ if( ) set(PHP_VERSION "${PHP_VERSION_FALLBACK}") else() - string(REGEX MATCH [[php-([0-9]+.[0-9]+.[0-9]+).tar.gz]] _ "${filename}") + string(REGEX MATCH [[php-([0-9.]+)\.tar\.gz]] _ "${filename}") set(PHP_VERSION "${CMAKE_MATCH_1}") endif() endblock() @@ -207,7 +207,7 @@ function(php_download) "https://github.com/php/php-src/archive/refs/heads/${branch}.tar.gz" ) elseif(PHP_VERSION MATCHES "^.*-dev$") - string(REGEX MATCH [[(^[0-9]+)\.([0-9]+).*$]] _ "${PHP_VERSION}") + string(REGEX MATCH [[(^[0-9]+)\.([0-9]+)]] _ "${PHP_VERSION}") set(branch "PHP-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") list( @@ -296,7 +296,7 @@ function(php_prepare_sources) message(STATUS "Applying patches to ${PHP_SOURCE_DIR_RELATIVE}") # Apply patches for php-src. - string(REGEX MATCH [[([0-9]+\.[0-9]+).*$]] _ "${PHP_VERSION}") + string(REGEX MATCH [[^([0-9]+\.[0-9]+)]] _ "${PHP_VERSION}") file(GLOB_RECURSE patches ${PHP_ROOT_DIR}/patches/${CMAKE_MATCH_1}/*.patch) foreach(patch ${patches}) @@ -318,7 +318,7 @@ function(php_prepare_sources) # Clean temporary .git directory. Checks are done as safeguards. if( - PHP_SOURCE_DIR MATCHES "\\/php-8\\.[0-9][.-].*$" + PHP_SOURCE_DIR MATCHES [[/php-8\.[0-9][.-].*$]] AND IS_DIRECTORY ${PHP_SOURCE_DIR}/.git/ AND EXISTS ${PHP_SOURCE_DIR}/php.ini-development AND EXISTS ${PHP_SOURCE_DIR}/main/php_version.h diff --git a/cmake/Zend/CMakeLists.txt b/cmake/Zend/CMakeLists.txt index 802d182d3..53670dfe9 100644 --- a/cmake/Zend/CMakeLists.txt +++ b/cmake/Zend/CMakeLists.txt @@ -32,7 +32,7 @@ block(PROPAGATE Zend_VERSION Zend_VERSION_LABEL) file(READ zend.h content) string( REGEX MATCH - "#[ \t]*define[ \t]+ZEND_VERSION[ \t]+\"([0-9.]+)([^\"]*)" + [[#[ \t]*define[ \t]+ZEND_VERSION[ \t]+"([0-9.]+)([^"]*)]] _ "${content}" ) diff --git a/cmake/cmake/ConfigureChecks.cmake b/cmake/cmake/ConfigureChecks.cmake index 3ac204196..e390edcdb 100644 --- a/cmake/cmake/ConfigureChecks.cmake +++ b/cmake/cmake/ConfigureChecks.cmake @@ -803,9 +803,9 @@ if(PHP_GCOV) if(CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache") message( WARNING - "ccache should be disabled when PHP_GCOV='ON' option is used. You can " - "disable ccache by setting option PHP_CCACHE='OFF' or environment " - "variable CCACHE_DISABLE=1." + "When 'PHP_GCOV' is enabled, ccache should be disabled by setting the " + "'PHP_CCACHE' to 'OFF' or by setting the 'CCACHE_DISABLE' environment " + "variable." ) endif() diff --git a/cmake/cmake/Version.cmake b/cmake/cmake/Version.cmake index 15304b5fe..38a74266a 100644 --- a/cmake/cmake/Version.cmake +++ b/cmake/cmake/Version.cmake @@ -15,8 +15,8 @@ include_guard(GLOBAL) # Set the PHP_VERSION_* variables from configure.ac. block(PROPAGATE PHP_VERSION) - set(regex "^AC_INIT\\(\\[PHP\\],\\[([0-9]+\.[0-9]+\.[0-9]+)([^\]]*)") - file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/../configure.ac _ REGEX "${regex}") + set(regex "^AC_INIT.+PHP\\],\\[([0-9.]+)([^]]*)") + file(STRINGS configure.ac _ REGEX "${regex}") cmake_policy(GET CMP0159 policy) if(CMAKE_VERSION VERSION_LESS 3.29 OR NOT policy STREQUAL NEW) diff --git a/cmake/cmake/modules/FindApache.cmake b/cmake/cmake/modules/FindApache.cmake index 9060f14c4..e0b3e6e94 100644 --- a/cmake/cmake/modules/FindApache.cmake +++ b/cmake/cmake/modules/FindApache.cmake @@ -338,9 +338,7 @@ block(PROPAGATE Apache_VERSION) ERROR_QUIET ) - string(REGEX MATCH " Apache/([0-9]\.[0-9.]+\.[0-9]+) " _ "${version}") - - if(CMAKE_MATCH_1) + if(version MATCHES [[ Apache/([0-9]+\.[0-9.]+)]]) set(Apache_VERSION "${CMAKE_MATCH_1}") endif() endif() diff --git a/cmake/cmake/modules/FindCcache.cmake b/cmake/cmake/modules/FindCcache.cmake index e6f4098fd..4748c3082 100644 --- a/cmake/cmake/modules/FindCcache.cmake +++ b/cmake/cmake/modules/FindCcache.cmake @@ -12,8 +12,8 @@ Find the Ccache compiler cache tool for faster compilation times. ## Hints -* The `CCACHE_DISABLE` environment variable disables the ccache and doesn't add - it to the C and CXX launcher, see Ccache documentation for more info. +* The `CCACHE_DISABLE` regular or environment variable which disables ccache and + doesn't adjust the C and CXX launcher. For more info see Ccache documentation. #]=============================================================================] include(FeatureSummary) @@ -45,9 +45,7 @@ block(PROPAGATE Ccache_VERSION) OUTPUT_STRIP_TRAILING_WHITESPACE ) - string(REGEX MATCH "^ccache version ([^\r\n]+)" _ "${version}") - - if(CMAKE_MATCH_1) + if(version MATCHES "^ccache version ([^\r\n]+)") set(Ccache_VERSION "${CMAKE_MATCH_1}") endif() endif() @@ -64,11 +62,16 @@ find_package_handle_standard_args( unset(_reason) -if(NOT Ccache_FOUND OR CCACHE_DISABLE OR "$ENV{CCACHE_DISABLE}") +if(NOT Ccache_FOUND) message(STATUS "Ccache disabled") return() endif() +if(CCACHE_DISABLE OR DEFINED ENV{CCACHE_DISABLE}) + message(STATUS "Ccache disabled ('CCACHE_DISABLE' is set)") + return() +endif() + if(CMAKE_C_COMPILER_LOADED) set(CMAKE_C_COMPILER_LAUNCHER ${Ccache_EXECUTABLE}) endif() diff --git a/cmake/cmake/modules/FindKerberos.cmake b/cmake/cmake/modules/FindKerberos.cmake index 7dcb3f240..27eddafba 100644 --- a/cmake/cmake/modules/FindKerberos.cmake +++ b/cmake/cmake/modules/FindKerberos.cmake @@ -99,9 +99,7 @@ block(PROPAGATE Kerberos_VERSION) OUTPUT_QUIET ) - string(REGEX MATCH " ([0-9]\.[0-9.]+) " _ "${version}") - - if(CMAKE_MATCH_1) + if(version MATCHES [[ ([0-9]\.[0-9.]+)]]) set(Kerberos_VERSION "${CMAKE_MATCH_1}") endif() endif() diff --git a/cmake/cmake/modules/FindODBC.cmake b/cmake/cmake/modules/FindODBC.cmake index 418543d7a..5910fc4d7 100644 --- a/cmake/cmake/modules/FindODBC.cmake +++ b/cmake/cmake/modules/FindODBC.cmake @@ -247,7 +247,7 @@ elseif(ODBC_CONFIG) ERROR_QUIET ) - if(NOT result EQUAL 0 OR NOT ODBC_VERSION MATCHES "[0-9]+\.[0-9.]+") + if(NOT result EQUAL 0 OR NOT ODBC_VERSION MATCHES [[[0-9]+\.[0-9.]+]]) unset(ODBC_VERSION) endif() diff --git a/cmake/cmake/modules/FindTokyoCabinet.cmake b/cmake/cmake/modules/FindTokyoCabinet.cmake index eee0c1654..2169796d3 100644 --- a/cmake/cmake/modules/FindTokyoCabinet.cmake +++ b/cmake/cmake/modules/FindTokyoCabinet.cmake @@ -76,7 +76,7 @@ endif() # Get version. block(PROPAGATE TokyoCabinet_VERSION) if(EXISTS ${TokyoCabinet_INCLUDE_DIR}/tcutil.h) - set(regex [[^[ \t]*#[ \t]*define[ \t]+_TC_VERSION[ \t]+"?([0-9.]+)"?[ \t]*$]]) + set(regex [[^[ \t]*#[ \t]*define[ \t]+_TC_VERSION[ \t]+"?([^"]+)"?[ \t]*$]]) file(STRINGS ${TokyoCabinet_INCLUDE_DIR}/tcutil.h result REGEX "${regex}") diff --git a/cmake/ext/odbc/CMakeLists.txt b/cmake/ext/odbc/CMakeLists.txt index 78c42fa38..b646858ab 100644 --- a/cmake/ext/odbc/CMakeLists.txt +++ b/cmake/ext/odbc/CMakeLists.txt @@ -363,9 +363,9 @@ elseif(PHP_ODBC_TYPE STREQUAL "sapdb") set(HAVE_SAPDB 1) elseif(PHP_ODBC_TYPE STREQUAL "solid") # Set based on the Solid version: - if(ODBC_LIBRARY MATCHES "23\.(a|so)$") + if(ODBC_LIBRARY MATCHES [[23\.(a|so)$]]) set(HAVE_SOLID 1) - elseif(ODBC_LIBRARY MATCHES "30\.(a|so)$") + elseif(ODBC_LIBRARY MATCHES [[30\.(a|so)$]]) set(HAVE_SOLID_30 1) else() set(HAVE_SOLID_35 1) diff --git a/cmake/sapi/fuzzer/CMakeLists.txt b/cmake/sapi/fuzzer/CMakeLists.txt index 70ae3d1d3..579428fdb 100644 --- a/cmake/sapi/fuzzer/CMakeLists.txt +++ b/cmake/sapi/fuzzer/CMakeLists.txt @@ -71,7 +71,7 @@ endif() add_executable(php_fuzzer) add_executable(PHP::fuzzer ALIAS php_fuzzer) -if(LIB_FUZZING_ENGINE OR "$ENV{LIB_FUZZING_ENGINE}") +if(LIB_FUZZING_ENGINE OR DEFINED ENV{LIB_FUZZING_ENGINE}) if(LIB_FUZZING_ENGINE) set(libFuzzingEngine "${LIB_FUZZING_ENGINE}") else()