Skip to content

Commit 96c9660

Browse files
committed
Simplify Windows configuration
1 parent 0558798 commit 96c9660

File tree

3 files changed

+38
-45
lines changed

3 files changed

+38
-45
lines changed

cmake/main/CMakeLists.txt

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ target_sources(
9797
BASE_DIRS ${PHP_BINARY_DIR}/$<CONFIG>/main
9898
FILES
9999
$<$<PLATFORM_ID:Windows>:${PHP_BINARY_DIR}/$<CONFIG>/main/config.w32.h>
100-
$<$<NOT:$<PLATFORM_ID:Windows>>:${PHP_BINARY_DIR}/$<CONFIG>/main/build-defs.h>
100+
${PHP_BINARY_DIR}/$<CONFIG>/main/build-defs.h
101101
$<$<NOT:$<PLATFORM_ID:Windows>>:${PHP_BINARY_DIR}/$<CONFIG>/main/php_config.h>
102102
)
103103

@@ -256,16 +256,14 @@ function(_php_main_create_files)
256256

257257
# Set the 'include_path' INI directive.
258258
if("@CMAKE_SYSTEM_NAME@" STREQUAL "Windows")
259-
set(INCLUDE_PATH ".;@EXPANDED_PEAR_INSTALLDIR@")
259+
set(PHP_INCLUDE_PATH ".;@EXPANDED_PEAR_INSTALLDIR@")
260260
else()
261-
set(INCLUDE_PATH ".:@EXPANDED_PEAR_INSTALLDIR@")
261+
set(PHP_INCLUDE_PATH ".:@EXPANDED_PEAR_INSTALLDIR@")
262262
endif()
263263

264264
# Set the PHP extensions directory.
265265
set(EXPANDED_EXTENSION_DIR "$<PATH:ABSOLUTE_PATH,NORMALIZE,@PHP_EXTENSION_DIR@,${CMAKE_INSTALL_PREFIX}>")
266266

267-
set(prefix "${CMAKE_INSTALL_PREFIX}")
268-
269267
set(EXPANDED_BINDIR "$<PATH:ABSOLUTE_PATH,NORMALIZE,@CMAKE_INSTALL_BINDIR@,${CMAKE_INSTALL_PREFIX}>")
270268

271269
set(EXPANDED_SBINDIR "$<PATH:ABSOLUTE_PATH,NORMALIZE,@CMAKE_INSTALL_SBINDIR@,${CMAKE_INSTALL_PREFIX}>")
@@ -296,7 +294,7 @@ function(_php_main_create_files)
296294
set(EXPANDED_PHP_CONFIG_FILE_SCAN_DIR "$<PATH:ABSOLUTE_PATH,NORMALIZE,@PHP_CONFIG_FILE_SCAN_DIR@,${CMAKE_INSTALL_PREFIX}>")
297295

