Skip to content

Commit a008b50

Browse files
committed
Use 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. Additional changes: - Valgrind find module refactored to include a fix for the parent includedir issue - Valgrind check moved to global configure checks - When searching for php executable, suffixes are removed as this would become too difficult and increases the check time - HAVE_VALGRIND moved out of find module - Valgrind imported target needs to be INTERFACE as no library is linked
1 parent 4f6901a commit a008b50

38 files changed

+182
-164
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ else()
150150
find_path(
151151
ACL_INCLUDE_DIR
152152
NAMES sys/acl.h
153-
PATHS ${PC_ACL_INCLUDE_DIRS}
153+
HINTS ${PC_ACL_INCLUDE_DIRS}
154154
DOC "Directory containing ACL library headers"
155155
)
156156

@@ -161,7 +161,7 @@ else()
161161
find_library(
162162
ACL_LIBRARY
163163
NAMES acl
164-
PATHS ${PC_ACL_LIBRARY_DIRS}
164+
HINTS ${PC_ACL_LIBRARY_DIRS}
165165
DOC "The path to the ACL library"
166166
)
167167

cmake/cmake/modules/FindApache.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ endif()
145145
find_program(
146146
Apache_APR_CONFIG_EXECUTABLE
147147
NAMES apr-config apr-1-config
148-
PATHS ${_Apache_APR_BINDIR}
148+
HINTS ${_Apache_APR_BINDIR}
149149
DOC "Path to the apr library command-line tool for retrieving metainformation"
150150
)
151151
mark_as_advanced(Apache_APR_CONFIG_EXECUTABLE)
@@ -200,7 +200,7 @@ endif()
200200
find_path(
201201
Apache_APR_INCLUDE_DIR
202202
NAMES apr.h
203-
PATHS
203+
HINTS
204204
${PC_Apache_APR_INCLUDE_DIRS}
205205
${_Apache_APR_INCLUDE_DIR}
206206
${_Apache_APU_INCLUDE_DIR}
@@ -215,7 +215,7 @@ endif()
215215
find_library(
216216
Apache_APR_LIBRARY
217217
NAMES apr-1
218-
PATHS ${PC_Apache_APR_LIBRARY_DIRS}
218+
HINTS ${PC_Apache_APR_LIBRARY_DIRS}
219219
DOC "The path to the apr library"
220220
)
221221
mark_as_advanced(Apache_APR_LIBRARY)
@@ -231,7 +231,7 @@ endif()
231231
find_program(
232232
Apache_APU_CONFIG_EXECUTABLE
233233
NAMES apu-config apu-1-config
234-
PATHS ${_Apache_APU_BINDIR}
234+
HINTS ${_Apache_APU_BINDIR}
235235
DOC "Path to the Apache Portable Runtime Utilities config command-line tool"
236236
)
237237
mark_as_advanced(Apache_APU_CONFIG_EXECUTABLE)
@@ -270,7 +270,7 @@ endif()
270270
find_program(
271271
Apache_EXECUTABLE
272272
NAMES ${_Apache_NAME} apache2
273-
PATHS ${_Apache_SBINDIR}
273+
HINTS ${_Apache_SBINDIR}
274274
DOC "Path to the Apache HTTP server command-line utility"
275275
)
276276
mark_as_advanced(Apache_EXECUTABLE)
@@ -283,7 +283,7 @@ find_path(
283283
Apache_INCLUDE_DIR
284284
NAMES httpd.h
285285
PATH_SUFFIXES apache2
286-
PATHS ${_Apache_APXS_INCLUDE_DIR}
286+
HINTS ${_Apache_APXS_INCLUDE_DIR}
287287
DOC "Directory containing Apache headers"
288288
)
289289
mark_as_advanced(Apache_INCLUDE_DIR)

cmake/cmake/modules/FindAppArmor.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ endif()
4444
find_path(
4545
AppArmor_INCLUDE_DIR
4646
NAMES sys/apparmor.h
47-
PATHS ${PC_AppArmor_INCLUDE_DIRS}
47+
HINTS ${PC_AppArmor_INCLUDE_DIRS}
4848
DOC "Directory containing AppArmor library headers"
4949
)
5050

@@ -55,7 +55,7 @@ endif()
5555
find_library(
5656
AppArmor_LIBRARY
5757
NAMES apparmor
58-
PATHS ${PC_AppArmor_LIBRARY_DIRS}
58+
HINTS ${PC_AppArmor_LIBRARY_DIRS}
5959
DOC "The path to the AppArmor library"
6060
)
6161

cmake/cmake/modules/FindArgon2.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ endif()
4343
find_path(
4444
Argon2_INCLUDE_DIR
4545
NAMES argon2.h
46-
PATHS ${PC_Argon2_INCLUDE_DIRS}
46+
HINTS ${PC_Argon2_INCLUDE_DIRS}
4747
DOC "Directory containing Argon2 library headers"
4848
)
4949

@@ -54,7 +54,7 @@ endif()
5454
find_library(
5555
Argon2_LIBRARY
5656
NAMES argon2
57-
PATHS ${PC_Argon2_LIBRARY_DIRS}
57+
HINTS ${PC_Argon2_LIBRARY_DIRS}
5858
DOC "The path to the Argon2 library"
5959
)
6060

cmake/cmake/modules/FindCapstone.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ endif()
4343
find_path(
4444
Capstone_INCLUDE_DIR
4545
NAMES capstone/capstone.h
46-
PATHS ${PC_Capstone_INCLUDE_DIRS}
46+
HINTS ${PC_Capstone_INCLUDE_DIRS}
4747
DOC "Directory containing Capstone library headers"
4848
)
4949

@@ -54,7 +54,7 @@ endif()
5454
find_library(
5555
Capstone_LIBRARY
5656
NAMES capstone
57-
PATHS ${PC_Capstone_LIBRARY_DIRS}
57+
HINTS ${PC_Capstone_LIBRARY_DIRS}
5858
DOC "The path to the Capstone library"
5959
)
6060

cmake/cmake/modules/FindCdb.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ endif()
4444
find_path(
4545
Cdb_INCLUDE_DIR
4646
NAMES cdb.h
47-
PATHS ${PC_Cdb_INCLUDE_DIRS}
47+
HINTS ${PC_Cdb_INCLUDE_DIRS}
4848
DOC "Directory containing cdb library headers"
4949
)
5050

@@ -55,7 +55,7 @@ endif()
5555
find_library(
5656
Cdb_LIBRARY
5757
NAMES cdb
58-
PATHS ${PC_Cdb_LIBRARY_DIRS}
58+
HINTS ${PC_Cdb_LIBRARY_DIRS}
5959
DOC "The path to the cdb library"
6060
)
6161

cmake/cmake/modules/FindCrypt.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ else()
9292
find_path(
9393
Crypt_INCLUDE_DIR
9494
NAMES crypt.h unistd.h
95-
PATHS ${PC_Crypt_INCLUDE_DIRS}
95+
HINTS ${PC_Crypt_INCLUDE_DIRS}
9696
DOC "Directory containing Crypt library headers"
9797
)
9898

@@ -103,7 +103,7 @@ else()
103103
find_library(
104104
Crypt_LIBRARY
105105
NAMES crypt
106-
PATHS ${PC_Crypt_LIBRARY_DIRS}
106+
HINTS ${PC_Crypt_LIBRARY_DIRS}
107107
DOC "The path to the crypt library"
108108
)
109109

cmake/cmake/modules/FindEditline.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ endif()
4444
find_path(
4545
Editline_INCLUDE_DIR
4646
NAMES editline/readline.h
47-
PATHS ${PC_Editline_INCLUDE_DIRS}
47+
HINTS ${PC_Editline_INCLUDE_DIRS}
4848
DOC "Directory containing Editline library headers"
4949
)
5050

@@ -55,7 +55,7 @@ endif()
5555
find_library(
5656
Editline_LIBRARY
5757
NAMES edit
58-
PATHS ${PC_Editline_LIBRARY_DIRS}
58+
HINTS ${PC_Editline_LIBRARY_DIRS}
5959
DOC "The path to the Editline library"
6060
)
6161

0 commit comments

Comments
 (0)