Skip to content

Commit ce439e5

Browse files
committed
PHP/SearchLibraries: Remove -l flags from libraries
If libraries are passed with -l flags (for example, `-ldl`), they should be interpreted as library names for consistency as already used across the CMake.
1 parent 6e6fb17 commit ce439e5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmake/cmake/modules/PHP/SearchLibraries.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ The arguments are:
6969
a macro definition. It would not be found using the other two commands because
7070
they don't include required headers.
7171
72+
Any `-l` strings prepended to the provided libraries are removed in the
73+
results. For example, `-ldl` will be interpreted as `dl`.
74+
7275
* `VARIABLE <variable>`
7376
7477
Optional. Name of an internal cache variable where the result of the check is
@@ -274,6 +277,9 @@ function(php_search_libraries)
274277
foreach(library IN LISTS parsed_LIBRARIES)
275278
unset(${parsed_VARIABLE} CACHE)
276279

280+
# If library was given as -l<library-name>, remove the linker flag.
281+
string(REGEX REPLACE "^-l" "" library "${library}")
282+
277283
if(NOT CMAKE_REQUIRED_QUIET)
278284
message(CHECK_START "Looking for ${symbol} in ${library}")
279285
endif()

0 commit comments

Comments
 (0)