xref: /aosp_15_r20/external/libxml2/libxml2-config.cmake.cmake.in (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1*7c568831SAndroid Build Coastguard Worker# libxml2-config.cmake
2*7c568831SAndroid Build Coastguard Worker# --------------------
3*7c568831SAndroid Build Coastguard Worker#
4*7c568831SAndroid Build Coastguard Worker# Libxml2 cmake module.
5*7c568831SAndroid Build Coastguard Worker# This module sets the following variables:
6*7c568831SAndroid Build Coastguard Worker#
7*7c568831SAndroid Build Coastguard Worker# ::
8*7c568831SAndroid Build Coastguard Worker#
9*7c568831SAndroid Build Coastguard Worker#   LIBXML2_INCLUDE_DIR        - Directory where LibXml2 headers are located.
10*7c568831SAndroid Build Coastguard Worker#   LIBXML2_INCLUDE_DIRS       - list of the include directories needed to use LibXml2.
11*7c568831SAndroid Build Coastguard Worker#   LIBXML2_LIBRARY            - path to the LibXml2 library.
12*7c568831SAndroid Build Coastguard Worker#   LIBXML2_LIBRARIES          - xml2 libraries to link against.
13*7c568831SAndroid Build Coastguard Worker#   LIBXML2_DEFINITIONS        - the compiler switches required for using LibXml2.
14*7c568831SAndroid Build Coastguard Worker#   LIBXML2_VERSION_MAJOR      - The major version of libxml2.
15*7c568831SAndroid Build Coastguard Worker#   LIBXML2_VERSION_MINOR      - The minor version of libxml2.
16*7c568831SAndroid Build Coastguard Worker#   LIBXML2_VERSION_PATCH      - The patch version of libxml2.
17*7c568831SAndroid Build Coastguard Worker#   LIBXML2_VERSION_STRING     - version number as a string (ex: "2.3.4")
18*7c568831SAndroid Build Coastguard Worker#   LIBXML2_MODULES            - whether libxml2 has dso support
19*7c568831SAndroid Build Coastguard Worker#   LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2
20*7c568831SAndroid Build Coastguard Worker
21*7c568831SAndroid Build Coastguard Workerinclude("${CMAKE_CURRENT_LIST_DIR}/libxml2-export.cmake")
22*7c568831SAndroid Build Coastguard Worker
23*7c568831SAndroid Build Coastguard Worker@PACKAGE_INIT@
24*7c568831SAndroid Build Coastguard Worker
25*7c568831SAndroid Build Coastguard Workerset(LIBXML2_VERSION_MAJOR  @LIBXML_MAJOR_VERSION@)
26*7c568831SAndroid Build Coastguard Workerset(LIBXML2_VERSION_MINOR  @LIBXML_MINOR_VERSION@)
27*7c568831SAndroid Build Coastguard Workerset(LIBXML2_VERSION_PATCH  @LIBXML_MICRO_VERSION@)
28*7c568831SAndroid Build Coastguard Workerset(LIBXML2_VERSION_STRING "@VERSION@")
29*7c568831SAndroid Build Coastguard Workerset(LIBXML2_INSTALL_PREFIX ${PACKAGE_PREFIX_DIR})
30*7c568831SAndroid Build Coastguard Workerset(LIBXML2_INCLUDE_DIR    ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@/libxml2)
31*7c568831SAndroid Build Coastguard Workerset(LIBXML2_LIBRARY_DIR    ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@)
32*7c568831SAndroid Build Coastguard Worker
33*7c568831SAndroid Build Coastguard Workermacro(select_library_location target basename)
34*7c568831SAndroid Build Coastguard Worker  if(TARGET ${target})
35*7c568831SAndroid Build Coastguard Worker    foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB)
36*7c568831SAndroid Build Coastguard Worker      get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG)
37*7c568831SAndroid Build Coastguard Worker      get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL)
38*7c568831SAndroid Build Coastguard Worker      get_target_property(${basename}_${property}_NOCONFIG ${target} ${property}_NOCONFIG)
39*7c568831SAndroid Build Coastguard Worker      get_target_property(${basename}_${property}_RELEASE ${target} ${property}_RELEASE)
40*7c568831SAndroid Build Coastguard Worker      get_target_property(${basename}_${property}_RELWITHDEBINFO ${target} ${property}_RELWITHDEBINFO)
41*7c568831SAndroid Build Coastguard Worker
42*7c568831SAndroid Build Coastguard Worker      if(${basename}_${property}_DEBUG AND ${basename}_${property}_RELEASE)
43*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELEASE})
44*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_RELWITHDEBINFO)
45*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELWITHDEBINFO})
46*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_MINSIZEREL)
47*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_MINSIZEREL})
48*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_RELEASE)
49*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY ${${basename}_${property}_RELEASE})
50*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_RELWITHDEBINFO)
51*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY ${${basename}_${property}_RELWITHDEBINFO})
52*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_MINSIZEREL)
53*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY ${${basename}_${property}_MINSIZEREL})
54*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_DEBUG)
55*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY ${${basename}_${property}_DEBUG})
56*7c568831SAndroid Build Coastguard Worker      elseif(${basename}_${property}_NOCONFIG)
57*7c568831SAndroid Build Coastguard Worker        set(${basename}_LIBRARY ${${basename}_${property}_NOCONFIG})
58*7c568831SAndroid Build Coastguard Worker      endif()
59*7c568831SAndroid Build Coastguard Worker    endforeach()
60*7c568831SAndroid Build Coastguard Worker  endif()
61*7c568831SAndroid Build Coastguard Workerendmacro()
62*7c568831SAndroid Build Coastguard Worker
63*7c568831SAndroid Build Coastguard Workermacro(select_executable_location target basename)
64*7c568831SAndroid Build Coastguard Worker  if(TARGET ${target})
65*7c568831SAndroid Build Coastguard Worker    get_target_property(${basename}_IMPORTED_LOCATION_DEBUG ${target} IMPORTED_LOCATION_DEBUG)
66*7c568831SAndroid Build Coastguard Worker    get_target_property(${basename}_IMPORTED_LOCATION_MINSIZEREL ${target} IMPORTED_LOCATION_MINSIZEREL)
67*7c568831SAndroid Build Coastguard Worker    get_target_property(${basename}_IMPORTED_LOCATION_NOCONFIG ${target} IMPORTED_LOCATION_NOCONFIG)
68*7c568831SAndroid Build Coastguard Worker    get_target_property(${basename}_IMPORTED_LOCATION_RELEASE ${target} IMPORTED_LOCATION_RELEASE)
69*7c568831SAndroid Build Coastguard Worker    get_target_property(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO ${target} IMPORTED_LOCATION_RELWITHDEBINFO)
70*7c568831SAndroid Build Coastguard Worker
71*7c568831SAndroid Build Coastguard Worker    if(${basename}_IMPORTED_LOCATION_RELEASE)
72*7c568831SAndroid Build Coastguard Worker      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELEASE})
73*7c568831SAndroid Build Coastguard Worker    elseif(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO)
74*7c568831SAndroid Build Coastguard Worker      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELWITHDEBINFO})
75*7c568831SAndroid Build Coastguard Worker    elseif(${basename}_IMPORTED_LOCATION_MINSIZEREL)
76*7c568831SAndroid Build Coastguard Worker      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_MINSIZEREL})
77*7c568831SAndroid Build Coastguard Worker    elseif(${basename}_IMPORTED_LOCATION_DEBUG)
78*7c568831SAndroid Build Coastguard Worker      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_DEBUG})
79*7c568831SAndroid Build Coastguard Worker    elseif(${basename}_IMPORTED_LOCATION_NOCONFIG)
80*7c568831SAndroid Build Coastguard Worker      set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_NOCONFIG})
81*7c568831SAndroid Build Coastguard Worker    endif()
82*7c568831SAndroid Build Coastguard Worker  endif()
83*7c568831SAndroid Build Coastguard Workerendmacro()
84*7c568831SAndroid Build Coastguard Worker
85*7c568831SAndroid Build Coastguard Workerselect_library_location(LibXml2::LibXml2 LIBXML2)
86*7c568831SAndroid Build Coastguard Workerselect_executable_location(LibXml2::xmlcatalog LIBXML2_XMLCATALOG)
87*7c568831SAndroid Build Coastguard Workerselect_executable_location(LibXml2::xmllint LIBXML2_XMLLINT)
88*7c568831SAndroid Build Coastguard Worker
89*7c568831SAndroid Build Coastguard Workerset(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
90*7c568831SAndroid Build Coastguard Workerset(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
91*7c568831SAndroid Build Coastguard Worker
92*7c568831SAndroid Build Coastguard Workerinclude(CMakeFindDependencyMacro)
93*7c568831SAndroid Build Coastguard Worker
94*7c568831SAndroid Build Coastguard Workerset(LIBXML2_SHARED @BUILD_SHARED_LIBS@)
95*7c568831SAndroid Build Coastguard Workerset(LIBXML2_WITH_ICONV @LIBXML2_WITH_ICONV@)
96*7c568831SAndroid Build Coastguard Workerset(LIBXML2_WITH_THREADS @LIBXML2_WITH_THREADS@)
97*7c568831SAndroid Build Coastguard Workerset(LIBXML2_WITH_ICU @LIBXML2_WITH_ICU@)
98*7c568831SAndroid Build Coastguard Workerset(LIBXML2_WITH_LZMA @LIBXML2_WITH_LZMA@)
99*7c568831SAndroid Build Coastguard Workerset(LIBXML2_WITH_ZLIB @LIBXML2_WITH_ZLIB@)
100*7c568831SAndroid Build Coastguard Worker
101*7c568831SAndroid Build Coastguard Workerif(LIBXML2_WITH_ICONV)
102*7c568831SAndroid Build Coastguard Worker  find_dependency(Iconv)
103*7c568831SAndroid Build Coastguard Worker  list(APPEND LIBXML2_LIBRARIES    ${Iconv_LIBRARIES})
104*7c568831SAndroid Build Coastguard Worker  list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS})
105*7c568831SAndroid Build Coastguard Worker  if(NOT Iconv_FOUND)
106*7c568831SAndroid Build Coastguard Worker    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
107*7c568831SAndroid Build Coastguard Worker    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Iconv dependency was not found")
108*7c568831SAndroid Build Coastguard Worker    return()
109*7c568831SAndroid Build Coastguard Worker  endif()
110*7c568831SAndroid Build Coastguard Workerendif()
111*7c568831SAndroid Build Coastguard Worker
112*7c568831SAndroid Build Coastguard Workerif(NOT LIBXML2_SHARED)
113*7c568831SAndroid Build Coastguard Worker  set(LIBXML2_DEFINITIONS -DLIBXML_STATIC)
114*7c568831SAndroid Build Coastguard Worker
115*7c568831SAndroid Build Coastguard Worker  if(LIBXML2_WITH_THREADS)
116*7c568831SAndroid Build Coastguard Worker    find_dependency(Threads)
117*7c568831SAndroid Build Coastguard Worker    list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
118*7c568831SAndroid Build Coastguard Worker    if(NOT Threads_FOUND)
119*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
120*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Threads dependency was not found")
121*7c568831SAndroid Build Coastguard Worker      return()
122*7c568831SAndroid Build Coastguard Worker    endif()
123*7c568831SAndroid Build Coastguard Worker  endif()
124*7c568831SAndroid Build Coastguard Worker
125*7c568831SAndroid Build Coastguard Worker  if(LIBXML2_WITH_ICU)
126*7c568831SAndroid Build Coastguard Worker    find_dependency(ICU COMPONENTS data i18n uc)
127*7c568831SAndroid Build Coastguard Worker    list(APPEND LIBXML2_LIBRARIES    ${ICU_LIBRARIES})
128*7c568831SAndroid Build Coastguard Worker    if(NOT ICU_FOUND)
129*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
130*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ICU dependency was not found")
131*7c568831SAndroid Build Coastguard Worker      return()
132*7c568831SAndroid Build Coastguard Worker    endif()
133*7c568831SAndroid Build Coastguard Worker  endif()
134*7c568831SAndroid Build Coastguard Worker
135*7c568831SAndroid Build Coastguard Worker  if(LIBXML2_WITH_LZMA)
136*7c568831SAndroid Build Coastguard Worker    find_dependency(LibLZMA)
137*7c568831SAndroid Build Coastguard Worker    list(APPEND LIBXML2_LIBRARIES    ${LIBLZMA_LIBRARIES})
138*7c568831SAndroid Build Coastguard Worker    if(NOT LibLZMA_FOUND)
139*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
140*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LibLZMA dependency was not found")
141*7c568831SAndroid Build Coastguard Worker      return()
142*7c568831SAndroid Build Coastguard Worker    endif()
143*7c568831SAndroid Build Coastguard Worker  endif()
144*7c568831SAndroid Build Coastguard Worker
145*7c568831SAndroid Build Coastguard Worker  if(LIBXML2_WITH_ZLIB)
146*7c568831SAndroid Build Coastguard Worker    find_dependency(ZLIB)
147*7c568831SAndroid Build Coastguard Worker    list(APPEND LIBXML2_LIBRARIES    ${ZLIB_LIBRARIES})
148*7c568831SAndroid Build Coastguard Worker    if(NOT ZLIB_FOUND)
149*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
150*7c568831SAndroid Build Coastguard Worker      set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ZLIB dependency was not found")
151*7c568831SAndroid Build Coastguard Worker      return()
152*7c568831SAndroid Build Coastguard Worker    endif()
153*7c568831SAndroid Build Coastguard Worker  endif()
154*7c568831SAndroid Build Coastguard Worker
155*7c568831SAndroid Build Coastguard Worker  if(UNIX)
156*7c568831SAndroid Build Coastguard Worker    list(APPEND LIBXML2_LIBRARIES m)
157*7c568831SAndroid Build Coastguard Worker  endif()
158*7c568831SAndroid Build Coastguard Worker
159*7c568831SAndroid Build Coastguard Worker  if(WIN32)
160*7c568831SAndroid Build Coastguard Worker    list(APPEND LIBXML2_LIBRARIES ws2_32)
161*7c568831SAndroid Build Coastguard Worker  endif()
162*7c568831SAndroid Build Coastguard Workerendif()
163*7c568831SAndroid Build Coastguard Worker
164*7c568831SAndroid Build Coastguard Worker# whether libxml2 has dso support
165*7c568831SAndroid Build Coastguard Workerset(LIBXML2_MODULES @LIBXML2_WITH_MODULES@)
166*7c568831SAndroid Build Coastguard Worker
167*7c568831SAndroid Build Coastguard Workermark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE)
168