Skip to content

Commit 2b1782d

Browse files
committed
Refactor targets and usage requirements
- MAX_EXECUTION_TIMERS don't need to be set in PARENT_SCOPE anymore - Reorder some include directories - DTrace and Dmalloc checks moved to configure checks - usage requirements in main and win32 collected through interface targets directly otherwise cyclic dependencies quickly pop up
1 parent d692712 commit 2b1782d

File tree

7 files changed

+132
-217
lines changed

7 files changed

+132
-217
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ target_link_libraries(zend PRIVATE PHP::configuration)
298298
target_include_directories(
299299
zend
300300
INTERFACE
301-
${CMAKE_CURRENT_SOURCE_DIR}
302301
${CMAKE_CURRENT_BINARY_DIR}
302+
${CMAKE_CURRENT_SOURCE_DIR}
303303
)
304304

305305
target_compile_definitions(
@@ -319,7 +319,7 @@ set_target_properties(
319319
)
320320

321321
################################################################################
322-
# Add transitive compile and link properties to PHP configuration interface.
322+
# Add usage requirements to PHP interface targets.
323323
################################################################################
324324

325325
# Cleaner COMPILE_ONLY generator expression is available in CMake >= 3.27.
@@ -340,11 +340,7 @@ else()
340340
php_configuration
341341
INTERFACE
342342
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_INCLUDE_DIRECTORIES>
343-
)
344-
target_link_libraries(
345-
php_configuration
346-
INTERFACE
347-
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_LINK_LIBRARIES>
343+
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
348344
)
349345
endif()
350346

cmake/Zend/cmake/MaxExecutionTimers.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ add_feature_info(
8686
"enhanced timeout and signal handling"
8787
)
8888

