From 25f79ff2f54c495c5648324dff6e0415d0d4e2d3 Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Sun, 17 Sep 2017 18:19:35 -0400 Subject: [PATCH] php: use find_library to find libphp7.so --- cmake/FindPHP.cmake | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cmake/FindPHP.cmake b/cmake/FindPHP.cmake index 955862943..3e2e64a46 100644 --- a/cmake/FindPHP.cmake +++ b/cmake/FindPHP.cmake @@ -38,10 +38,22 @@ if(NOT PHP_FOUND) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE PHP_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE PHP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) if(${PHP_VERSION} MATCHES "^7") - string(REPLACE "-I" "" PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIRS}) - SEPARATE_ARGUMENTS(PHP_INCLUDE_DIRS) - set(PHP_LDFLAGS "-L${PHP_LIB_PREFIX}/lib/ ${PHP_LIBS} -lphp7") - set(PHP_FOUND 1) + find_library(PHP_LIB php7 HINTS ${PHP_LIB_PREFIX} ${PHP_LIB_PREFIX}/lib ${PHP_LIB_PREFIX}/lib64) + if(PHP_LIB) + get_filename_component(PHP_LIB_DIR ${PHP_LIB} DIRECTORY) + string(REPLACE "-I" "" PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIRS}) + SEPARATE_ARGUMENTS(PHP_INCLUDE_DIRS) + set(PHP_LDFLAGS "-L${PHP_LIB_DIR} ${PHP_LIBS} -lphp7") + set(PHP_FOUND 1) + endif() endif() endif() endif() + +if(NOT PHP_FOUND) + message(WARNING "Could not find libphp7. " + "Ensure PHP >=7.0.0 development libraries are installed and compiled with `--enable-embed`. " + "Ensure `php-config` is in `PATH`. " + "You may set `-DCMAKE_LIBRARY_PATH=...` to the directory containing libphp7." + ) +endif()