Skip to content

Commit f0bb453

Browse files
authored
Refactor find modules (#9)
Changes: * Using HINTS instead of PATHS in find modules When pkg-config is utilized in find modules, the HINTS has precedence over PATHS. Meaning, pkg-config result is tried first and then system or default paths. And when <PackageName>_ROOT or CMAKE_PREFIX_PATH are set they have precedence over pkg-config. * Enabled version ranges handling in find modules * Valgrind: * Valgrind find module refactored to include a fix for the parent includedir issue. * Valgrind's HAVE_VALGRIND variable moved to global configure checks as it is more related to the code usage than the find module itself and to have more standardized find module. * Valgrind imported target needs to be INTERFACE as no library is linked. * When searching for php executable, suffixes are removed as this would become too difficult and increases the check time. * <PackageName>_INCLUDE_DIRS used for appending INTERFACE_INCLUDE_DIRECTORIES. * LDAP module now has components * `<PackageName>_INCLUDE_DIRS` used in most targets to append INTERFACE_INCLUDE_DIRECTORIES * Testing better places for find module sanity checks * Updated Markdown headers * s/pkgconf/pkg-config/ for easier understanding
1 parent c2804b8 commit f0bb453

File tree

93 files changed

+841
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+841
-1003
lines changed

cmake/Zend/cmake/CheckDlsym.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Some non-ELF platforms, such as OpenBSD, FreeBSD, NetBSD, Mac OSX (~10.3),
55
needed underscore character (`_`) prefix for symbols, when using `dlsym()`. This
66
module is obsolete on current platforms.
77
8-
Cache variables:
8+
## Cache variables
99
1010
* `DLSYM_NEEDS_UNDERSCORE`
1111
Whether `dlsym()` requires a leading underscore in symbol names.

cmake/Zend/cmake/CheckFloatPrecision.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Check for x87 floating point internal precision control.
33
44
See: https://wiki.php.net/rfc/rounding
55
6-
Cache variables:
6+
## Cache variables
77
88
* `HAVE__FPU_SETCW`
99
Whether `_FPU_SETCW` is usable.

cmake/Zend/cmake/CheckMMAlignment.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Test and set the alignment defines for the Zend memory manager (`ZEND_MM`). This
33
also does the logarithmic test.
44
5-
Cache variables:
5+
## Cache variables
66
77
* `ZEND_MM_ALIGNMENT`
88
* `ZEND_MM_ALIGNMENT_LOG2`

cmake/Zend/cmake/CheckStackLimit.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[=============================================================================[
22
Check whether the stack grows downwards. Assumes contiguous stack.
33
4-
Cache variables:
4+
## Cache variables
55
66
* `ZEND_CHECK_STACK_LIMIT`
77
Whether checking the stack limit is supported.

cmake/Zend/cmake/CheckStrerrorR.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Check for `strerror_r()`, and if its a POSIX-compatible or a GNU-specific
33
version.
44
5-
Cache variables:
5+
## Cache variables
66
77
* `HAVE_STRERROR_R`
88
Whether `strerror_r()` is available.

cmake/cmake/ConfigureChecks.cmake

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -504,41 +504,6 @@ if(TARGET PHP::CheckGethostbynameR)
504504
target_link_libraries(php_configuration INTERFACE PHP::CheckGethostbynameR)
505505
endif()
506506

507-
if(PHP_CCACHE)
508-
find_package(Ccache)
509-
endif()
510-
511-
# Check GCOV.
512-
if(PHP_GCOV)
513-
if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
514-
message(FATAL_ERROR "GCC is required for using PHP_GCOV='ON'")
515-
endif()
516-
517-
# Check if ccache is being used.
518-
if(CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")
519-
message(
520-
WARNING
521-
"ccache should be disabled when PHP_GCOV='ON' option is used. You can "
522-
"disable ccache by setting option PHP_CCACHE='OFF' or environment "
523-
"variable CCACHE_DISABLE=1."
524-
)
525-
endif()
526-
527-
find_package(Gcov)
528-
set_package_properties(
529-
Gcov
530-
PROPERTIES
531-
TYPE REQUIRED
532-
PURPOSE "Necessary to enable GCOV coverage report and symbols."
533-
)
534-
535-
if(TARGET Gcov::Gcov)
536-
target_link_libraries(php_configuration INTERFACE Gcov::Gcov)
537-
538-
gcov_generate_report()
539-
endif()
540-
endif()
541-
542507
################################################################################
543508
# Check for required libraries.
544509
################################################################################
@@ -820,3 +785,63 @@ block()
820785
target_link_libraries(php_configuration INTERFACE ${libgcc_path})
821786
endif()
822787
endblock()
788+
789+
################################################################################
790+
# Check for additional tools.
791+
################################################################################
792+
793+
if(PHP_CCACHE)
794+
find_package(Ccache)
795+
endif()
796+
797+
# Check GCOV.
798+
if(PHP_GCOV)
799+
if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
800+
message(FATAL_ERROR "GCC is required for using PHP_GCOV='ON'")
801+
endif()
802+
803+
if(CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")
804+
message(
805+
WARNING
806+
"ccache should be disabled when PHP_GCOV='ON' option is used. You can "
807+
"disable ccache by setting option PHP_CCACHE='OFF' or environment "
808+
"variable CCACHE_DISABLE=1."
809+
)
810+
endif()
811+
812+
find_package(Gcov)
813+
set_package_properties(
814+
Gcov
815+
PROPERTIES
816+
TYPE REQUIRED
817+
PURPOSE "Necessary to enable GCOV coverage report and symbols."
818+
)
819+
820+
if(TARGET Gcov::Gcov)
821+
target_link_libraries(php_configuration INTERFACE Gcov::Gcov)
822+
823+
gcov_generate_report()
824+
endif()
825+
endif()
826+
827+
# Check Valgrind.
828+
if(PHP_VALGRIND)
829+
find_package(Valgrind)
830+
set_package_properties(
831+
Valgrind
832+
PROPERTIES
833+
TYPE REQUIRED
834+
PURPOSE "Necessary to enable Valgrind support."
835+
)
836+
837+
if(Valgrind_FOUND)
838+
set(HAVE_VALGRIND 1)
839+
endif()
840+
841+
target_link_libraries(php_configuration INTERFACE Valgrind::Valgrind)
842+
endif()
843+
add_feature_info(
844+
"Valgrind"
845+
PHP_VALGRIND
846+
"support for dynamic analysis"
847+
)

cmake/cmake/Requirements.cmake

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,6 @@ endif()
122122
################################################################################
123123
find_package(Sendmail)
124124

125-
################################################################################
126-
# Find Valgrind.
127-
################################################################################
128-
if(PHP_VALGRIND)
129-
find_package(Valgrind)
130-
set_package_properties(
131-
Valgrind
132-
PROPERTIES
133-
TYPE REQUIRED
134-
PURPOSE "Necessary to enable Valgrind support."
135-
)
136-
137-
target_link_libraries(php_configuration INTERFACE Valgrind::Valgrind)
138-
endif()
139-
140125
################################################################################
141126
# Find PHP installed on the system for generating stub files (*_arginfo.h),
142127
# Zend/zend_vm_gen.php, ext/tokenizer/tokenizer_data_gen.php and similar where

cmake/cmake/modules/FindACL.cmake

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,25 @@ Module defines the following `IMPORTED` target(s):
55
66
* `ACL::ACL` - The package library, if found.
77
8-
Result variables:
8+
## Result variables
99
1010
* `ACL_FOUND` - Whether the package has been found.
1111
* `ACL_INCLUDE_DIRS` - Include directories needed to use this package.
1212
* `ACL_LIBRARIES` - Libraries needed to link to the package library.
1313
* `ACL_VERSION` - Package version, if found.
1414
15-
Cache variables:
15+
## Cache variables
1616
1717
* `ACL_IS_BUILT_IN` - Whether ACL is a part of the C library (BSD-based
1818
systems).
1919
* `ACL_INCLUDE_DIR` - Directory containing package library headers.
2020
* `ACL_LIBRARY` - The path to the package library.
2121
22-
Hints:
22+
## Hints
2323
24-
The `ACL_ROOT` variable adds custom search path.
25-
26-
Set `ACL_USE_USER_GROUP` to `TRUE` before calling `find_package(ACL)` to also
27-
check if the ACL library supports `ACL_USER` and `ACL_GROUP`. For example, macOS
28-
doesn't have support for user/group.
24+
* Set `ACL_USE_USER_GROUP` to `TRUE` before calling `find_package(ACL)` to also
25+
check if the ACL library supports `ACL_USER` and `ACL_GROUP`. For example,
26+
macOS doesn't have support for user/group.
2927
#]=============================================================================]
3028

3129
include(CheckSourceCompiles)
@@ -141,7 +139,7 @@ if(ACL_IS_BUILT_IN)
141139
else()
142140
set(_ACL_REQUIRED_VARS ACL_LIBRARY ACL_INCLUDE_DIR)
143141

144-
# Use pkgconf, if available on the system.
142+
# Try pkg-config.
145143
find_package(PkgConfig QUIET)
146144
if(PKG_CONFIG_FOUND)
147145
pkg_check_modules(PC_ACL QUIET libacl)
@@ -150,7 +148,7 @@ else()
150148
find_path(
151149
ACL_INCLUDE_DIR
152150
NAMES sys/acl.h
153-
PATHS ${PC_ACL_INCLUDE_DIRS}
151+
HINTS ${PC_ACL_INCLUDE_DIRS}
154152
DOC "Directory containing ACL library headers"
155153
)
156154

@@ -161,25 +159,18 @@ else()
161159
find_library(
162160
ACL_LIBRARY
163161
NAMES acl
164-
PATHS ${PC_ACL_LIBRARY_DIRS}
162+
HINTS ${PC_ACL_LIBRARY_DIRS}
165163
DOC "The path to the ACL library"
166164
)
167165

168166
if(NOT ACL_LIBRARY)
169167
string(APPEND _reason "ACL library not found. ")
170168
endif()
171169

172-
# Get version.
173-
block(PROPAGATE ACL_VERSION)
174-
# ACL headers don't provide version. Try pkgconf version, if found.
175-
if(PC_ACL_VERSION AND ACL_INCLUDE_DIR)
176-
cmake_path(COMPARE "${ACL_INCLUDE_DIR}" EQUAL "${PC_ACL_INCLUDEDIR}" isEqual)
177-
178-
if(isEqual)
179-
set(ACL_VERSION ${PC_ACL_VERSION})
180-
endif()
181-
endif()
182-
endblock()
170+
# ACL headers don't provide version. Try pkg-config.
171+
if(PC_ACL_VERSION AND ACL_INCLUDE_DIR IN_LIST PC_ACL_INCLUDE_DIRS)
172+
set(ACL_VERSION ${PC_ACL_VERSION})
173+
endif()
183174

184175
_acl_check(_acl_works)
185176

@@ -204,6 +195,7 @@ find_package_handle_standard_args(
204195
${_ACL_REQUIRED_VARS}
205196
_acl_works
206197
VERSION_VAR ACL_VERSION
198+
HANDLE_VERSION_RANGE
207199
REASON_FAILURE_MESSAGE "${_reason}"
208200
)
209201

@@ -227,11 +219,11 @@ endif()
227219
if(NOT TARGET ACL::ACL)
228220
add_library(ACL::ACL UNKNOWN IMPORTED)
229221

230-
if(ACL_INCLUDE_DIR)
222+
if(ACL_INCLUDE_DIRS)
231223
set_target_properties(
232224
ACL::ACL
233225
PROPERTIES
234-
INTERFACE_INCLUDE_DIRECTORIES "${ACL_INCLUDE_DIR}"
226+
INTERFACE_INCLUDE_DIRECTORIES "${ACL_INCLUDE_DIRS}"
235227
)
236228
endif()
237229

cmake/cmake/modules/FindApache.cmake

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Module defines the following `IMPORTED` target(s):
99
1010
* `Apache::Apache` - The package library, if found.
1111
12-
Result variables:
12+
## Result variables
1313
1414
* `Apache_FOUND` - Whether the package has been found.
1515
* `Apache_INCLUDE_DIRS` - Include directories needed to use this package.
@@ -19,7 +19,7 @@ Result variables:
1919
* `Apache_LIBEXECDIR` - Path to the directory containing all Apache modules and
2020
`httpd.exp` file (list of exported symbols).
2121
22-
Cache variables:
22+
## Cache variables
2323
2424
* `Apache_APXS_EXECUTABLE` - Path to the APache eXtenSion tool command-line tool
2525
(`apxs`).
@@ -34,10 +34,6 @@ Cache variables:
3434
* `Apache_INCLUDE_DIR` - Directory containing package library headers.
3535
* `Apache_APR_INCLUDE_DIR` - Directory containing `apr` library headers.
3636
* `Apache_APR_LIBRARY` - The path to the `apr` library.
37-
38-
Hints:
39-
40-
The `Apache_ROOT` variable adds custom search path.
4137
#]=============================================================================]
4238

4339
include(FeatureSummary)
@@ -145,7 +141,7 @@ endif()
145141
find_program(
146142
Apache_APR_CONFIG_EXECUTABLE
147143
NAMES apr-config apr-1-config
148-
PATHS ${_Apache_APR_BINDIR}
144+
HINTS ${_Apache_APR_BINDIR}
149145
DOC "Path to the apr library command-line tool for retrieving metainformation"
150146
)
151147
mark_as_advanced(Apache_APR_CONFIG_EXECUTABLE)
@@ -190,8 +186,7 @@ if(Apache_APR_CONFIG_EXECUTABLE)
190186
)
191187
endif()
192188

193-
# Find the apr library (Apache portable runtime).
194-
# Use pkgconf, if available on the system.
189+
# Try pkg-config.
195190
find_package(PkgConfig QUIET)
196191
if(PKG_CONFIG_FOUND)
197192
pkg_check_modules(PC_Apache_APR QUIET apr-1)
@@ -200,7 +195,7 @@ endif()
200195
find_path(
201196
Apache_APR_INCLUDE_DIR
202197
NAMES apr.h
203-
PATHS
198+
HINTS
204199
${PC_Apache_APR_INCLUDE_DIRS}
205200
${_Apache_APR_INCLUDE_DIR}
206201
${_Apache_APU_INCLUDE_DIR}
@@ -215,7 +210,7 @@ endif()
215210
find_library(
216211
Apache_APR_LIBRARY
217212
NAMES apr-1
218-
PATHS ${PC_Apache_APR_LIBRARY_DIRS}
213+
HINTS ${PC_Apache_APR_LIBRARY_DIRS}
219214
DOC "The path to the apr library"
220215
)
221216
mark_as_advanced(Apache_APR_LIBRARY)
@@ -231,7 +226,7 @@ endif()
231226
find_program(
232227
Apache_APU_CONFIG_EXECUTABLE
233228
NAMES apu-config apu-1-config
234-
PATHS ${_Apache_APU_BINDIR}
229+
HINTS ${_Apache_APU_BINDIR}
235230
DOC "Path to the Apache Portable Runtime Utilities config command-line tool"
236231
)
237232
mark_as_advanced(Apache_APU_CONFIG_EXECUTABLE)
@@ -270,7 +265,7 @@ endif()
270265
find_program(
271266
Apache_EXECUTABLE
272267
NAMES ${_Apache_NAME} apache2
273-
PATHS ${_Apache_SBINDIR}
268+
HINTS ${_Apache_SBINDIR}
274269
DOC "Path to the Apache HTTP server command-line utility"
275270
)
276271
mark_as_advanced(Apache_EXECUTABLE)
@@ -283,7 +278,7 @@ find_path(
283278
Apache_INCLUDE_DIR
284279
NAMES httpd.h
285280
PATH_SUFFIXES apache2
286-
PATHS ${_Apache_APXS_INCLUDE_DIR}
281+
HINTS ${_Apache_APXS_INCLUDE_DIR}
287282
DOC "Directory containing Apache headers"
288283
)
289284
mark_as_advanced(Apache_INCLUDE_DIR)
@@ -294,7 +289,7 @@ endif()
294289

295290
# Get Apache version.
296291
block(PROPAGATE Apache_VERSION)
297-
if(Apache_INCLUDE_DIR AND EXISTS ${Apache_INCLUDE_DIR}/ap_release.h)
292+
if(EXISTS ${Apache_INCLUDE_DIR}/ap_release.h)
298293
file(
299294
STRINGS
300295
${Apache_INCLUDE_DIR}/ap_release.h
@@ -397,6 +392,7 @@ find_package_handle_standard_args(
397392
Apache_APR_INCLUDE_DIR
398393
Apache_EXECUTABLE
399394
VERSION_VAR Apache_VERSION
395+
HANDLE_VERSION_RANGE
400396
REASON_FAILURE_MESSAGE "${_reason}"
401397
)
402398

0 commit comments

Comments
 (0)