298296
# Set shared library object extension.
299-
string(REPLACE "." "" SHLIB_DL_SUFFIX_NAME "@CMAKE_SHARED_MODULE_SUFFIX@")
297+
string(REPLACE "." "" PHP_SHLIB_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@")
300298

301299
# Set filename prefix for PHP shared extensions.
302300
if("@CMAKE_SYSTEM_NAME@" STREQUAL "Windows")
@@ -354,43 +352,35 @@ function(_php_main_create_files)
354352
file(READ ${CMAKE_CURRENT_BINARY_DIR}/Zend/CMakeFiles/zend_config.h config)
355353
string(STRIP "${config}" ZEND_CONFIGURATION)
356354

357-
file(READ main/cmake/build-defs.h.in PHP_BUILD_DEFINITIONS_CODE)
358-
string(CONFIGURE "${PHP_BUILD_DEFINITIONS_CODE}" PHP_BUILD_DEFINITIONS_CODE @ONLY)
355+
message(STATUS "Creating build-defs.h")
356+
file(READ main/cmake/build-defs.h.in content)
357+
string(CONFIGURE "${content}" content @ONLY)
359358

360-
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
361-
message(STATUS "Creating build-defs.h")
359+
file(
360+
GENERATE
361+
OUTPUT ${PHP_BINARY_DIR}/$<CONFIG>/main/build-defs.h
362+
CONTENT "${content}"
363+
)
362364

363-
# To be able to evaluate the generator expressions.
364-
file(
365-
GENERATE
366-
# Multi-config generators need to write separate files.
367-
OUTPUT ${PHP_BINARY_DIR}/$<CONFIG>/main/build-defs.h
368-
CONTENT "${PHP_BUILD_DEFINITIONS_CODE}"
365+
# This enables regenerating file on the install step when using different
366+
# installation prefix at the 'cmake --install ... --prefix <install-prefix>'
367+
# phase.
368+
string(CONFIGURE [[
369+
@code@
370+
configure_file(
371+
"@PHP_SOURCE_DIR@/main/cmake/build-defs.h.in"
372+
"@PHP_BINARY_DIR@/$<CONFIG>/main/build-defs.h"
373+
@ONLY
369374
)
370-
371-
set(PHP_BUILD_DEFINITIONS_CODE "")
372-
373-
# This enables regenerating the build-defs.h file on the install step
374-
# when using different install prefix at the 'cmake --install ... --prefix'
375-
# phase. Needs to be adjusted further to rebuild PHP at such case.
376-
string(CONFIGURE [[
377-
@code@
378-
configure_file(
379-
"@PHP_SOURCE_DIR@/main/cmake/build-defs.h.in"
380-
"@PHP_BINARY_DIR@/$<CONFIG>/main/build-defs.h"
381-
@ONLY
382-
)
383-
]] code @ONLY)
384-
install(CODE "${code}")
385-
endif()
375+
]] code @ONLY)
376+
install(CODE "${code}")
386377

387378
message(STATUS "Creating ${file}")
388379
file(READ main/cmake/php_config.h.in content)
389380
string(CONFIGURE "${content}" content @ONLY)
390381

391382
file(
392383
GENERATE
393-
# Multi-config generators need to write separate files.
394384
OUTPUT ${PHP_BINARY_DIR}/$<CONFIG>/main/${file}
395385
CONTENT "${content}"
396386
)

cmake/main/cmake/build-defs.h.in

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
/* The following build system related configuration values are on *nix systems
2-
defined in the main/build-defs.h header and JScript Windows build system
3-
defines them in the configuration header file (main/config.w32.h). On *nix
4-
systems these are provided as a separate header file aiming to simplify the
5-
(re)building phase when multiple configurations are used. For example, using
6-
one installation prefix for the stage installation directory and the other
7-
for production. */
1+
/* The following build system related configuration is in Autotools build system
2+
defined in the main/build-defs.h header and in JScript Windows build system
3+
in the main/config.w32.h header. These are provided as a separate header file
4+
aiming to simplify the re-build phase when multiple configurations are used.
5+
For example, using different installation prefixes for the stage and
6+
production installation directories. */
7+
8+
#ifndef _PHP_BUILD_DEFS_H
9+
#define _PHP_BUILD_DEFS_H
810

911
/* Command used for configuring PHP at build phase. */
1012
#cmakedefine CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
@@ -32,7 +34,7 @@
3234
#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
3335

3436
/* The default 'include_path' PHP INI directive. */
35-
#define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
37+
#define PHP_INCLUDE_PATH "@PHP_INCLUDE_PATH@"
3638

3739
/* The path to the directory containing system libraries (lib). */
3840
#define PHP_LIBDIR "@EXPANDED_LIBDIR@"
@@ -44,7 +46,7 @@
4446
#cmakedefine PHP_MANDIR "@PHP_MANDIR@"
4547

4648
/* The PHP installation prefix. */
47-
#define PHP_PREFIX "@prefix@"
49+
#define PHP_PREFIX "@CMAKE_INSTALL_PREFIX@"
4850

4951
/* The path to the sendmail program. PHP on Windows uses a built in mailer. */
5052
#cmakedefine PHP_PROG_SENDMAIL "@PHP_PROG_SENDMAIL@"
@@ -56,7 +58,9 @@
5658
#define PHP_SHLIB_EXT_PREFIX "@PHP_SHLIB_EXT_PREFIX@"
5759

5860
/* The file extension of the shared PHP extensions ('so', 'dll'). */
59-
#define PHP_SHLIB_SUFFIX "@SHLIB_DL_SUFFIX_NAME@"
61+
#define PHP_SHLIB_SUFFIX "@PHP_SHLIB_SUFFIX@"
6062

6163
/* The path to the directory containing read-only single-machine data (etc). */
6264
#define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@"
65+
66+
#endif

cmake/main/cmake/php_config.h.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,7 @@
700700
@ZEND_CONFIGURATION@
701701

702702
#if @PHP_CONFIG_H_WINDOWS@
703-
@PHP_BUILD_DEFINITIONS_CODE@
704-
703+
# include "build-defs.h"
705704
# if __has_include("main/config.pickle.h")
706705
# include "main/config.pickle.h"
707706
# endif

0 commit comments

Comments
 (0)