Skip to content

Commit 6e5b176

Browse files
committed
Add various improvements
- Initial adjustments for build types and multi-config generators - Configuration headers synced further - Some variables are now resolved during the generation phase to be able to include generator expressions - Some minor bugs fixed for generated files
1 parent 5a98e7e commit 6e5b176

File tree

9 files changed

+93
-34
lines changed

9 files changed

+93
-34
lines changed

bin/init.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,20 @@ if make -h 2>&1 | grep -q "\[-j max_jobs\]" \
228228
fi
229229
fi
230230

231+
if test -n "$jobs"; then
232+
jobs="-j $jobs"
233+
else
234+
case $generator in
235+
Ninja*);;
236+
*) jobs=-j;;
237+
esac
238+
fi
239+
231240
cd php-src
232241

233242
# Run CMake preset configuration.
234243
eval "'$cmake' --preset $preset $cmake_debug_options $options $generator_option"
235244

236245
# Run build step using preset and jobs arguments passed after the arguments for
237246
# exotic make implementations, such as dmake on illumos.
238-
eval "'$cmake' --build --preset $preset $cmake_verbose -- -j $jobs"
247+
eval "'$cmake' --build --preset $preset $cmake_verbose -- $jobs"

cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Running system checks
99
")
1010

1111
message(STATUS "CMake version: ${CMAKE_VERSION}")
12+
message(STATUS "CMake generator: ${CMAKE_GENERATOR}")
1213

1314
# Set the PHP_VERSION_* variables from configure.ac.
1415
include(cmake/Version.cmake)

cmake/cmake/BuildTypes.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ include_guard(GLOBAL)
66

77
block()
88
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
9-
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
9+
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
1010

11-
if(is_multi_config)
11+
if(isMultiConfig)
1212
if(NOT "DebugAssertions" IN_LIST CMAKE_CONFIGURATION_TYPES)
1313
list(APPEND CMAKE_CONFIGURATION_TYPES DebugAssertions)
1414
endif()
1515
else()
1616
set(
17-
allowed_build_types
17+
allowedBuildTypes
1818
Debug
1919
MinSizeRel
2020
Release
@@ -25,12 +25,12 @@ block()
2525

2626
set_property(
2727
CACHE CMAKE_BUILD_TYPE
28-
PROPERTY STRINGS "${allowed_build_types}"
28+
PROPERTY STRINGS "${allowedBuildTypes}"
2929
)
3030

3131
if(NOT CMAKE_BUILD_TYPE)
3232
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
33-
elseif(NOT CMAKE_BUILD_TYPE IN_LIST allowed_build_types)
33+
elseif(NOT CMAKE_BUILD_TYPE IN_LIST allowedBuildTypes)
3434
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
3535
endif()
3636
endif()

cmake/cmake/Configuration.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,11 @@ block()
224224
set(extension_dir "${extension_dir}-zts")
225225
endif()
226226

227-
if(PHP_DEBUG)
228-
set(extension_dir "${extension_dir}-debug")
229-
endif()
227+
set(extension_dir "${extension_dir}$<IF:$<CONFIG:Debug>,-debug,>")
230228
else()
231229
set(extension_dir "${extension_dir}/extensions")
232230

233-
if(PHP_DEBUG)
234-
set(extension_dir "${extension_dir}/debug")
235-
else()
236-
set(extension_dir "${extension_dir}/no-debug")
237-
endif()
231+
set(extension_dir "${extension_dir}/$<IF:$<CONFIG:Debug>,debug,no-debug>")
238232

239233
if(PHP_THREAD_SAFETY)
240234
set(extension_dir "${extension_dir}-zts")

cmake/cmake/modules/PHP/ConfigureFile.cmake

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ function(_php_configure_file_parse_variables)
116116
replaced
117117
"${value}"
118118
)
119-
list(APPEND resultValues ${replaced})
119+
list(APPEND resultValues "${replaced}")
120120
else()
121-
list(APPEND resultValues ${value})
121+
list(APPEND resultValues "${value}")
122122
endif()
123123

