FindLibXml2.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # Copyright (c) 2006, Alexander Neundorf, <[email protected]>
  9. #
  10. # Redistribution and use is allowed according to the terms of the BSD license.
  11. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  12. IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  13. # in cache already
  14. SET(LibXml2_FIND_QUIETLY TRUE)
  15. ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  16. IF (NOT WIN32)
  17. # use pkg-config to get the directories and then use these values
  18. # in the FIND_PATH() and FIND_LIBRARY() calls
  19. INCLUDE(UsePkgConfig)
  20. PKGCONFIG(libxml-2.0 _LibXml2IncDir _LibXml2LinkDir _LibXml2LinkFlags _LibXml2Cflags)
  21. SET(LIBXML2_DEFINITIONS ${_LibXml2Cflags})
  22. ENDIF (NOT WIN32)
  23. FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h
  24. PATHS
  25. ${_LibXml2IncDir}
  26. PATH_SUFFIXES libxml2
  27. )
  28. FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2
  29. PATHS
  30. ${_LibXml2LinkDir}
  31. )
  32. INCLUDE(FindPackageHandleStandardArgs)
  33. # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
  34. # all listed variables are TRUE
  35. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
  36. MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES)