diff options
author | Fabrice Fontaine <fontaine.fabrice@gmail.com> | 2019-04-24 22:22:29 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2019-04-24 22:07:05 +0000 |
commit | 580098d875b497e5d5aa36dfad10291668e7d392 (patch) | |
tree | 926bded459b053b69d17b9f4a36d954b1a3f2056 /cmake | |
parent | b641febb1ea9ddc18550a4dd4d55a027b7ea9669 (diff) |
FindXml2: use pkg-config to find libxml2 dependencies
On UNIX, when statically built, libxml2 can depends on other libraries
such as lzma. These dependencies are already retrieved through
pkg-config so append them to LIBXML2_LIBRARIES otherwise static build
will fail
Change-Id: I362064969488ec53042aa323eadb54fef026d8a5
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Reviewed-on: https://code.wireshark.org/review/32968
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindLibXml2.cmake | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cmake/modules/FindLibXml2.cmake b/cmake/modules/FindLibXml2.cmake index 99d70af57d..34121ef01b 100644 --- a/cmake/modules/FindLibXml2.cmake +++ b/cmake/modules/FindLibXml2.cmake @@ -106,10 +106,17 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY LIBXML2_XMLLINT_EXECUTABLE) -if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2) - add_library(LibXml2::LibXml2 UNKNOWN IMPORTED) - set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}") - set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}") +if(LibXml2_FOUND) + # Include transitive dependencies for static linking. + if(UNIX AND CMAKE_FIND_LIBRARY_SUFFIXES STREQUAL ".a") + list(APPEND LIBXML2_LIBRARIES ${PC_LIBXML_LIBRARIES}) + endif() + + if (NOT TARGET LibXml2::LibXml2) + add_library(LibXml2::LibXml2 UNKNOWN IMPORTED) + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}") + set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}") + endif() endif() AddWSWinDLLS(LibXml2 LIBXML2_HINTS "libxml2*" "lzma*") |