Skip to content

Commit a1834f4

Browse files
committed
Fix CMake versions prior to 3.27
1 parent 8a7ca99 commit a1834f4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cmake/cmake/modules/PHP/PkgConfigGenerator.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,25 @@ function(_pkgconfig_parse_variables variables)
100100
endif()
101101

102102
list(APPEND result_variables ${var})
103-
list(APPEND result_values "${value}")
103+
104+
# The result_values are for the install(CODE) and generator expression
105+
# $<INSTALL_PREFIX> works since CMake 3.27, for earlier versions the escaped
106+
# variable CMAKE_INSTALL_PREFIX can be used.
107+
if(
108+
CMAKE_VERSION VERSION_LESS 3.27
109+
AND value MATCHES [[.*\$<INSTALL_PREFIX>.*]]
110+
)
111+
string(
112+
REPLACE
113+
"$<INSTALL_PREFIX>"
114+
"\${CMAKE_INSTALL_PREFIX}"
115+
replaced_value
116+
"${value}"
117+
)
118+
list(APPEND result_values "${replaced_value}")
119+
else()
120+
list(APPEND result_values "${value}")
121+
endif()
104122

105123
# Replace possible INSTALL_PREFIX in value for usage in add_custom_command,
106124
# in the result_values above the intact genex is left for enabling the

0 commit comments

Comments
 (0)