Skip to content

Commit f02f31a

Browse files
committed
Change internal CACHE variables to local variables
- Setting internal CACHE variables isn't needed in these cases. - This also fixes ftp and mysqlnd extensions to have entire configuration deferred to properly check for the PHP openssl extension. - Some help texts moved to configuration headers. - Main configuration header improved a bit further. - Gersemi configuration moved forward with new --config option. - HAVE_<extension> cache variables are no longer automatically defined as this is simply redundant and makes it simpler to manage locally and individually on the extension level.
1 parent 3f52eaf commit f02f31a

34 files changed

+149
-264
lines changed

bin/check-cmake.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ function runGersemi(): int
591591
}
592592

593593
exec(
594-
'gersemi --check --indent 2 --definitions cmake bin -- cmake bin',
594+
'gersemi --check --config ' . __DIR__ . '/check-cmake/.gersemirc -- cmake bin',
595595
$output,
596596
$status,
597597
);

bin/check-cmake/.gersemirc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
#
33
# CMake code formatting configuration.
44
# See: https://github.com/BlankSpruce/gersemi
5-
#
6-
# This is only a template for now, as configuration options are passed manually.
75

8-
cache: true
9-
color: true
10-
definitions: [.]
6+
definitions: [../../cmake, ., ../../bin]
117
indent: 2
128
line_length: 80
139
list_expansion: favour-inlining
14-
quiet: false
1510
unsafe: false
1611
warn_about_unknown_commands: true
17-
workers: max

cmake/cmake/modules/PHP/Extensions.cmake

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ php_extensions_add(subdirectory)
4949
* `PHP_ALWAYS_ENABLED_EXTENSIONS`
5050
5151
This global property contains a list of always enabled PHP extensions which
52-
don't need the `HAVE_<extension-name>` preprocessor macros defined in the PHP
53-
configuration header and can be considered as part of the core PHP engine.
52+
can be considered part of the core PHP engine.
5453
5554
* `PHP_EXTENSIONS`
5655
@@ -670,13 +669,6 @@ function(_php_extensions_post_configure directory)
670669
return()
671670
endif()
672671

673-
# Define HAVE_<extension-name> symbol for php_config.h.
674-
string(TOUPPER "HAVE_${extension}" symbol)
675-
set(
676-
${symbol} 1
677-
CACHE INTERNAL "Whether to enable the PHP extension '${extension}'."
678-
)
679-
680672
get_target_property(extension_type php_${extension} TYPE)
681673

682674
if(NOT extension_type MATCHES "^(MODULE|SHARED)_LIBRARY$")

cmake/ext/date/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ target_compile_definitions(
6262
HAVE_STRTOLL
6363
)
6464

65-
set(HAVE_TIMELIB_CONFIG_H 1 CACHE INTERNAL "Whether you have timelib_config.h.")
65+
set(HAVE_TIMELIB_CONFIG_H 1)
6666

