Skip to content

Commit 875b38a

Browse files
committed
Add CMakeLists.txt to ext and sapi directories
This is initial refactoring and simplification for extensions and SAPIs.
1 parent b39ab2a commit 875b38a

File tree

16 files changed

+170
-178
lines changed

16 files changed

+170
-178
lines changed

bin/check-cmake.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,8 @@ function getProjectModules(): array
213213
],
214214
'PHP/CheckCompilerFlag' => ['php_check_compiler_flag'],
215215
'PHP/ConfigureFile' => ['php_configure_file'],
216-
'PHP/Extensions' => ['php_extensions_add'],
217216
'PHP/Install' => ['php_install'],
218217
'PHP/PkgConfigGenerator' => ['pkgconfig_generate_pc'],
219-
'PHP/SAPIs' => ['php_sapis_add'],
220218
'PHP/SearchLibraries' => ['php_search_libraries'],
221219
'PHP/Set' => ['php_set'],
222220
'PHP/SystemExtensions' => ['PHP::SystemExtensions'],

cmake/CMakeLists.txt

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ cmake_minimum_required(VERSION 3.25...3.31)
33
# Configure CMake behavior.
44
include(cmake/CMakeDefaults.cmake)
55

6-
message("
7-
Initializing PHP build system
8-
-----------------------------
9-
")
6+
message(
7+
STATUS
8+
"-----------------------------
9+
Initializing PHP build system
10+
-----------------------------"
11+
)
1012

1113
message(STATUS "CMake version: ${CMAKE_VERSION}")
1214
message(STATUS "CMake generator: ${CMAKE_GENERATOR}")
@@ -28,30 +30,16 @@ set(CMAKE_C_STANDARD_REQUIRED TRUE)
2830
# Configure project.
2931
include(cmake/Bootstrap.cmake)
3032

31-
message("
32-
Configuring PHP SAPI modules
33-
----------------------------
34-
")
35-
include(PHP/SAPIs)
36-
php_sapis_add(sapi)
37-
38-
message("
39-
Configuring PHP extensions
40-
--------------------------
41-
")
42-
include(PHP/Extensions)
43-
php_extensions_add(ext)
44-
45-
message("
46-
Configuring Zend engine
47-
-----------------------
48-
")
33+
add_subdirectory(sapi)
34+
add_subdirectory(ext)
4935
add_subdirectory(Zend)
5036

51-
message("
52-
Configuring PHP
53-
---------------
54-
")
37+
message(
38+
STATUS
39+
"---------------
40+
Configuring PHP
41+
---------------"
42+
)
5543
add_subdirectory(pear)
5644
add_subdirectory(TSRM)
5745
add_subdirectory(win32)
@@ -92,9 +80,9 @@ include(cmake/CPack.cmake)
9280

9381
include(PHP/FeatureSummary)
9482

95-
message("
96-
License
97-
-------
83+
message(
84+
STATUS
85+
[[License
9886

9987
This software is subject to the PHP License, available in this
10088
distribution in the file LICENSE. By continuing this installation
@@ -103,4 +91,5 @@ If you do not agree with the terms of this license, you must abort
10391
the installation process at this point.
10492

10593
Thank you for using PHP.
106-
")
94+
]]
95+
)

cmake/Zend/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# Zend engine.
33
################################################################################
44

5+
message(
6+
STATUS
7+
"-----------------------
8+
Configuring Zend engine
9+
-----------------------"
10+
)
11+
512
# Read the Zend engine version.
613
block(PROPAGATE Zend_VERSION Zend_VERSION_LABEL)
714
file(READ zend.h content)

cmake/cmake/Bootstrap.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ include(cmake/Configuration.cmake)
4646
# Check requirements.
4747
include(cmake/Requirements.cmake)
4848

49-
message("
50-
Running system checks
51-
---------------------
52-
")
49+
message(
50+
STATUS
51+
"---------------------
52+
Running system checks
53+
---------------------"
54+
)
5355

5456
# Run PHP configuration checks.
5557
include(cmake/ConfigureChecks.cmake)

cmake/cmake/modules/PHP/Extensions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ function(_php_extensions_get directory result)
182182

183183
foreach(path ${paths})
184184
cmake_path(GET path PARENT_PATH dir)
185+
cmake_path(SET dir NORMALIZE ${dir})
185186
list(APPEND directories "${dir}")
186187

187188
# Add extension name to a list of all extensions.

cmake/cmake/modules/PHP/FeatureSummary.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ include_guard(GLOBAL)
1313

1414
include(FeatureSummary)
1515

16-
message("
17-
Summary
18-
-------
19-
")
16+
message(
17+
STATUS
18+
"-----------
19+
PHP summary
20+
-----------"
21+
)
2022

2123
# Output enabled features.
2224
block()

cmake/cmake/modules/PHP/SAPIs.cmake

Lines changed: 0 additions & 96 deletions
This file was deleted.

cmake/ext/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[=============================================================================[
2+
Add subdirectories of PHP extensions.
3+
#]=============================================================================]
4+
5+
message(
6+
STATUS
7+
"--------------------------
8+
Configuring PHP extensions
9+
--------------------------"
10+
)
11+
12+
include(PHP/Extensions)
13+
php_extensions_add(.)

cmake/sapi/CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#[=============================================================================[
2+
Add subdirectories of PHP SAPIs.
3+
4+
## Custom CMake properties
5+
6+
* `PHP_ALL_SAPIS`
7+
8+
Global property with a list of all PHP SAPIs in the sapi directory.
9+
10+
* `PHP_SAPIS`
11+
12+
Global property with a list of all enabled PHP SAPIs.
13+
#]=============================================================================]
14+
15+
message(
16+
STATUS
17+
"----------------------------
18+
Configuring PHP SAPI modules
19+
----------------------------"
20+
)
21+
22+
list(APPEND CMAKE_MESSAGE_CONTEXT "sapi")
23+
24+
# Traverse CMakeLists.txt files of PHP SAPIs.
25+
file(GLOB sapis ${CMAKE_CURRENT_SOURCE_DIR}/*/CMakeLists.txt)
26+
list(TRANSFORM sapis REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/|/CMakeLists.txt" "")
27+
set_property(GLOBAL PROPERTY PHP_ALL_SAPIS ${sapis})
28+
29+
get_directory_property(processed SUBDIRECTORIES)
30+
list(TRANSFORM processed REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "")
31+
32+
foreach(sapi IN LISTS sapis)
33+
if(NOT sapi IN_LIST processed)
34+
list(APPEND CMAKE_MESSAGE_CONTEXT "${sapi}")
35+
add_subdirectory("${sapi}")
36+
list(POP_BACK CMAKE_MESSAGE_CONTEXT)
37+
endif()
38+
39+
if(TARGET php_${sapi})
40+
set_property(GLOBAL APPEND PROPERTY PHP_SAPIS ${sapi})
41+
endif()
42+
endforeach()
43+
44+
# Check if at least one SAPI is enabled.
45+
get_cmake_property(sapis PHP_SAPIS)
46+
if(NOT sapis)
47+
message(
48+
WARNING
49+
"None of the PHP SAPIs have been enabled. If this is intentional, you "
50+
"can disregard this warning."
51+
)
52+
endif()

cmake/sapi/apache2handler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ endif()
2626
message(CHECK_PASS "enabled")
2727

2828
add_library(php_apache2handler SHARED)
29+
add_library(PHP::apache2handler ALIAS php_apache2handler)
2930

3031
target_sources(
3132
php_apache2handler

0 commit comments

Comments
 (0)