1# libxml2-config.cmake 2# -------------------- 3# 4# Libxml2 cmake module. 5# This module sets the following variables: 6# 7# :: 8# 9# LIBXML2_INCLUDE_DIR - Directory where LibXml2 headers are located. 10# LIBXML2_INCLUDE_DIRS - list of the include directories needed to use LibXml2. 11# LIBXML2_LIBRARY - path to the LibXml2 library. 12# LIBXML2_LIBRARIES - xml2 libraries to link against. 13# LIBXML2_DEFINITIONS - the compiler switches required for using LibXml2. 14# LIBXML2_VERSION_MAJOR - The major version of libxml2. 15# LIBXML2_VERSION_MINOR - The minor version of libxml2. 16# LIBXML2_VERSION_PATCH - The patch version of libxml2. 17# LIBXML2_VERSION_STRING - version number as a string (ex: "2.3.4") 18# LIBXML2_MODULES - whether libxml2 has dso support 19# LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2 20# 21# The following targets are defined: 22# 23# LibXml2::LibXml2 - the LibXml2 library 24# LibXml2::xmllint - the xmllint command-line executable 25 26get_filename_component(_libxml2_rootdir ${CMAKE_CURRENT_LIST_DIR}/../../../ ABSOLUTE) 27 28set(LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@) 29set(LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@) 30set(LIBXML2_VERSION_MICRO @LIBXML_MICRO_VERSION@) 31set(LIBXML2_VERSION_STRING "@VERSION@") 32set(LIBXML2_DEFINITIONS "@XML_CFLAGS@") 33set(LIBXML2_INSTALL_PREFIX ${_libxml2_rootdir}) 34set(LIBXML2_INCLUDE_DIR ${_libxml2_rootdir}/include/libxml2) 35set(LIBXML2_LIBRARY_DIR ${_libxml2_rootdir}/lib) 36 37find_library(LIBXML2_LIBRARY NAMES xml2 HINTS ${LIBXML2_LIBRARY_DIR} NO_DEFAULT_PATH) 38find_program(LIBXML2_XMLCATALOG_EXECUTABLE NAMES xmlcatalog HINTS ${_libxml2_rootdir}/bin NO_DEFAULT_PATH) 39find_program(LIBXML2_XMLLINT_EXECUTABLE NAMES xmllint HINTS ${_libxml2_rootdir}/bin NO_DEFAULT_PATH) 40 41set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY}) 42set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR}) 43unset(LIBXML2_INTERFACE_LINK_LIBRARIES) 44 45include(CMakeFindDependencyMacro) 46 47set(LIBXML2_WITH_ICONV @WITH_ICONV@) 48set(LIBXML2_WITH_THREADS @WITH_THREADS@) 49set(LIBXML2_WITH_ICU @WITH_ICU@) 50set(LIBXML2_WITH_LZMA @WITH_LZMA@) 51set(LIBXML2_WITH_ZLIB @WITH_ZLIB@) 52 53if(LIBXML2_WITH_ICONV) 54 find_dependency(Iconv) 55 list(APPEND LIBXML2_LIBRARIES ${Iconv_LIBRARIES}) 56 list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS}) 57 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "Iconv::Iconv") 58endif() 59 60if(LIBXML2_WITH_THREADS) 61 find_dependency(Threads) 62 list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) 63 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:Threads::Threads>") 64endif() 65 66if(LIBXML2_WITH_ICU) 67 find_dependency(ICU COMPONENTS data i18n uc) 68 list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES}) 69 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ICU::data>;\$<LINK_ONLY:ICU::i18n>;\$<LINK_ONLY:ICU::uc>") 70endif() 71 72if(LIBXML2_WITH_LZMA) 73 find_dependency(LibLZMA) 74 list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) 75 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:LibLZMA::LibLZMA>") 76endif() 77 78if(LIBXML2_WITH_ZLIB) 79 find_dependency(ZLIB) 80 list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES}) 81 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ZLIB::ZLIB>") 82endif() 83 84if(UNIX) 85 list(APPEND LIBXML2_LIBRARIES m) 86 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:m>") 87endif() 88 89if(WIN32) 90 list(APPEND LIBXML2_LIBRARIES ws2_32) 91 list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ws2_32>") 92endif() 93 94# whether libxml2 has dso support 95set(LIBXML2_MODULES @WITH_MODULES@) 96 97mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE) 98 99if(NOT TARGET LibXml2::LibXml2 AND DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS) 100 add_library(LibXml2::LibXml2 UNKNOWN IMPORTED) 101 set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}") 102 set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}") 103 set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}") 104 set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBXML2_INTERFACE_LINK_LIBRARIES}") 105endif() 106 107if(NOT TARGET LibXml2::xmlcatalog AND DEFINED LIBXML2_XMLCATALOG_EXECUTABLE) 108 add_executable(LibXml2::xmlcatalog IMPORTED) 109 set_target_properties(LibXml2::xmlcatalog PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLCATALOG_EXECUTABLE}") 110endif() 111 112if(NOT TARGET LibXml2::xmllint AND DEFINED LIBXML2_XMLLINT_EXECUTABLE) 113 add_executable(LibXml2::xmllint IMPORTED) 114 set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}") 115endif() 116