• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21include("${CMAKE_CURRENT_LIST_DIR}/libxml2-export.cmake")
22
23@PACKAGE_INIT@
24
25set(LIBXML2_VERSION_MAJOR  @LIBXML_MAJOR_VERSION@)
26set(LIBXML2_VERSION_MINOR  @LIBXML_MINOR_VERSION@)
27set(LIBXML2_VERSION_PATCH  @LIBXML_MICRO_VERSION@)
28set(LIBXML2_VERSION_STRING "@VERSION@")
29set(LIBXML2_INSTALL_PREFIX ${PACKAGE_PREFIX_DIR})
30set(LIBXML2_INCLUDE_DIR    ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@/libxml2)
31set(LIBXML2_LIBRARY_DIR    ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@)
32
33macro(select_library_location target basename)
34  if(TARGET ${target})
35    foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB)
36      get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG)
37      get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL)
38      get_target_property(${basename}_${property}_RELEASE ${target} ${property}_RELEASE)
39      get_target_property(${basename}_${property}_RELWITHDEBINFO ${target} ${property}_RELWITHDEBINFO)
40
41      if(${basename}_${property}_DEBUG AND ${basename}_${property}_RELEASE)
42        set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELEASE})
43      elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_RELWITHDEBINFO)
44        set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELWITHDEBINFO})
45      elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_MINSIZEREL)
46        set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_MINSIZEREL})
47      elseif(${basename}_${property}_RELEASE)
48        set(${basename}_LIBRARY ${${basename}_${property}_RELEASE})
49      elseif(${basename}_${property}_RELWITHDEBINFO)
50        set(${basename}_LIBRARY ${${basename}_${property}_RELWITHDEBINFO})
51      elseif(${basename}_${property}_MINSIZEREL)
52        set(${basename}_LIBRARY ${${basename}_${property}_MINSIZEREL})
53      elseif(${basename}_${property}_DEBUG)
54        set(${basename}_LIBRARY ${${basename}_${property}_DEBUG})
55      endif()
56    endforeach()
57  endif()
58endmacro()
59
60macro(select_executable_location target basename)
61  if(TARGET ${target})
62    get_target_property(${basename}_IMPORTED_LOCATION_DEBUG ${target} IMPORTED_LOCATION_DEBUG)
63    get_target_property(${basename}_IMPORTED_LOCATION_MINSIZEREL ${target} IMPORTED_LOCATION_MINSIZEREL)
64    get_target_property(${basename}_IMPORTED_LOCATION_RELEASE ${target} IMPORTED_LOCATION_RELEASE)
65    get_target_property(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO ${target} IMPORTED_LOCATION_RELWITHDEBINFO)
66
67    if(${basename}_IMPORTED_LOCATION_RELEASE)
68      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELEASE})
69    elseif(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO)
70      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELWITHDEBINFO})
71    elseif(${basename}_IMPORTED_LOCATION_MINSIZEREL)
72      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_MINSIZEREL})
73    elseif(${basename}_IMPORTED_LOCATION_DEBUG)
74      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_DEBUG})
75    endif()
76  endif()
77endmacro()
78
79select_library_location(LibXml2::LibXml2 LIBXML2)
80select_executable_location(LibXml2::xmlcatalog LIBXML2_XMLCATALOG)
81select_executable_location(LibXml2::xmllint LIBXML2_XMLLINT)
82
83set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
84set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
85
86include(CMakeFindDependencyMacro)
87
88set(LIBXML2_SHARED @BUILD_SHARED_LIBS@)
89set(LIBXML2_WITH_ICONV @LIBXML2_WITH_ICONV@)
90set(LIBXML2_WITH_THREADS @LIBXML2_WITH_THREADS@)
91set(LIBXML2_WITH_ICU @LIBXML2_WITH_ICU@)
92set(LIBXML2_WITH_LZMA @LIBXML2_WITH_LZMA@)
93set(LIBXML2_WITH_ZLIB @LIBXML2_WITH_ZLIB@)
94
95if(LIBXML2_WITH_ICONV)
96  find_dependency(Iconv)
97  list(APPEND LIBXML2_LIBRARIES    ${Iconv_LIBRARIES})
98  list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS})
99endif()
100
101if(NOT LIBXML2_SHARED)
102  set(LIBXML2_DEFINITIONS -DLIBXML_STATIC)
103
104  if(LIBXML2_WITH_THREADS)
105    find_dependency(Threads)
106    list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
107  endif()
108
109  if(LIBXML2_WITH_ICU)
110    find_dependency(ICU COMPONENTS data i18n uc)
111    list(APPEND LIBXML2_LIBRARIES    ${ICU_LIBRARIES})
112  endif()
113
114  if(LIBXML2_WITH_LZMA)
115    find_dependency(LibLZMA)
116    list(APPEND LIBXML2_LIBRARIES    ${LIBLZMA_LIBRARIES})
117  endif()
118
119  if(LIBXML2_WITH_ZLIB)
120    find_dependency(ZLIB)
121    list(APPEND LIBXML2_LIBRARIES    ${ZLIB_LIBRARIES})
122  endif()
123
124  if(UNIX)
125    list(APPEND LIBXML2_LIBRARIES m)
126  endif()
127
128  if(WIN32)
129    list(APPEND LIBXML2_LIBRARIES ws2_32)
130  endif()
131endif()
132
133# whether libxml2 has dso support
134set(LIBXML2_MODULES @LIBXML2_WITH_MODULES@)
135
136mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE)
137