Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions cmake/Zend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ target_link_libraries(zend PRIVATE PHP::configuration)
target_include_directories(
zend
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

target_compile_definitions(
Expand All @@ -318,23 +318,35 @@ set_target_properties(
ZEND_MODULE_API_NO ${Zend_VERSION_MODULE_API_NO}
)

# Add Zend PUBLIC/INTERFACE compile properties to configuration.
################################################################################
# Add usage requirements to PHP interface targets.
################################################################################

# Cleaner COMPILE_ONLY generator expression is available in CMake >= 3.27.
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)
target_link_libraries(php_configuration INTERFACE $<COMPILE_ONLY:zend>)
target_link_libraries(php_configuration INTERFACE $<COMPILE_ONLY:Zend::Zend>)
else()
target_include_directories(
target_compile_definitions(
php_configuration
INTERFACE
$<TARGET_PROPERTY:zend,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_definitions(
target_compile_options(
php_configuration
INTERFACE
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_COMPILE_OPTIONS>
)
target_include_directories(
php_configuration
INTERFACE
$<TARGET_PROPERTY:zend,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
endif()

target_link_libraries(php_sapi INTERFACE Zend::Zend)
target_sources(php_sapi INTERFACE $<TARGET_OBJECTS:Zend::Zend>)

################################################################################
# TSRM (Thread Safe Resource Manager) is a separate directory in php-src as it
# was once a standalone project. Ideally, it should be moved into Zend Engine at
Expand Down
7 changes: 0 additions & 7 deletions cmake/Zend/cmake/MaxExecutionTimers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ add_feature_info(
"enhanced timeout and signal handling"
)

# Set the result variable also in the PARENT_SCOPE, to make it available for the
# parent project PHP in its configuration headers. This module is included in
# the Zend Engine which is added with add_subdirectory() in the PHP project.
if(NOT PROJECT_IS_TOP_LEVEL)
set(ZEND_MAX_EXECUTION_TIMERS ${ZEND_MAX_EXECUTION_TIMERS} PARENT_SCOPE)
endif()

add_library(Zend::MaxExecutionTimers INTERFACE IMPORTED GLOBAL)
if(libraryForTimerCreate)
target_link_libraries(
Expand Down
7 changes: 6 additions & 1 deletion cmake/cmake/Bootstrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include(PHP/InterproceduralOptimization)
# Set CMAKE_POSITION_INDEPENDENT_CODE.
include(PHP/PositionIndependentCode)

# Create a project wide INTERFACE library with project configuration.
# INTERFACE library with usage requirements.
add_library(php_configuration INTERFACE)
add_library(PHP::configuration ALIAS php_configuration)
target_include_directories(
Expand All @@ -43,6 +43,11 @@ target_include_directories(
${PHP_SOURCE_DIR}
)

# INTERFACE library that ties objects and configuration together for PHP SAPIs.
add_library(php_sapi INTERFACE)
add_library(PHP::SAPI ALIAS php_sapi)
target_link_libraries(php_sapi INTERFACE PHP::configuration)

# Create a custom target for generating files (parsers, lexers, etc.) manually:
# cmake --build <dir> -t php_generate_files
add_custom_target(php_generate_files)
Expand Down
80 changes: 78 additions & 2 deletions cmake/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ if(PHP_GCOV)
endif()
endif()

# Check Valgrind.
# Valgrind.
if(PHP_VALGRIND)
find_package(Valgrind)
set_package_properties(
Expand All @@ -836,6 +836,82 @@ if(PHP_VALGRIND)
endif()
add_feature_info(
"Valgrind"
PHP_VALGRIND
HAVE_VALGRIND
"dynamic analysis"
)

# DTrace.
if(PHP_DTRACE)
message(CHECK_START "Checking for DTrace support")

find_package(DTrace)
set_package_properties(
DTrace
PROPERTIES
TYPE REQUIRED
PURPOSE "Necessary to enable the DTrace support."
)

if(DTrace_FOUND)
dtrace_target(
php_dtrace
INPUT ${PHP_SOURCE_DIR}/Zend/zend_dtrace.d
HEADER ${PHP_BINARY_DIR}/Zend/zend_dtrace_gen.h
SOURCES
${PHP_SOURCE_DIR}/main/main.c
${PHP_SOURCE_DIR}/Zend/zend_API.c
${PHP_SOURCE_DIR}/Zend/zend_dtrace.c
${PHP_SOURCE_DIR}/Zend/zend_exceptions.c
${PHP_SOURCE_DIR}/Zend/zend_execute.c
${PHP_SOURCE_DIR}/Zend/zend.c
INCLUDES
$<TARGET_PROPERTY:PHP::configuration,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(php_configuration INTERFACE DTrace::DTrace)
target_link_libraries(php_sapi INTERFACE php_dtrace)

set(HAVE_DTRACE TRUE)

message(CHECK_PASS "yes")
else()
message(CHECK_FAIL "no")
endif()
endif()
add_feature_info(
"DTrace"
HAVE_DTRACE
"performance analysis and troubleshooting"
)

# Dmalloc.
if(PHP_DMALLOC)
message(CHECK_START "Checking for Dmalloc support")

find_package(Dmalloc)
set_package_properties(
Dmalloc
PROPERTIES
TYPE REQUIRED
PURPOSE "Necessary to use Dmalloc memory debugger."
)

target_compile_definitions(
php_configuration
INTERFACE
$<$<COMPILE_LANGUAGE:ASM,C,CXX>:DMALLOC_FUNC_CHECK>
)

target_link_libraries(php_configuration INTERFACE Dmalloc::Dmalloc)

if(Dmalloc_FOUND)
message(CHECK_PASS "yes")
set(HAVE_DMALLOC TRUE)
else()
message(CHECK_FAIL "no")
endif()
endif()
add_feature_info(
"Dmalloc"
HAVE_DMALLOC
"memory debugging"
)
16 changes: 9 additions & 7 deletions cmake/cmake/modules/FindGcov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,29 @@ macro(gcov_generate_report)
)

# Create a list of PHP SAPIs with genex for usage in the add_custom_command.
block(PROPAGATE php_sapis)
set(php_sapis "")
block(PROPAGATE sapis)
set(sapis "")
file(GLOB directories ${PROJECT_SOURCE_DIR}/sapi/*)
foreach(dir ${directories})
cmake_path(GET dir FILENAME sapi)
list(APPEND php_sapis "$<TARGET_NAME_IF_EXISTS:php_${sapi}>")
list(APPEND sapis "$<TARGET_NAME_IF_EXISTS:php_${sapi}>")
endforeach()
endblock()

add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/php_lcov.info
COMMAND ${CMAKE_COMMAND} -P "CMakeFiles/GenerateGcovReport.cmake"
DEPENDS
${php_sapis}
DEPENDS ${sapis}
COMMENT "[GCOV] Generating GCOV coverage report"
VERBATIM
COMMAND_EXPAND_LISTS
)

unset(php_sapis)
unset(sapis)

# Create target which consumes the command via DEPENDS.
add_custom_target(gcov ALL
add_custom_target(
gcov ALL
DEPENDS ${PROJECT_BINARY_DIR}/php_lcov.info
COMMENT "[GCOV] Generating GCOV files"
)
Expand Down
18 changes: 11 additions & 7 deletions cmake/cmake/modules/PHP/Extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,17 @@ function(php_extensions_postconfigure extension)
"'ON'."
)

set(
EXT_${dependencyUpper}
ON
CACHE BOOL
"Enable the ${dependency} extension"
FORCE
)
if(DEFINED CACHE{EXT_${dependencyUpper}})
set_property(CACHE EXT_${dependencyUpper} PROPERTY VALUE ON)
else()
set(
EXT_${dependencyUpper}
ON
CACHE BOOL
"Enable the ${dependency} extension"
FORCE
)
endif()
endforeach()

if(NOT TARGET PHP::${extension})
Expand Down
20 changes: 4 additions & 16 deletions cmake/ext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#[=============================================================================[
Add subdirectories of PHP extensions.

## INTERFACE target

* `php_extensions` (alias `PHP::extensions`) is an INTERFACE library with all
enabled extensions linked into for convenience.
#]=============================================================================]

include(PHP/Extensions)
Expand Down Expand Up @@ -57,9 +52,6 @@ set_property(GLOBAL PROPERTY PHP_ALL_EXTENSIONS ${extensions})
# Sort and preconfigure extensions by their dependencies.
php_extensions_preprocess(extensions)

add_library(php_extensions INTERFACE)
add_library(PHP::extensions ALIAS php_extensions)

# Add subdirectories of extensions.
foreach(extension IN LISTS extensions)
list(APPEND CMAKE_MESSAGE_CONTEXT "${extension}")
Expand All @@ -80,9 +72,7 @@ foreach(extension IN LISTS extensions)

add_dependencies(php_${extension} Zend::Zend)

# Add extension's transitive compile and link properties to configuration.
# The INTERFACE_SOURCES are propagated separately only to PHP::PHP.
# See: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
# Add usage requirements to PHP interface targets.
# TODO: Should PHP_CLI extensions pass properties only to PHP_CLI SAPIs?
get_target_property(type php_${extension} TYPE)
if(NOT type MATCHES "^(MODULE|SHARED)_LIBRARY$")
Expand Down Expand Up @@ -112,17 +102,15 @@ foreach(extension IN LISTS extensions)
)

target_link_libraries(
php_extensions
php_sapi
INTERFACE
$<IF:$<BOOL:$<TARGET_GENEX_EVAL:PHP::${extension},$<TARGET_PROPERTY:PHP::${extension},PHP_CLI>>>,$<$<BOOL:$<TARGET_PROPERTY:PHP_CLI>>:$<LINK_ONLY:PHP::${extension}>>,$<LINK_ONLY:PHP::${extension}>>
$<IF:$<BOOL:$<TARGET_GENEX_EVAL:PHP::${extension},$<TARGET_PROPERTY:PHP::${extension},PHP_CLI>>>,$<$<BOOL:$<TARGET_PROPERTY:PHP_CLI>>:PHP::${extension}>,PHP::${extension}>
)

target_sources(
php_extensions
php_sapi
INTERFACE
$<IF:$<BOOL:$<TARGET_GENEX_EVAL:PHP::${extension},$<TARGET_PROPERTY:PHP::${extension},PHP_CLI>>>,$<$<BOOL:$<TARGET_PROPERTY:PHP_CLI>>:$<TARGET_OBJECTS:PHP::${extension}>>,$<TARGET_OBJECTS:PHP::${extension}>>

$<IF:$<BOOL:$<TARGET_GENEX_EVAL:PHP::${extension},$<TARGET_PROPERTY:PHP::${extension},PHP_CLI>>>,$<$<BOOL:$<TARGET_PROPERTY:PHP_CLI>>:$<TARGET_PROPERTY:PHP::${extension},INTERFACE_SOURCES>>,$<TARGET_PROPERTY:PHP::${extension},INTERFACE_SOURCES>>
)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/ext/skeleton/cmake/modules/FindPHP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Components:
Module defines the following `IMPORTED` target(s):

* `PHP::php` - The PHP package `IMPORTED` target, if found.
* `PHP:embed` - The PHP embed SAPI, if found.
* `PHP::embed` - The PHP embed SAPI, if found.

## Result variables

Expand Down
35 changes: 11 additions & 24 deletions cmake/ext/standard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -534,42 +534,26 @@ endblock()

check_symbol_exists(chroot "unistd.h" HAVE_CHROOT)

add_library(php_standard_functions_cli OBJECT)
add_library(php_standard_functions OBJECT)
add_library(php_standard_functions_cli OBJECT)

target_sources(php_standard_functions_cli PRIVATE basic_functions.c dir.c)
target_sources(php_standard_functions PRIVATE basic_functions.c dir.c)
target_sources(php_standard_functions_cli PRIVATE basic_functions.c dir.c)

target_include_directories(
php_standard_functions_cli
PRIVATE
$<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES>
)
target_include_directories(
set_target_properties(
php_standard_functions
PRIVATE
$<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES>
php_standard_functions_cli
PROPERTIES
INCLUDE_DIRECTORIES $<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES>
COMPILE_DEFINITIONS $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS>
LINK_LIBRARIES $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES>
)

target_compile_definitions(
php_standard_functions_cli
PRIVATE
$<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS>
$<$<NOT:$<PLATFORM_ID:Windows>>:ENABLE_CHROOT_FUNC>
)
target_compile_definitions(
php_standard_functions
PRIVATE $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS>
)

target_link_libraries(
php_standard_functions_cli
PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES>
)
target_link_libraries(
php_standard_functions
PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES>
)

# ext/standard functions objects based on the SAPI type.
target_sources(
Expand All @@ -578,6 +562,9 @@ target_sources(
$<IF:$<BOOL:$<TARGET_PROPERTY:PHP_CLI>>,$<TARGET_OBJECTS:php_standard_functions_cli>,$<TARGET_OBJECTS:php_standard_functions>>
)

add_dependencies(php_standard_functions php_standard)
add_dependencies(php_standard_functions_cli php_standard)

################################################################################
# Configuration header
################################################################################
Expand Down
Loading
Loading