Skip to content

Commit 53407f2

Browse files
committed
Improve build-defs.h configuration
Changes: - This adds a CMake-related template for generating the `build-defs.h` header. - The ODBC build configuration is moved to its own `config.h` (or `php_config.h`) header. - Added `build-defs.h` also for Windows targets for simplicity of handling configuration header templates, although this separates the CMake-based and upstream build systems even more. - Fixed build when using multi-config generators (Ninja Multi-Config, Visual Studio, etc.). This now generates `build-defs.h` and `php_config.h`/`config.w32.h` files in a separate directory `<CONFIG>/main`, where `<CONFIG>` is one of the build configurations (Debug, Release ...). - Initial preparations to remove the redundant and complex PHP/ConfigureFile CMake module. - Further fixes are needed but this now at least enables building PHP a bit better than before. PHP at this point is still not relocatable (to be able to utilize paths in a relative way, depending on the current executable).
1 parent 01a9ba4 commit 53407f2

File tree

8 files changed

+217
-250
lines changed

8 files changed

+217
-250
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
578578
file(
579579
CONFIGURE
580580
OUTPUT zend_config.h
581-
CONTENT "#include <../main/php_config.h>\n"
581+
CONTENT "#include <php_config.h>\n"
582582
)
583583
endif()
584584

