1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/cmake/modules/GetLibraryName.cmake
Petr Hosek 04bcaa46b7 [CMake] Simplify CMake handling for libxml2
This matches the changes made to handling of zlib done in 10b1b4a
where we rely on find_package and the imported target rather than
manually appending the library and include paths. The use of
LLVM_LIBXML2_ENABLED has been replaced by LLVM_ENABLE_LIBXML2
thus reducing the number of variables.

Differential Revision: https://reviews.llvm.org/D84563
2020-09-09 21:44:44 -07:00

18 lines
632 B
CMake

# Returns library name for a given path.
function(get_library_name path name)
get_filename_component(path ${path} NAME)
set(prefixes ${CMAKE_FIND_LIBRARY_PREFIXES})
set(suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
list(FILTER prefixes EXCLUDE REGEX "^\\s*$")
list(FILTER suffixes EXCLUDE REGEX "^\\s*$")
if(prefixes)
string(REPLACE ";" "|" prefixes "${prefixes}")
string(REGEX REPLACE "^(${prefixes})" "" path ${path})
endif()
if(suffixes)
string(REPLACE ";" "|" suffixes "${suffixes}")
string(REGEX REPLACE "(${suffixes})$" "" path ${path})
endif()
set(${name} "${path}" PARENT_SCOPE)
endfunction()