124124
# The resultValuesInCode are for the configure_file inside the install(CODE)
@@ -184,6 +184,12 @@ function(php_configure_file)
184184
)
185185
endif()
186186

187+
cmake_path(GET ___phpConfigureFileOutput FILENAME filename)
188+
set(
189+
___phpConfigureFileOutputTemporary
190+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${filename}.cmake.in
191+
)
192+
187193
if(parsed_VARIABLES)
188194
_php_configure_file_parse_variables(
189195
"${parsed_VARIABLES}"
@@ -200,9 +206,18 @@ function(php_configure_file)
200206

201207
configure_file(
202208
${___phpConfigureFileTemplate}
203-
${___phpConfigureFileOutput}
209+
${___phpConfigureFileOutputTemporary}
204210
@ONLY
205211
)
212+
213+
# To be able to evaluate possible additional generator expressions.
214+
file(
215+
GENERATE
216+
# TODO: Multi-config generators need to write separate files.
217+
#OUTPUT $<CONFIG>/file.output
218+
OUTPUT ${___phpConfigureFileOutput}
219+
INPUT ${___phpConfigureFileOutputTemporary}
220+
)
206221
endblock()
207222

208223
install(CODE "

cmake/main/CMakeLists.txt

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,53 @@ function(_php_main_create_files)
271271

272272
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
273273
message(STATUS "Creating main/config.w32.h")
274-
configure_file(main/config.w32.cmake.h.in main/config.w32.h @ONLY)
274+
configure_file(
275+
main/config.w32.cmake.h.in
276+
main/CMakeFiles/config.w32.cmake.h.in
277+
@ONLY
278+
)
279+
280+
file(
281+
GENERATE
282+
# TODO: Multi-config generators need to write separate files.
283+
#OUTPUT $<CONFIG>/main/config.w32.h
284+
OUTPUT ${PHP_BINARY_DIR}/main/config.w32.h
285+
INPUT ${PHP_BINARY_DIR}/main/CMakeFiles/config.w32.cmake.h.in
286+
)
275287
else()
276288
message(STATUS "Creating main/build-defs.h")
277-
configure_file(main/build-defs.h.in main/build-defs.h @ONLY)
289+
configure_file(
290+
main/build-defs.h.in
291+
main/CMakeFiles/build-defs.h.in
292+
@ONLY
293+
)
294+
295+
# To be able to evaluate the generator expressions.
296+
file(
297+
GENERATE
298+
# TODO: Multi-config generators need to write separate files.
299+
#OUTPUT $<CONFIG>/main/build-defs.h
300+
OUTPUT ${PHP_BINARY_DIR}/main/build-defs.h
301+
INPUT ${PHP_BINARY_DIR}/main/CMakeFiles/build-defs.h.in
302+
)
278303

279304
set(HAVE_BUILD_DEFS_H 1)
280305

281306
message(STATUS "Creating main/php_config.h")
282-
configure_file(main/php_config.cmake.h.in main/php_config.h @ONLY)
307+
configure_file(
308+
main/php_config.cmake.h.in
309+
main/CMakeFiles/php_config.cmake.h.in
310+
@ONLY
311+
)
312+
313+
# To be able to evaluate the generator expressions.
314+
file(
315+
GENERATE
316+
# TODO: Multi-config generators need to write separate files.
317+
#OUTPUT $<CONFIG>/main/php_config.h
318+
OUTPUT ${PHP_BINARY_DIR}/main/php_config.h
319+
INPUT ${PHP_BINARY_DIR}/main/CMakeFiles/php_config.cmake.h.in
320+
)
283321
endif()
284322

285323
message(STATUS "Creating main/php_version.h")

cmake/main/config.w32.cmake.h.in

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,8 @@
10921092
/* Define to 1 if you have the 'mremap' function. */
10931093
#cmakedefine HAVE_MREMAP 1
10941094

1095-
/* Define to 1 if you have the <mscoree.h> header file, and to 0 if not. */
1096-
#cmakedefine01 HAVE_MSCOREE_H
1095+
/* Define to 1 if you have the <mscoree.h> header file. */
1096+
#cmakedefine HAVE_MSCOREE_H
10971097

10981098
/* Define to 1 if you have the 'nanosleep' function. */
10991099
#cmakedefine HAVE_NANOSLEEP 1
@@ -1759,9 +1759,6 @@
17591759
/* Define to 1 if the PHP extension 'zlib' is available. */
17601760
#cmakedefine HAVE_ZLIB 1
17611761

1762-
/* Define to 1 if you have the <zlib.h> header file, and to 0 if not. */
1763-
#cmakedefine01 HAVE_ZLIB_H
1764-
17651762
/* Define to 1 if _controlfp is present and usable. */
17661763
#cmakedefine HAVE__CONTROLFP 1
17671764

@@ -2074,6 +2071,13 @@
20742071
/* Define to 1 if checking the stack limit is supported. */
20752072
#cmakedefine ZEND_CHECK_STACK_LIMIT 1
20762073

2074+
/* Define to 1 if debugging is enabled, and to 0 if not.
2075+
TODO: This is still not good enough because multi-config generators would
2076+
then need separate php_config.h files for each build type. */
2077+
#ifndef ZEND_DEBUG
2078+
# define ZEND_DEBUG $<IF:$<CONFIG:Debug>,1,0>
2079+
#endif
2080+
20772081
/* Define to 1 if Zend fiber uses ucontext instead of boost context. */
20782082
#cmakedefine ZEND_FIBER_UCONTEXT 1
20792083

cmake/main/php_config.cmake.h.in

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,8 @@
10831083
/* Define to 1 if you have the 'mremap' function. */
10841084
#cmakedefine HAVE_MREMAP 1
10851085

1086-
/* Define to 1 if you have the <mscoree.h> header file, and to 0 if not. */
1087-
#cmakedefine01 HAVE_MSCOREE_H
1086+
/* Define to 1 if you have the <mscoree.h> header file. */
1087+
#cmakedefine HAVE_MSCOREE_H
10881088

10891089
/* Define to 1 if you have the 'nanosleep' function. */
10901090
#cmakedefine HAVE_NANOSLEEP 1
@@ -1747,9 +1747,6 @@
17471747
/* Define to 1 if the PHP extension 'zlib' is available. */
17481748
#cmakedefine HAVE_ZLIB 1
17491749

1750-
/* Define to 1 if you have the <zlib.h> header file, and to 0 if not. */
1751-
#cmakedefine01 HAVE_ZLIB_H
1752-
17531750
/* Define to 1 if _controlfp is present and usable. */
17541751
#cmakedefine HAVE__CONTROLFP 1
17551752

@@ -2039,10 +2036,11 @@
20392036
/* Define to 1 if checking the stack limit is supported. */
20402037
#cmakedefine ZEND_CHECK_STACK_LIMIT 1
20412038

2042-
/* Whether build type is Debug or DebugAssertions.
2043-
TODO: Fix this better. */
2039+
/* Define to 1 if debugging is enabled, and to 0 if not.
2040+
TODO: This is still not good enough because multi-config generators would
2041+
then need separate php_config.h files for each build type. */
20442042
#ifndef ZEND_DEBUG
2045-
#cmakedefine01 ZEND_DEBUG
2043+
# define ZEND_DEBUG $<IF:$<CONFIG:Debug>,1,0>
20462044
#endif
20472045

20482046
/* Define to 1 if Zend fiber uses ucontext instead of boost context. */

cmake/scripts/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ block()
4949
exec_prefix "$<INSTALL_PREFIX>"
5050
PHP_VERSION "${PHP_VERSION}"
5151
PHP_VERSION_ID "${PHP_VERSION_ID}"
52-
include_dir "$<PHP_EXPAND:${CMAKE_INSTALL_INCLUDEDIR}>"
52+
includedir "$<PHP_EXPAND:${CMAKE_INSTALL_INCLUDEDIR}>"
5353
# TODO:
5454
PHP_LDFLAGS ""
5555
# TODO:

0 commit comments

Comments
 (0)