6767
message(STATUS "Creating ext/date/lib/timelib_config.h")
6868
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/lib/timelib_config.h [[

cmake/ext/enchant/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ set_package_properties(
4949
)
5050

5151
if(Enchant_FOUND)
52-
set(
53-
HAVE_ENCHANT_GET_VERSION 1
54-
CACHE INTERNAL "enchant_get_version since 1.6.0"
55-
)
52+
set(HAVE_ENCHANT_GET_VERSION 1)
5653
else()
5754
message(WARNING "Library Enchant 2 not found, trying with Enchant 1")
5855

cmake/ext/ftp/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,22 @@ function(php_ftp_post_configuration)
6565

6666
target_link_libraries(php_ftp PRIVATE OpenSSL::SSL)
6767

68-
set(HAVE_FTP_SSL 1 CACHE INTERNAL "Whether FTP over SSL is enabled")
68+
set(HAVE_FTP_SSL 1)
6969
endif()
7070

7171
add_feature_info(
7272
"ext/ftp SSL"
7373
HAVE_FTP_SSL
7474
"FTP over SSL support"
7575
)
76+
77+
set(HAVE_FTP 1)
78+
79+
configure_file(
80+
${PhpExtensionFtp_SOURCE_DIR}/config.cmake.h.in
81+
${PhpExtensionFtp_BINARY_DIR}/config.h
82+
@ONLY
83+
)
7684
endfunction()
7785

7886
# Run at the end of the configuration.
@@ -81,7 +89,3 @@ cmake_language(
8189
DIRECTORY ${PHP_SOURCE_DIR}
8290
CALL php_ftp_post_configuration
8391
)
84-
85-
set(HAVE_FTP 1)
86-
87-
configure_file(config.cmake.h.in config.h @ONLY)

cmake/ext/gd/CMakeLists.txt

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,12 @@ if(NOT EXT_GD_EXTERNAL)
213213
libgd/wbmp.h
214214
)
215215

216-
set(HAVE_GD_BUNDLED 1 CACHE INTERNAL "Whether the bundled libgd is used")
216+
set(HAVE_GD_BUNDLED 1)
217217

218218
# With bundled GD library these are always available.
219-
set(
220-
HAVE_GD_PNG 1
221-
CACHE INTERNAL "Whether the PNG functionality can be used with libgd"
222-
)
223-
224-
set(
225-
HAVE_GD_BMP 1
226-
CACHE INTERNAL "Whether the BMP functionality can be used with libgd"
227-
)
228-
229-
set(
230-
HAVE_GD_TGA 1
231-
CACHE INTERNAL "Whether the TGA functionality can be used with libgd"
232-
)
219+
set(HAVE_GD_PNG 1)
220+
set(HAVE_GD_BMP 1)
221+
set(HAVE_GD_TGA 1)
233222

234223
target_compile_definitions(
235224
php_gd
@@ -279,7 +268,7 @@ if(NOT EXT_GD_EXTERNAL)
279268

280269
target_link_libraries(php_gd PRIVATE PNG::PNG)
281270

282-
set(HAVE_LIBPNG 1 CACHE INTERNAL "Whether the libpng is available")
271+
set(HAVE_LIBPNG 1)
283272

284273
if(EXT_GD_AVIF)
285274
find_package(libavif 0.8.2)
@@ -292,8 +281,8 @@ if(NOT EXT_GD_EXTERNAL)
292281

293282
target_link_libraries(php_gd PRIVATE libavif::libavif)
294283

295-
set(HAVE_LIBAVIF 1 CACHE INTERNAL "Whether the libavif is available")
296-
set(HAVE_GD_AVIF 1 CACHE INTERNAL "Whether the AVIF support is enabled")
284+
set(HAVE_LIBAVIF 1)
285+
set(HAVE_GD_AVIF 1)
297286
endif()
298287

299288
if(EXT_GD_WEBP)
@@ -307,8 +296,8 @@ if(NOT EXT_GD_EXTERNAL)
307296

308297
target_link_libraries(php_gd PRIVATE WebP::WebP)
309298

310-
set(HAVE_LIBWEBP 1 CACHE INTERNAL "Whether the libwebp is available")
311-
set(HAVE_GD_WEBP 1 CACHE INTERNAL "Whether the WebP support is enabled")
299+
set(HAVE_LIBWEBP 1)
300+
set(HAVE_GD_WEBP 1)
312301
endif()
313302

314303
if(EXT_GD_JPEG)
@@ -322,8 +311,8 @@ if(NOT EXT_GD_EXTERNAL)
322311

323312
target_link_libraries(php_gd PRIVATE JPEG::JPEG)
324313

325-
set(HAVE_LIBJPEG 1 CACHE INTERNAL "Whether the libjpeg is available")
326-
set(HAVE_GD_JPG 1 CACHE INTERNAL "Whether the JPEG support is enabled")
314+
set(HAVE_LIBJPEG 1)
315+
set(HAVE_GD_JPG 1)
327316
endif()
328317

329318
if(EXT_GD_XPM)
@@ -337,8 +326,8 @@ if(NOT EXT_GD_EXTERNAL)
337326

338327
target_link_libraries(php_gd PRIVATE XPM::XPM)
339328

340-
set(HAVE_XPM 1 CACHE INTERNAL "Whether the libXpm library is available")
341-
set(HAVE_GD_XPM 1 CACHE INTERNAL "Whether the XPM support is enabled")
329+
set(HAVE_XPM 1)
330+
set(HAVE_GD_XPM 1)
342331
endif()
343332

344333
if(EXT_GD_FREETYPE)
@@ -352,27 +341,13 @@ if(NOT EXT_GD_EXTERNAL)
352341

353342
target_link_libraries(php_gd PRIVATE Freetype::Freetype)
354343

355-
set(
356-
HAVE_LIBFREETYPE 1
357-
CACHE INTERNAL "Whether the FreeType library is available"
358-
)
359-
360-
set(
361-
HAVE_GD_FREETYPE 1
362-
CACHE INTERNAL "Whether the FreeType support is enabled"
363-
)
344+
set(HAVE_LIBFREETYPE 1)
345+
set(HAVE_GD_FREETYPE 1)
364346
endif()
365347

366348
if(EXT_GD_JIS)
367-
set(
368-
JISX0208 1
369-
CACHE INTERNAL "Whether the JIS-mapped Japanese font support is available"
370-
)
371-
372-
set(
373-
USE_GD_JISX0208 1
374-
CACHE INTERNAL "Whether the JIS-mapped Japanese font support is enabled"
375-
)
349+
set(JISX0208 1)
350+
set(USE_GD_JISX0208 1)
376351
endif()
377352

378353
# Do sanity check when all required packages are found.

cmake/ext/gettext/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if(TARGET Intl::Intl)
6161
)
6262
endif()
6363

64-
set(HAVE_LIBINTL 1 CACHE INTERNAL "Whether gettext library is available")
64+
set(HAVE_LIBINTL 1)
6565

6666
check_library_exists(Intl::Intl ngettext "" HAVE_NGETTEXT)
6767
check_library_exists(Intl::Intl dngettext "" HAVE_DNGETTEXT)

cmake/ext/hash/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(EXT_HASH_MHASH)
2626
"Support for mhash in the hash extension is deprecated as of PHP 8.1.0"
2727
)
2828

