2017-09-03 12:17:26 +02:00
|
|
|
#
|
2019-12-14 11:25:07 +01:00
|
|
|
# Copyright (C) 2017 Adam Saponara <as@php.net>
|
2021-01-02 21:34:16 +01:00
|
|
|
# Copyright (C) 2017-2021 Sébastien Helleu <flashcode@flashtux.org>
|
2017-09-03 12:17:26 +02:00
|
|
|
#
|
|
|
|
# This file is part of WeeChat, the extensible chat client.
|
|
|
|
#
|
|
|
|
# WeeChat is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# WeeChat is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2018-11-29 23:16:07 +01:00
|
|
|
# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-03 12:17:26 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
if(PHP_FOUND)
|
2017-09-05 01:54:50 -04:00
|
|
|
set(PHP_FIND_QUIETLY TRUE)
|
2017-09-03 12:17:26 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(PkgConfig)
|
|
|
|
if(PKG_CONFIG_FOUND)
|
2020-12-13 11:52:29 +01:00
|
|
|
pkg_search_module(PHP php8 php7)
|
2017-09-03 12:17:26 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT PHP_FOUND)
|
|
|
|
find_program(PHP_CONFIG_EXECUTABLE NAMES
|
2021-07-04 17:13:06 -04:00
|
|
|
php-config8.1 php-config81
|
2020-12-13 11:52:29 +01:00
|
|
|
php-config8.0 php-config80
|
2021-07-04 17:13:06 -04:00
|
|
|
php-config8
|
2019-12-14 11:25:07 +01:00
|
|
|
php-config7.4 php-config74
|
2018-10-16 23:02:13 +02:00
|
|
|
php-config7.3 php-config73
|
2017-09-03 12:17:26 +02:00
|
|
|
php-config7.2 php-config72
|
|
|
|
php-config7.1 php-config71
|
2017-10-14 11:10:34 +02:00
|
|
|
php-config7.0 php-config70
|
2021-07-04 17:13:06 -04:00
|
|
|
php-config7
|
|
|
|
php-config
|
2019-09-28 20:37:38 +02:00
|
|
|
)
|
2017-09-03 12:17:26 +02:00
|
|
|
if (PHP_CONFIG_EXECUTABLE)
|
|
|
|
execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE PHP_LIB_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --includes OUTPUT_VARIABLE PHP_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE PHP_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-09-05 01:54:50 -04:00
|
|
|
execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE PHP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2020-12-13 11:52:29 +01:00
|
|
|
if(${PHP_VERSION} MATCHES "^[78]")
|
2017-10-14 11:10:34 +02:00
|
|
|
find_library(PHP_LIB
|
2021-07-04 17:13:06 -04:00
|
|
|
NAMES php8.1 php8.0 php8 php7.4 php7.3 php7.2 php7.1 php7.0 php7 php
|
2019-09-28 20:37:38 +02:00
|
|
|
HINTS ${PHP_LIB_PREFIX} ${PHP_LIB_PREFIX}/lib ${PHP_LIB_PREFIX}/lib64
|
|
|
|
)
|
2017-09-17 18:19:35 -04:00
|
|
|
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)
|
2017-10-14 11:10:34 +02:00
|
|
|
set(PHP_LDFLAGS "-L${PHP_LIB_DIR} ${PHP_LIBS}")
|
2017-09-17 18:19:35 -04:00
|
|
|
set(PHP_FOUND 1)
|
|
|
|
endif()
|
2017-09-05 01:54:50 -04:00
|
|
|
endif()
|
2017-09-03 12:17:26 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
2017-09-17 18:19:35 -04:00
|
|
|
|
|
|
|
if(NOT PHP_FOUND)
|
2021-07-04 17:13:06 -04:00
|
|
|
message(WARNING "Could not find libphp. "
|
2017-09-17 18:19:35 -04:00
|
|
|
"Ensure PHP >=7.0.0 development libraries are installed and compiled with `--enable-embed`. "
|
|
|
|
"Ensure `php-config` is in `PATH`. "
|
2021-07-04 17:13:06 -04:00
|
|
|
"You may set `-DCMAKE_LIBRARY_PATH=...` to the directory containing libphp."
|
2017-09-17 18:19:35 -04:00
|
|
|
)
|
|
|
|
endif()
|