cmake/cmake/modules/FindGcov.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ macro(gcov_generate_report)
149149
message(STATUS \"Generating gcovr HTML\")
150150
# Clean generated gcovr_html directory. Checks are done as safeguards.
151151
if(
152-
EXISTS ${PROJECT_BINARY_DIR}/main/php_config.h
152+
EXISTS ${PROJECT_BINARY_DIR}/main/internal_functions.c
153153
AND EXISTS ${PROJECT_BINARY_DIR}/gcovr_html
154154
)
155155
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/gcovr_html)
@@ -173,7 +173,7 @@ macro(gcov_generate_report)
173173
message(STATUS \"Generating gcovr XML\")
174174
# Clean generated gcovr.xml file. Checks are done as safeguards.
175175
if(
176-
EXISTS ${PROJECT_BINARY_DIR}/main/php_config.h
176+
EXISTS ${PROJECT_BINARY_DIR}/main/internal_functions.c
177177
AND EXISTS ${PROJECT_BINARY_DIR}/gcovr.xml
178178
)
179179
file(REMOVE ${PROJECT_BINARY_DIR}/gcovr.xml)

cmake/cmake/modules/FindSendmail.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ either `sendmail` is used if found, or a general default value is set to
99
## Result variables
1010
1111
* `Sendmail_FOUND` - Whether sendmail has been found.
12-
* `PROG_SENDMAIL` - Path to the sendmail executable program, either found by
13-
the module or set to a sensible default value.
12+
* `Sendmail_PROGRAM` - Path to the sendmail executable program, either found by
13+
the module or set to a sensible default value for usage in PHP. On Windows,
14+
this is set to an empty string as PHP uses a built in mailer there.
1415
1516
## Cache variables
1617
@@ -39,6 +40,7 @@ set(_reason "")
3940
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
4041
set(_sendmailIsBuiltInMsg "PHP built-in mailer (Windows)")
4142
set(_sendmailRequiredVars _sendmailIsBuiltInMsg)
43+
set(Sendmail_PROGRAM "")
4244
else()
4345
find_program(
4446
Sendmail_EXECUTABLE
@@ -50,14 +52,14 @@ else()
5052
set(_sendmailRequiredVars Sendmail_EXECUTABLE)
5153

5254
if(Sendmail_EXECUTABLE)
53-
set(PROG_SENDMAIL ${Sendmail_EXECUTABLE})
55+
set(Sendmail_PROGRAM "${Sendmail_EXECUTABLE}")
5456
else()
55-
set(PROG_SENDMAIL "/usr/sbin/sendmail")
57+
set(Sendmail_PROGRAM "/usr/sbin/sendmail")
5658
endif()
5759

5860
set(
5961
_reason
60-
"sendmail not found. Default set to ${PROG_SENDMAIL}.
62+
"sendmail not found. Default set to ${Sendmail_PROGRAM}.
6163
It can be overridden with 'sendmail_path' php.ini directive."
6264
)
6365
endif()

cmake/ext/odbc/CMakeLists.txt

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ if(PHP_EXT_ODBC_VERSION AND NOT PHP_EXT_ODBC_VERSION MATCHES "^0x[0-9A-Fa-f]+$")
273273
)
274274
endif()
275275

276-
unset(PHP_ODBC_CFLAGS CACHE)
277-
unset(PHP_ODBC_LFLAGS CACHE)
278-
unset(PHP_ODBC_LIBS CACHE)
279-
unset(PHP_ODBC_TYPE CACHE)
280-
281276
if(NOT PHP_EXT_ODBC)
282277
return()
283278
endif()
@@ -332,7 +327,7 @@ if(PHP_EXT_ODBC_TYPE STREQUAL "ibm-db2" AND TARGET ODBC::ODBC)
332327
endif()
333328

334329
################################################################################
335-
# Set variables for main/build-defs.h and config.h file.
330+
# Configure config.h file.
336331
################################################################################
337332

338333
# Set PHP_ODBC_TYPE for configuration header value.
@@ -394,7 +389,7 @@ if(NOT PHP_EXT_ODBC_TYPE MATCHES "^(dbmaker|solid)$")
394389
set(HAVE_SQLDATASOURCES TRUE)
395390
endif()
396391

397-
if(TARGET ODBC::ODBC)
392+
if(TARGET ODBC::ODBC AND NOT ODBC_DRIVER STREQUAL "Windows")
398393
block(PROPAGATE PHP_ODBC_BUILD_DEFINITIONS_CODE)
399394
get_target_property(definitions ODBC::ODBC INTERFACE_COMPILE_DEFINITIONS)
400395
get_target_property(options ODBC::ODBC INTERFACE_COMPILE_OPTIONS)
@@ -430,37 +425,18 @@ if(TARGET ODBC::ODBC)
430425
list(JOIN ldflags " " ldflags)
431426
list(JOIN libs " " libs)
432427

433-
set(PHP_ODBC_CFLAGS "${cflags}" CACHE INTERNAL "ODBC CFLAGS")
434-
set(PHP_ODBC_LFLAGS "${ldflags}" CACHE INTERNAL "ODBC linker flags")
435-
set(PHP_ODBC_LIBS "${libs}" CACHE INTERNAL "ODBC libraries")
436-
set(PHP_ODBC_TYPE "${PHP_ODBC_TYPE}" CACHE INTERNAL "ODBC type")
437-
438-
if(
439-
NOT ODBC_DRIVER STREQUAL "Windows"
440-
AND NOT EXISTS ${PHP_SOURCE_DIR}/main/build-defs.h.in
441-
)
442-
set(
443-
PHP_ODBC_BUILD_DEFINITIONS_CODE
444-
[[
428+
string(CONFIGURE [[
445429
/* The compile options that PHP odbc extension was built with. */
446-
#define PHP_ODBC_CFLAGS "@PHP_ODBC_CFLAGS@"
430+
#define PHP_ODBC_CFLAGS "@cflags@"
447431

448432
/* The linker flags that PHP odbc extension was built with. */
449-
#define PHP_ODBC_LFLAGS "@PHP_ODBC_LFLAGS@"
433+
#define PHP_ODBC_LFLAGS "@ldflags@"
450434

451435
/* The libraries linker flags that PHP odbc extension was built with. */
452-
#define PHP_ODBC_LIBS "@PHP_ODBC_LIBS@"
436+
#define PHP_ODBC_LIBS "@libs@"
453437

454438
/* The ODBC library used in the PHP odbc extension. */
455-
#define PHP_ODBC_TYPE "@PHP_ODBC_TYPE@"]]
456-
)
457-
458-
string(
459-
CONFIGURE
460-
"${PHP_ODBC_BUILD_DEFINITIONS_CODE}"
461-
PHP_ODBC_BUILD_DEFINITIONS_CODE
462-
)
463-
endif()
439+
#define PHP_ODBC_TYPE "@PHP_ODBC_TYPE@"]] PHP_ODBC_BUILD_DEFINITIONS_CODE)
464440
endblock()
465441
endif()
466442

0 commit comments

Comments
 (0)