[CMake] Fix an issue where get_system_libname creates an empty regex capture on windows

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1119478

Patch By: haampie

Differential Revision: https://reviews.llvm.org/D86245
This commit is contained in:
Petr Hosek 2020-08-19 14:33:52 -07:00
parent 7a028fe702
commit 1ed1e16ab8
1 changed files with 8 additions and 4 deletions

View File

@ -4,10 +4,14 @@ endif()
function(get_system_libname libpath libname)
get_filename_component(libpath ${libpath} NAME)
string(REPLACE ";" "|" PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
string(REPLACE ";" "|" SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
STRING(REGEX REPLACE "^(${PREFIXES})" "" libpath ${libpath})
STRING(REGEX REPLACE "(${SUFFIXES})$" "" libpath ${libpath})
if( CMAKE_FIND_LIBRARY_PREFIXES )
string(REPLACE ";" "|" PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
string(REGEX REPLACE "^(${PREFIXES})" "" libpath ${libpath})
endif()
if( CMAKE_FIND_LIBRARY_SUFFIXES )
string(REPLACE ";" "|" SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
string(REGEX REPLACE "(${SUFFIXES})$" "" libpath ${libpath})
endif()
set(${libname} "${libpath}" PARENT_SCOPE)
endfunction()