@@ -11,16 +11,17 @@ add_feature_info(
1111
1212if (PHP_PEAR)
1313  set (
14-     PHP_PEAR_DIR "" 
14+     PHP_PEAR_DIR "${CMAKE_INSTALL_DATADIR} /pear " 
1515    CACHE  FILEPATH 
16-     "Install  PEAR in DIR (PREFIX/lib/php )" 
16+     "The  PEAR installation directory (default: DATADIR/pear )" 
1717  )
1818  # Change from INTERNAL type to show variable on consecutive configuration run. 
1919  set_property (CACHE  PHP_PEAR_DIR PROPERTY TYPE  FILEPATH )
2020elseif (DEFINED  PHP_PEAR_DIR)
2121  # Hide variable. 
2222  set_property (CACHE  PHP_PEAR_DIR PROPERTY TYPE  INTERNAL )
2323endif ()
24+ mark_as_advanced (PHP_PEAR_DIR)
2425
2526message (CHECK_START "Checking for PEAR" )
2627
@@ -44,16 +45,6 @@ if(NOT EXT_XML)
4445    "PEAR requires the xml extension to be enabled. Set EXT_XML to 'ON'." )
4546endif ()
4647
47- if (NOT  PHP_PEAR_DIR)
48-   set (_php_pear_dir "\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR} /pear" )
49- else ()
50-   set (_php_pear_dir "${PHP_PEAR_DIR} " )
51- endif ()
52- 
53- # Defined for build-defs.h. 
54- # TODO: INSTALL_PREFIX here cannot be evaluated during the install phase. 
55- set (EXPANDED_PEAR_INSTALLDIR "${_php_pear_dir} "  CACHE  INTERNAL  "PEAR dir" )
56- 
5748if (NOT  CMAKE_CROSSCOMPILING )
5849  set (PHP_EXECUTABLE "$<TARGET_FILE:php_cli>" )
5950elseif (CMAKE_CROSSCOMPILING  AND  CMAKE_CROSSCOMPILING_EMULATOR)
@@ -63,7 +54,16 @@ endif()
6354set (_phpPearInstallerUrl "https://pear.php.net/install-pear-nozlib.phar" )
6455
6556php_install(CODE " 
66-   message(STATUS \" Installing PEAR: \$ ENV{DESTDIR}${_php_pear_dir} \" ) 
57+   set( 
58+     pearInstallDir 
59+     \" $<PATH:ABSOLUTE_PATH,NORMALIZE,${PHP_PEAR_DIR} ,\$ {CMAKE_INSTALL_PREFIX}>\"  
60+   ) 
61+   set( 
62+     binDir 
63+     \" $<PATH:ABSOLUTE_PATH,NORMALIZE,${CMAKE_INSTALL_BINDIR} ,\$ {CMAKE_INSTALL_PREFIX}>\"  
64+   ) 
65+ 
66+   message(STATUS \" Installing PEAR to \$ ENV{DESTDIR}\$ {pearInstallDir}\" ) 
6767
6868  if(EXISTS \" ${CMAKE_CURRENT_SOURCE_DIR} /install-pear-nozlib.phar\"  
6969    AND NOT \" ${CMAKE_CURRENT_SOURCE_DIR} \"  STREQUAL \" ${CMAKE_CURRENT_BINARY_DIR} \"  
@@ -89,7 +89,7 @@ php_install(CODE "
8989      execute_process( 
9090        COMMAND ${PHP_EXECUTABLE}  
9191          -n 
92-           ${CMAKE_CURRENT_BINARY_DIR } /fetch.php 
92+           ${CMAKE_CURRENT_SOURCE_DIR } /fetch.php 
9393            ${_phpPearInstallerUrl}  
9494            ${CMAKE_CURRENT_BINARY_DIR} /install-pear-nozlib.phar 
9595        OUTPUT_VARIABLE output 
@@ -110,14 +110,15 @@ php_install(CODE "
110110      set(ENV{INSTALL_ROOT} \"\$ ENV{DESTDIR}\" ) 
111111    endif() 
112112
113-     # The PEAR's --config option doesn't seem to install the pear.conf into the 
114-     # specified directory, but the sysconf can be also bypassed with the 
115-     # environment variable. 
113+     # The PEAR sysconf directory by default matches the PHP SYSCONFDIR and it 
114+     # doesn't seem that any configuration option installs the pear.conf into the 
115+     # manually specified directory. But the sysconf can be also bypassed with 
116+     # the environment variable for the installation time. 
116117    set(ENV{PHP_PEAR_SYSCONF_DIR} \$ {CMAKE_INSTALL_FULL_SYSCONFDIR}) 
117118
118119    file( 
119120      MAKE_DIRECTORY 
120-       \$ ENV{DESTDIR}${_php_pear_dir } 
121+       \$ ENV{DESTDIR}\$ {pearInstallDir } 
121122      ${CMAKE_CURRENT_BINARY_DIR} /CMakeFiles/pear 
122123    ) 
123124
@@ -130,12 +131,12 @@ php_install(CODE "
130131        -dmemory_limit=-1 
131132        -ddetect_unicode=0 
132133        ${CMAKE_CURRENT_BINARY_DIR} /install-pear-nozlib.phar 
133-           --dir \" ${_php_pear_dir }\"  
134-           --bin \"\$ {CMAKE_INSTALL_FULL_BINDIR }\"  
135-           --metadata \" ${_php_pear_dir }\"  
136-           --data \" ${_php_pear_dir }\"  
134+           --dir \"\$  {pearInstallDir }\"  
135+           --bin \"\$ {binDir }\"  
136+           --metadata \"\$  {pearInstallDir }\"  
137+           --data \"\$  {pearInstallDir }\"  
137138          --temp \" ${CMAKE_CURRENT_BINARY_DIR} /CMakeFiles/pear\"  
138-           # --php \$ {CMAKE_INSTALL_FULL_BINDIR }/$<TARGET_FILE_NAME:php_cli> 
139+           --php \$ {binDir }/$<TARGET_FILE_NAME:php_cli> 
139140          -dp a${PHP_PROGRAM_PREFIX}  
140141          -ds a${PHP_PROGRAM_SUFFIX}  
141142      OUTPUT_VARIABLE output 
0 commit comments