89-
# Set the result variable also in the PARENT_SCOPE, to make it available for the
90-
# parent project PHP in its configuration headers. This module is included in
91-
# the Zend Engine which is added with add_subdirectory() in the PHP project.
92-
if(NOT PROJECT_IS_TOP_LEVEL)
93-
set(ZEND_MAX_EXECUTION_TIMERS ${ZEND_MAX_EXECUTION_TIMERS} PARENT_SCOPE)
94-
endif()
95-
9689
add_library(Zend::MaxExecutionTimers INTERFACE IMPORTED GLOBAL)
9790
if(libraryForTimerCreate)
9891
target_link_libraries(

cmake/cmake/ConfigureChecks.cmake

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ if(PHP_GCOV)
818818
endif()
819819
endif()
820820

821-
# Check Valgrind.
821+
# Valgrind.
822822
if(PHP_VALGRIND)
823823
find_package(Valgrind)
824824
set_package_properties(
@@ -836,6 +836,82 @@ if(PHP_VALGRIND)
836836
endif()
837837
add_feature_info(
838838
"Valgrind"
839-
PHP_VALGRIND
839+
HAVE_VALGRIND
840840
"dynamic analysis"
841841
)
842+
843+
# DTrace.
844+
if(PHP_DTRACE)
845+
message(CHECK_START "Checking for DTrace support")
846+
847+
find_package(DTrace)
848+
set_package_properties(
849+
DTrace
850+
PROPERTIES
851+
TYPE REQUIRED
852+
PURPOSE "Necessary to enable the DTrace support."
853+
)
854+
855+
if(DTrace_FOUND)
856+
dtrace_target(
857+
php_dtrace
858+
INPUT ${PHP_SOURCE_DIR}/Zend/zend_dtrace.d
859+
HEADER ${PHP_BINARY_DIR}/Zend/zend_dtrace_gen.h
860+
SOURCES
861+
${PHP_SOURCE_DIR}/main/main.c
862+
${PHP_SOURCE_DIR}/Zend/zend_API.c
863+
${PHP_SOURCE_DIR}/Zend/zend_dtrace.c
864+
${PHP_SOURCE_DIR}/Zend/zend_exceptions.c
865+
${PHP_SOURCE_DIR}/Zend/zend_execute.c
866+
${PHP_SOURCE_DIR}/Zend/zend.c
867+
INCLUDES
868+
$<TARGET_PROPERTY:PHP::configuration,INTERFACE_INCLUDE_DIRECTORIES>
869+
)
870+
target_link_libraries(php_configuration INTERFACE DTrace::DTrace)
871+
target_link_libraries(php_sapi INTERFACE php_dtrace)
872+
873+
set(HAVE_DTRACE TRUE)
874+
875+
message(CHECK_PASS "yes")
876+
else()
877+
message(CHECK_FAIL "no")
878+
endif()
879+
endif()
880+
add_feature_info(
881+
"DTrace"
882+
HAVE_DTRACE
883+
"performance analysis and troubleshooting"
884+
)
885+
886+
# Dmalloc.
887+
if(PHP_DMALLOC)
888+
message(CHECK_START "Checking for Dmalloc support")
889+
890+
find_package(Dmalloc)
891+
set_package_properties(
892+
Dmalloc
893+
PROPERTIES
894+
TYPE REQUIRED
895+
PURPOSE "Necessary to use Dmalloc memory debugger."
896+
)
897+
898+
target_compile_definitions(
899+
php_configuration
900+
INTERFACE
901+
$<$<COMPILE_LANGUAGE:ASM,C,CXX>:DMALLOC_FUNC_CHECK>
902+
)
903+
904+
target_link_libraries(php_configuration INTERFACE Dmalloc::Dmalloc)
905+
906+
if(Dmalloc_FOUND)
907+
message(CHECK_PASS "yes")
908+
set(HAVE_DMALLOC TRUE)
909+
else()
910+
message(CHECK_FAIL "no")
911+
endif()
912+
endif()
913+
add_feature_info(
914+
"Dmalloc"
915+
HAVE_DMALLOC
916+
"memory debugging"
917+
)

cmake/ext/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ foreach(extension IN LISTS extensions)
7272

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

75-
# Add transitive compile and link properties to PHP configuration interface.
75+
# Add usage requirements to PHP interface targets.
7676
# TODO: Should PHP_CLI extensions pass properties only to PHP_CLI SAPIs?
7777
get_target_property(type php_${extension} TYPE)
7878
if(NOT type MATCHES "^(MODULE|SHARED)_LIBRARY$")

cmake/ext/standard/CMakeLists.txt

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -534,42 +534,26 @@ endblock()
534534

535535
check_symbol_exists(chroot "unistd.h" HAVE_CHROOT)
536536

537-
add_library(php_standard_functions_cli OBJECT)
538537
add_library(php_standard_functions OBJECT)
538+
add_library(php_standard_functions_cli OBJECT)
539539

540-
target_sources(php_standard_functions_cli PRIVATE basic_functions.c dir.c)
541540
target_sources(php_standard_functions PRIVATE basic_functions.c dir.c)
541+
target_sources(php_standard_functions_cli PRIVATE basic_functions.c dir.c)
542542

543-
target_include_directories(
544-
php_standard_functions_cli
545-
PRIVATE
546-
$<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES>
547-
)
548-
target_include_directories(
543+
set_target_properties(
549544
php_standard_functions
550-
PRIVATE
551-
$<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES>
545+
php_standard_functions_cli
546+
PROPERTIES
547+
INCLUDE_DIRECTORIES $<TARGET_PROPERTY:php_standard,INCLUDE_DIRECTORIES>
548+
COMPILE_DEFINITIONS $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS>
549+
LINK_LIBRARIES $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES>
552550
)
553551

554552
target_compile_definitions(
555553
php_standard_functions_cli
556554
PRIVATE
557-
$<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS>
558555
$<$<NOT:$<PLATFORM_ID:Windows>>:ENABLE_CHROOT_FUNC>
559556
)
560-
target_compile_definitions(
561-
php_standard_functions
562-
PRIVATE $<TARGET_PROPERTY:php_standard,COMPILE_DEFINITIONS>
563-
)
564-
565-
target_link_libraries(
566-
php_standard_functions_cli
567-
PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES>
568-
)
569-
target_link_libraries(
570-
php_standard_functions
571-
PRIVATE $<TARGET_PROPERTY:php_standard,LINK_LIBRARIES>
572-
)
573557

574558
# ext/standard functions objects based on the SAPI type.
575559
target_sources(

0 commit comments

Comments
 (0)