1- # Wrapper for integrating PHP sources with CMake
2- #
3- # This file uses the FetchContent module to download the PHP source code (from
4- # a tarball), integrate additional CMake files, and apply necessary patches to
5- # enable building PHP with CMake.
6- #
7- # While not part of the CMake-based build system itself, this file serves as a
8- # wrapper to bridge the upstream PHP source code with the CMake-based build
9- # system in this repository, streamlining the integration process.
1+ #[=============================================================================[
2+ Wrapper for integrating PHP sources with CMake
3+
4+ This file uses the FetchContent module to download the PHP source code (from a
5+ tarball), integrate CMake files, and apply necessary patches to enable building
6+ PHP with CMake.
7+
8+ While not part of the CMake-based build system itself, this file serves as a
9+ wrapper to bridge the upstream PHP source code with the CMake-based build system
10+ in this repository, streamlining the integration process.
11+
12+ Basic usage:
13+
14+ cmake -B <build-dir> [<options>...]
15+
16+ Configuration variables:
17+
18+ PHP_VERSION_DOWNLOAD
19+ PHP version to download. Format: <major>.<minor>[.<patch>][<extra>]
20+
21+ <OTHER_PHP_CONFIGURATION_VARIABLES>
22+ See build system documentation.
23+
24+ For example:
25+
26+ cmake -B <build-dir> -D PHP_VERSION_DOWNLOAD=8.3-dev
27+ will download PHP-8.3 Git branch archive file from GitHub.
28+
29+ cmake -B <build-dir> -D PHP_VERSION_DOWNLOAD=8.3
30+ will download latest stable 8.3 release tarball from php.net.
31+
32+ cmake -B <build-dir> -D PHP_VERSION_DOWNLOAD=8.3.15
33+ will download specific PHP version tarball from php.net.
34+ #]=============================================================================]
1035
1136cmake_minimum_required (VERSION 3.25...3.31)
1237
@@ -33,19 +58,6 @@ project(
3358################################################################################
3459
3560block(PROPAGATE phpUrl)
36- # The PHP_VERSION_DOWNLOAD format: <major>.<minor>[.<patch>][<extra>]
37- #
38- # For example:
39- #
40- # cmake -B <build-dir> -D PHP_VERSION_DOWNLOAD=8.3-dev
41- # will download PHP-8.3 Git branch archive file from GitHub.
42- #
43- # cmake -B <build-dir> -D PHP_VERSION_DOWNLOAD=8.3.15
44- # will download this specific PHP version tarball from php.net.
45- #
46- # cmake -B <build-dir> -D PHP_VERSION_DOWNLOAD=8.3
47- # will download latest stable 8.3 release tarball from php.net.
48- #
4961 set (
5062 PHP_VERSION_DOWNLOAD ${PROJECT_VERSION}
5163 CACHE STRING "The PHP version to download"
@@ -66,14 +78,24 @@ block(PROPAGATE phpUrl)
6678 string (REGEX MATCH [[^([0-9]+\.[0-9]+)]] _ "${PHP_VERSION_DOWNLOAD} " )
6779 message (
6880 FATAL_ERROR
69- "Version ${PHP_VERSION_DOWNLOAD} is not supported by the current "
70- "php-build-system Git repository branch. "
71- "Please, checkout php-build-system Git branch if available :\n "
81+ "Version ${PHP_VERSION_DOWNLOAD} is not supported by the current Git "
82+ "branch of the php-build-system repository. Please checkout the "
83+ "PHP- ${CMAKE_MATCH_1} Git branch if it exists :\n "
7284 " git checkout PHP-${CMAKE_MATCH_1} "
7385 )
7486 endif ()
7587
76- if (PHP_VERSION_DOWNLOAD STREQUAL phpDevelopmentBranch)
88+ set (branch "" )
89+ set (version "" )
90+
91+ if (PHP_VERSION_DOWNLOAD MATCHES "^${phpDevelopmentBranch} (-dev)?(.*)$" )
92+ if (CMAKE_MATCH_2)
93+ message (
94+ WARNING
95+ "PHP ${phpDevelopmentBranch} is marked as development branch. Version "
96+ "has been set to ${phpDevelopmentBranch} -dev"
97+ )
98+ endif ()
7799 set (branch "master" )
78100 elseif (PHP_VERSION_DOWNLOAD MATCHES [[^([0-9]+\.[0-9]+)-dev$]])
79101 set (branch "PHP-${CMAKE_MATCH_1} " )
@@ -94,14 +116,13 @@ block(PROPAGATE phpUrl)
94116 if (error)
95117 message (
96118 WARNING
97- "Latest PHP version could not be determined. "
98- "Setting version to ${PROJECT_VERSION} -dev.\n ${error} "
119+ "Latest PHP version could not be determined. Setting version to "
120+ "${PROJECT_VERSION} -dev.\n ${error} "
99121 )
100122 set (version "" )
101123 set (branch "PHP-${PROJECT_VERSION} " )
102124 endif ()
103125 else ()
104- set (branch "" )
105126 set (version ${PHP_VERSION_DOWNLOAD} )
106127 endif ()
107128
0 commit comments