29-
set(PHP_MHASH_BC 1 CACHE INTERNAL "Whether the mhash support is included")
29+
set(PHP_MHASH_BC 1)
3030
endif()
3131

3232
add_library(php_hash STATIC)
@@ -78,7 +78,7 @@ target_sources(
7878
target_include_directories(php_hash PRIVATE xxhash)
7979

8080
if(WORDS_BIGENDIAN)
81-
set(HAVE_SLOW_HASH3 1 CACHE INTERNAL "Whether slow SHA3 algo is used.")
81+
set(HAVE_SLOW_HASH3 1)
8282
message(WARNING "Using slow SHA3 implementation on bigendian")
8383
else()
8484
block()

cmake/ext/iconv/CMakeLists.txt

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ if(TARGET Iconv::Iconv)
7979
check_library_exists(Iconv::Iconv libiconv "" HAVE_LIBICONV)
8080

8181
if(HAVE_LIBICONV)
82-
set(
83-
ICONV_ALIASED_LIBICONV 1
84-
CACHE INTERNAL "iconv() is aliased to libiconv()"
85-
)
82+
set(ICONV_ALIASED_LIBICONV 1)
8683
else()
8784
check_library_exists(Iconv::Iconv iconv "" _HAVE_ICONV)
8885
endif()
@@ -106,11 +103,8 @@ if(TARGET Iconv::Iconv)
106103
cmake_pop_check_state()
107104
if(_have_gnu_libiconv)
108105
message(CHECK_PASS "GNU libiconv")
109-
set(HAVE_LIBICONV 1 CACHE INTERNAL "")
110-
set(
111-
PHP_ICONV_IMPL "libiconv"
112-
CACHE INTERNAL "The iconv implementation"
113-
)
106+
set(HAVE_LIBICONV 1)
107+
set(PHP_ICONV_IMPL "libiconv")
114108
endif()
115109

116110
# Check for glibc implementation.
@@ -123,10 +117,7 @@ if(TARGET Iconv::Iconv)
123117
endif()
124118
if(HAVE_GLIBC_ICONV)
125119
message(CHECK_PASS "GNU C library")
126-
set(
127-
PHP_ICONV_IMPL "glibc"
128-
CACHE INTERNAL "The iconv implementation"
129-
)
120+
set(PHP_ICONV_IMPL "glibc")
130121
endif()
131122

132123
# Check for Konstantin Chuguev's iconv implementation.
@@ -139,10 +130,7 @@ if(TARGET Iconv::Iconv)
139130
endif()
140131
if(_have_bsd_iconv)
141132
message(CHECK_PASS "BSD iconv")
142-
set(
143-
PHP_ICONV_IMPL "BSD iconv"
144-
CACHE INTERNAL "The iconv implementation"
145-
)
133+
set(PHP_ICONV_IMPL "BSD iconv")
146134
endif()
147135

148136
# Check for IBM iconv implementation.
@@ -155,10 +143,7 @@ if(TARGET Iconv::Iconv)
155143
endif()
156144
if(HAVE_IBM_ICONV)
157145
message(CHECK_PASS "IBM iconv")
158-
set(
159-
PHP_ICONV_IMPL "IBM iconv"
160-
CACHE INTERNAL "The iconv implementation"
161-
)
146+
set(PHP_ICONV_IMPL "IBM iconv")
162147
endif()
163148

164149
if(NOT PHP_ICONV_IMPL AND Iconv_IS_BUILT_IN)

0 commit comments

Comments
 (0)