FindLibXml2.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # - Try to find LibXml2
  2. # Once done this will define
  3. #
  4. # LIBXML2_FOUND - System has LibXml2
  5. # LIBXML2_INCLUDE_DIR - The LibXml2 include directory
  6. # LIBXML2_LIBRARIES - The libraries needed to use LibXml2
  7. # LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2
  8. # LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibXml2
  9. #=============================================================================
  10. # Copyright 2006-2009 Kitware, Inc.
  11. # Copyright 2006 Alexander Neundorf <[email protected]>
  12. #
  13. # Distributed under the OSI-approved BSD License (the "License");
  14. # see accompanying file Copyright.txt for details.
  15. #
  16. # This software is distributed WITHOUT ANY WARRANTY; without even the
  17. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. # See the License for more information.
  19. #=============================================================================
  20. # (To distributed this file outside of CMake, substitute the full
  21. # License text for the above reference.)
  22. IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  23. # in cache already
  24. SET(LibXml2_FIND_QUIETLY TRUE)
  25. ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  26. IF (NOT WIN32)
  27. # use pkg-config to get the directories and then use these values
  28. # in the FIND_PATH() and FIND_LIBRARY() calls
  29. FIND_PACKAGE(PkgConfig)
  30. PKG_CHECK_MODULES(PC_LIBXML libxml-2.0)
  31. SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})
  32. ENDIF (NOT WIN32)
  33. FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h
  34. HINTS
  35. ${PC_LIBXML_INCLUDEDIR}
  36. ${PC_LIBXML_INCLUDE_DIRS}
  37. PATH_SUFFIXES libxml2
  38. )
  39. FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2
  40. HINTS
  41. ${PC_LIBXML_LIBDIR}
  42. ${PC_LIBXML_LIBRARY_DIRS}
  43. )
  44. FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint)
  45. # for backwards compat. with KDE 4.0.x:
  46. SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}")
  47. INCLUDE(FindPackageHandleStandardArgs)
  48. # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
  49. # all listed variables are TRUE
  50. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
  51. MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE)