[llvm] 2b3807d - [CMake] Fix ncurses/zlib in LLVM_SYSTEM_LIBS for Windows GNU
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 23:06:26 PDT 2020
Author: Petr Hosek
Date: 2020-08-24T23:00:54-07:00
New Revision: 2b3807d822c50d361ae67184b6de5a41bd7b1bba
URL: https://github.com/llvm/llvm-project/commit/2b3807d822c50d361ae67184b6de5a41bd7b1bba
DIFF: https://github.com/llvm/llvm-project/commit/2b3807d822c50d361ae67184b6de5a41bd7b1bba.diff
LOG: [CMake] Fix ncurses/zlib in LLVM_SYSTEM_LIBS for Windows GNU
For the Windows GNU platform, CMAKE_FIND_LIBRARY_PREFIXES is a list
containing an empty string, which ended up in a regex capturing group,
which is invalid in CMake's regex engine. With this change, we get the
following:
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib")
get_system_libname(path/to/libz.dll.a zlib)
message("${zlib}")
outputs z, as expected.
Patch By: haampie
Differential Revision: https://reviews.llvm.org/D86434
Added:
Modified:
llvm/lib/Support/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index a571d269b39f..09838edbb073 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -4,14 +4,14 @@ endif()
function(get_system_libname libpath libname)
get_filename_component(libpath ${libpath} NAME)
- 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(prefixes ${CMAKE_FIND_LIBRARY_PREFIXES})
+ set(suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ list(FILTER prefixes EXCLUDE REGEX "^\\s*$")
+ list(FILTER suffixes EXCLUDE REGEX "^\\s*$")
+ string(REPLACE ";" "|" prefixes "${prefixes}")
+ string(REPLACE ";" "|" suffixes "${suffixes}")
+ string(REGEX REPLACE "^(${prefixes})" "" libpath ${libpath})
+ string(REGEX REPLACE "(${suffixes})$" "" libpath ${libpath})
set(${libname} "${libpath}" PARENT_SCOPE)
endfunction()
More information about the llvm-commits
mailing list