2020-04-21 01:53:12 +03:00
# libxml2-config.cmake
# --------------------
#
# Libxml2 cmake module.
2020-12-06 19:26:23 +03:00
# This module sets the following variables:
2020-04-21 01:53:12 +03:00
#
# ::
#
2020-12-06 19:26:23 +03:00
# LIBXML2_INCLUDE_DIR - Directory where LibXml2 headers are located.
# LIBXML2_INCLUDE_DIRS - list of the include directories needed to use LibXml2.
# LIBXML2_LIBRARY - path to the LibXml2 library.
# LIBXML2_LIBRARIES - xml2 libraries to link against.
# LIBXML2_DEFINITIONS - the compiler switches required for using LibXml2.
# LIBXML2_VERSION_MAJOR - The major version of libxml2.
# LIBXML2_VERSION_MINOR - The minor version of libxml2.
# LIBXML2_VERSION_PATCH - The patch version of libxml2.
# LIBXML2_VERSION_STRING - version number as a string (ex: "2.3.4")
# LIBXML2_MODULES - whether libxml2 has dso support
# LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2
2020-04-21 01:53:12 +03:00
include ( "${CMAKE_CURRENT_LIST_DIR}/libxml2-export.cmake" )
@ P A C K A G E _ I N I T @
set ( LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@ )
set ( LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@ )
set ( LIBXML2_VERSION_PATCH @LIBXML_MICRO_VERSION@ )
set ( LIBXML2_VERSION_STRING "@VERSION@" )
set ( LIBXML2_INSTALL_PREFIX ${ PACKAGE_PREFIX_DIR } )
2020-12-06 19:26:23 +03:00
set ( LIBXML2_INCLUDE_DIR ${ PACKAGE_PREFIX_DIR } /@CMAKE_INSTALL_INCLUDEDIR@/libxml2 )
2020-04-21 01:53:12 +03:00
set ( LIBXML2_LIBRARY_DIR ${ PACKAGE_PREFIX_DIR } /@CMAKE_INSTALL_LIBDIR@ )
macro ( select_library_location target basename )
2020-12-31 15:18:14 +03:00
if ( TARGET ${ target } )
foreach ( property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB )
get_target_property ( ${ basename } _ ${ property } _DEBUG ${ target } ${ property } _DEBUG )
get_target_property ( ${ basename } _ ${ property } _MINSIZEREL ${ target } ${ property } _MINSIZEREL )
2023-09-09 18:46:34 +03:00
get_target_property ( ${ basename } _ ${ property } _NOCONFIG ${ target } ${ property } _NOCONFIG )
2020-12-31 15:18:14 +03:00
get_target_property ( ${ basename } _ ${ property } _RELEASE ${ target } ${ property } _RELEASE )
get_target_property ( ${ basename } _ ${ property } _RELWITHDEBINFO ${ target } ${ property } _RELWITHDEBINFO )
2020-12-06 19:26:23 +03:00
2020-12-31 15:18:14 +03:00
if ( ${ basename } _ ${ property } _DEBUG AND ${ basename } _ ${ property } _RELEASE )
set ( ${ basename } _LIBRARY debug ${ ${basename } _ ${ property } _DEBUG} optimized ${ ${basename } _ ${ property } _RELEASE} )
elseif ( ${ basename } _ ${ property } _DEBUG AND ${ basename } _ ${ property } _RELWITHDEBINFO )
set ( ${ basename } _LIBRARY debug ${ ${basename } _ ${ property } _DEBUG} optimized ${ ${basename } _ ${ property } _RELWITHDEBINFO} )
elseif ( ${ basename } _ ${ property } _DEBUG AND ${ basename } _ ${ property } _MINSIZEREL )
set ( ${ basename } _LIBRARY debug ${ ${basename } _ ${ property } _DEBUG} optimized ${ ${basename } _ ${ property } _MINSIZEREL} )
elseif ( ${ basename } _ ${ property } _RELEASE )
set ( ${ basename } _LIBRARY ${ ${basename } _ ${ property } _RELEASE} )
elseif ( ${ basename } _ ${ property } _RELWITHDEBINFO )
set ( ${ basename } _LIBRARY ${ ${basename } _ ${ property } _RELWITHDEBINFO} )
elseif ( ${ basename } _ ${ property } _MINSIZEREL )
set ( ${ basename } _LIBRARY ${ ${basename } _ ${ property } _MINSIZEREL} )
elseif ( ${ basename } _ ${ property } _DEBUG )
set ( ${ basename } _LIBRARY ${ ${basename } _ ${ property } _DEBUG} )
2023-09-09 18:46:34 +03:00
elseif ( ${ basename } _ ${ property } _NOCONFIG )
set ( ${ basename } _LIBRARY ${ ${basename } _ ${ property } _NOCONFIG} )
2020-12-31 15:18:14 +03:00
endif ( )
endforeach ( )
endif ( )
2020-04-21 01:53:12 +03:00
endmacro ( )
2020-12-06 19:26:23 +03:00
macro ( select_executable_location target basename )
2020-12-31 15:18:14 +03:00
if ( TARGET ${ target } )
get_target_property ( ${ basename } _IMPORTED_LOCATION_DEBUG ${ target } IMPORTED_LOCATION_DEBUG )
get_target_property ( ${ basename } _IMPORTED_LOCATION_MINSIZEREL ${ target } IMPORTED_LOCATION_MINSIZEREL )
2023-09-09 18:46:34 +03:00
get_target_property ( ${ basename } _IMPORTED_LOCATION_NOCONFIG ${ target } IMPORTED_LOCATION_NOCONFIG )
2020-12-31 15:18:14 +03:00
get_target_property ( ${ basename } _IMPORTED_LOCATION_RELEASE ${ target } IMPORTED_LOCATION_RELEASE )
get_target_property ( ${ basename } _IMPORTED_LOCATION_RELWITHDEBINFO ${ target } IMPORTED_LOCATION_RELWITHDEBINFO )
2020-12-06 19:26:23 +03:00
2020-12-31 15:18:14 +03:00
if ( ${ basename } _IMPORTED_LOCATION_RELEASE )
set ( ${ basename } _EXECUTABLE ${ ${basename } _IMPORTED_LOCATION_RELEASE} )
elseif ( ${ basename } _IMPORTED_LOCATION_RELWITHDEBINFO )
set ( ${ basename } _EXECUTABLE ${ ${basename } _IMPORTED_LOCATION_RELWITHDEBINFO} )
elseif ( ${ basename } _IMPORTED_LOCATION_MINSIZEREL )
set ( ${ basename } _EXECUTABLE ${ ${basename } _IMPORTED_LOCATION_MINSIZEREL} )
elseif ( ${ basename } _IMPORTED_LOCATION_DEBUG )
set ( ${ basename } _EXECUTABLE ${ ${basename } _IMPORTED_LOCATION_DEBUG} )
2023-09-09 18:46:34 +03:00
elseif ( ${ basename } _IMPORTED_LOCATION_NOCONFIG )
set ( ${ basename } _EXECUTABLE ${ ${basename } _IMPORTED_LOCATION_NOCONFIG} )
2020-12-31 15:18:14 +03:00
endif ( )
2020-12-06 19:26:23 +03:00
endif ( )
endmacro ( )
2020-04-21 01:53:12 +03:00
select_library_location ( LibXml2::LibXml2 LIBXML2 )
2020-12-30 16:40:43 +03:00
select_executable_location ( LibXml2::xmlcatalog LIBXML2_XMLCATALOG )
2020-12-06 19:26:23 +03:00
select_executable_location ( LibXml2::xmllint LIBXML2_XMLLINT )
set ( LIBXML2_LIBRARIES ${ LIBXML2_LIBRARY } )
set ( LIBXML2_INCLUDE_DIRS ${ LIBXML2_INCLUDE_DIR } )
2020-04-21 01:53:12 +03:00
include ( CMakeFindDependencyMacro )
2020-12-31 18:34:25 +03:00
set ( LIBXML2_SHARED @BUILD_SHARED_LIBS@ )
set ( LIBXML2_WITH_ICONV @LIBXML2_WITH_ICONV@ )
set ( LIBXML2_WITH_THREADS @LIBXML2_WITH_THREADS@ )
set ( LIBXML2_WITH_ICU @LIBXML2_WITH_ICU@ )
set ( LIBXML2_WITH_LZMA @LIBXML2_WITH_LZMA@ )
set ( LIBXML2_WITH_ZLIB @LIBXML2_WITH_ZLIB@ )
if ( LIBXML2_WITH_ICONV )
2020-04-21 01:53:12 +03:00
find_dependency ( Iconv )
list ( APPEND LIBXML2_LIBRARIES ${ Iconv_LIBRARIES } )
list ( APPEND LIBXML2_INCLUDE_DIRS ${ Iconv_INCLUDE_DIRS } )
2023-09-10 15:50:18 +03:00
if ( NOT Iconv_FOUND )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _FOUND FALSE )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _NOT_FOUND_MESSAGE "Iconv dependency was not found" )
return ( )
endif ( )
2020-04-21 01:53:12 +03:00
endif ( )
2020-12-31 18:34:25 +03:00
if ( NOT LIBXML2_SHARED )
2020-11-20 00:06:23 +03:00
set ( LIBXML2_DEFINITIONS -DLIBXML_STATIC )
2020-12-31 18:34:25 +03:00
if ( LIBXML2_WITH_THREADS )
2020-04-21 01:53:12 +03:00
find_dependency ( Threads )
list ( APPEND LIBXML2_LIBRARIES ${ CMAKE_THREAD_LIBS_INIT } )
2023-09-10 15:50:18 +03:00
if ( NOT Threads_FOUND )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _FOUND FALSE )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _NOT_FOUND_MESSAGE "Threads dependency was not found" )
return ( )
endif ( )
2020-04-21 01:53:12 +03:00
endif ( )
2020-12-31 18:34:25 +03:00
if ( LIBXML2_WITH_ICU )
2020-12-30 16:28:24 +03:00
find_dependency ( ICU COMPONENTS data i18n uc )
2020-04-21 01:53:12 +03:00
list ( APPEND LIBXML2_LIBRARIES ${ ICU_LIBRARIES } )
2023-09-10 15:50:18 +03:00
if ( NOT ICU_FOUND )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _FOUND FALSE )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _NOT_FOUND_MESSAGE "ICU dependency was not found" )
return ( )
endif ( )
2020-04-21 01:53:12 +03:00
endif ( )
2020-12-31 18:34:25 +03:00
if ( LIBXML2_WITH_LZMA )
2020-04-21 01:53:12 +03:00
find_dependency ( LibLZMA )
list ( APPEND LIBXML2_LIBRARIES ${ LIBLZMA_LIBRARIES } )
2023-09-10 15:50:18 +03:00
if ( NOT LibLZMA_FOUND )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _FOUND FALSE )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _NOT_FOUND_MESSAGE "LibLZMA dependency was not found" )
return ( )
endif ( )
2020-04-21 01:53:12 +03:00
endif ( )
2020-12-31 18:34:25 +03:00
if ( LIBXML2_WITH_ZLIB )
2020-04-21 01:53:12 +03:00
find_dependency ( ZLIB )
list ( APPEND LIBXML2_LIBRARIES ${ ZLIB_LIBRARIES } )
2023-09-10 15:50:18 +03:00
if ( NOT ZLIB_FOUND )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _FOUND FALSE )
set ( ${ CMAKE_FIND_PACKAGE_NAME } _NOT_FOUND_MESSAGE "ZLIB dependency was not found" )
return ( )
endif ( )
2020-04-21 01:53:12 +03:00
endif ( )
if ( UNIX )
list ( APPEND LIBXML2_LIBRARIES m )
endif ( )
if ( WIN32 )
list ( APPEND LIBXML2_LIBRARIES ws2_32 )
endif ( )
endif ( )
# whether libxml2 has dso support
set ( LIBXML2_MODULES @LIBXML2_WITH_MODULES@ )
2020-12-30 16:40:43 +03:00
mark_as_advanced ( LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE )