Created
October 16, 2020 12:58
-
-
Save jedisct1/6d03d591dace75018612ef0f2f1f373e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit c74f64f05764f8bb25d85d8a88cc7c4647be60cc | |
Author: Frank Denis <[email protected]> | |
Date: Fri Oct 16 14:57:36 2020 +0200 | |
Backport libxml2 fix from master | |
diff --git a/llvm/cmake/modules/GetLibraryName.cmake b/llvm/cmake/modules/GetLibraryName.cmake | |
new file mode 100644 | |
index 00000000000..518fa4cf594 | |
--- /dev/null | |
+++ b/llvm/cmake/modules/GetLibraryName.cmake | |
@@ -0,0 +1,16 @@ | |
+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() | |
diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt | |
index 7ccc17ad577..044216be85b 100644 | |
--- a/llvm/lib/WindowsManifest/CMakeLists.txt | |
+++ b/llvm/lib/WindowsManifest/CMakeLists.txt | |
@@ -1,23 +1,23 @@ | |
+include(GetLibraryName) | |
+ | |
+set(imported_libs LibXml2::LibXml2) | |
+ | |
add_llvm_component_library(LLVMWindowsManifest | |
WindowsManifestMerger.cpp | |
ADDITIONAL_HEADER_DIRS | |
${LLVM_MAIN_INCLUDE_DIR}/llvm/WindowsManifest | |
- ${Backtrace_INCLUDE_DIRS}) | |
+ ${Backtrace_INCLUDE_DIRS} | |
+ LINK_LIBS ${imported_libs}) | |
if(LIBXML2_LIBRARIES) | |
- target_link_libraries(LLVMWindowsManifest PUBLIC ${LIBXML2_LIBRARIES}) | |
- | |
- get_filename_component(xml2_library ${LIBXML2_LIBRARIES} NAME) | |
- if (CMAKE_STATIC_LIBRARY_PREFIX AND | |
- xml2_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$") | |
- string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) | |
- string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) | |
- elseif (CMAKE_SHARED_LIBRARY_PREFIX AND | |
- xml2_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$") | |
- string(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) | |
- string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) | |
+ if(CMAKE_BUILD_TYPE) | |
+ string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) | |
+ get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) | |
endif() | |
- set_property(TARGET LLVMWindowsManifest PROPERTY | |
- LLVM_SYSTEM_LIBS ${xml2_library}) | |
+ if(NOT zlib_library) | |
+ get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) | |
+ endif() | |
+ get_library_name(${libxml2_library} libxml2_library) | |
+ set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment