Provide cmake module

* add libxml2-config.cmake.in template
* configure.ac: add libxml2-config.cmake.in to the configured file list
* Makefile.am: install libxml2-config.cmake under ${libdir}/cmake/libxml2

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
This commit is contained in:
Samuel Martin 2014-10-11 21:50:41 +02:00 committed by Daniel Veillard
parent af62eb4fab
commit fa23ac1a79
3 changed files with 55 additions and 1 deletions

View File

@ -1207,6 +1207,7 @@ EXTRA_DIST = xml2-config.in xml2Conf.sh.in libxml.spec.in libxml2.spec \
check-xsddata-test-suite.py check-xinclude-test-suite.py \
example/Makefile.am example/gjobread.c example/gjobs.xml \
$(man_MANS) libxml-2.0.pc.in libxml-2.0-uninstalled.pc.in \
libxml2-config.cmake.in \
trionan.c trionan.h triostr.c triostr.h trio.c trio.h \
triop.h triodef.h libxml.h elfgcchack.h xzlib.h buf.h \
enc.h save.h testThreadsWin32.c genUnicode.py TODO_SCHEMAS \
@ -1218,6 +1219,9 @@ EXTRA_DIST = xml2-config.in xml2Conf.sh.in libxml.spec.in libxml2.spec \
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxml-2.0.pc
cmakedir = $(libdir)/cmake/libxml2
cmake_DATA = libxml2-config.cmake
#
# Install the tests program sources as examples
#

View File

@ -1656,7 +1656,7 @@ rm -f COPYING.LIB COPYING
ln -s $srcdir/Copyright COPYING
# keep on one line for cygwin c.f. #130896
AC_CONFIG_FILES([libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h xml2-config libxml-2.0.pc libxml-2.0-uninstalled.pc python/setup.py])
AC_CONFIG_FILES([libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h xml2-config libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake python/setup.py])
AC_OUTPUT
chmod +x xml2-config python/setup.py

50
libxml2-config.cmake.in Normal file
View File

@ -0,0 +1,50 @@
# libxml2-config.cmake
# --------------------
#
# Libxml2 cmake module.
# THis module sets the following variables:
#
# ::
#
# LIBXML2_INCLUDE_DIRS - Directory where libxml2 headers are located.
# LIBXML2_LIBRARIES - xml2 libraries to link against.
# 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 as dso support
get_filename_component(_libxml2_rootdir ${CMAKE_CURRENT_LIST_DIR}/../../../ ABSOLUTE)
set(LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@)
set(LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@)
set(LIBXML2_VERSION_MICRO @LIBXML_MICRO_VERSION@)
set(LIBXML2_VERSION_STRING "@VERSION@")
set(LIBXML2_INSTALL_PREFIX ${_libxml2_rootdir})
set(LIBXML2_INCLUDE_DIRS ${_libxml2_rootdir}/include)
set(LIBXML2_LIBRARY_DIR ${_libxml2_rootdir}/lib)
set(LIBXML2_LIBRARIES -L${LIBXML2_LIBRARY_DIR} -lxml2)
if(@WITH_THREADS@)
find_package(Threads REQUIRED)
list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
if(@WITH_LZMA@)
find_package(LibLZMA REQUIRED)
list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})
list(APPEND LIBXML2_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIRS})
endif()
if(@WITH_ZLIB@)
find_package(ZLIB REQUIRED)
list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES})
list(APPEND LIBXML2_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
endif()
list(APPEND LIBXML2_LIBRARIES @ICU_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@)
# whether libxml2 has dso support
set(LIBXML2_MODULES @WITH_MODULES@)
mark_as_advanced( LIBXML2_INCLUDE_DIRS LIBXML2_LIBRARIES )