|
| 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() |
0 commit comments