FindLibXml2.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #
  9. # Copyright (c) 2006, Alexander Neundorf <[email protected]>
  10. # This code is available under the BSD license, see licenses/BSD for details.
  11. # Copyright (c) 2006, Alexander Neundorf, <[email protected]>
  12. #
  13. # Redistribution and use is allowed according to the terms of the BSD license.
  14. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  15. IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  16. # in cache already
  17. SET(LibXml2_FIND_QUIETLY TRUE)
  18. ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  19. IF (NOT WIN32)
  20. # use pkg-config to get the directories and then use these values
  21. # in the FIND_PATH() and FIND_LIBRARY() calls
  22. INCLUDE(UsePkgConfig)
  23. PKGCONFIG(libxml-2.0 _LibXml2IncDir _LibXml2LinkDir _LibXml2LinkFlags _LibXml2Cflags)
  24. SET(LIBXML2_DEFINITIONS ${_LibXml2Cflags})
  25. ENDIF (NOT WIN32)
  26. FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h
  27. PATHS
  28. ${_LibXml2IncDir}
  29. PATH_SUFFIXES libxml2
  30. )
  31. FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2
  32. PATHS
  33. ${_LibXml2LinkDir}
  34. )
  35. IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  36. SET(LIBXML2_FOUND TRUE)
  37. ELSE (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  38. SET(LIBXML2_FOUND FALSE)
  39. ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
  40. IF (LIBXML2_FOUND)
  41. IF (NOT LibXml2_FIND_QUIETLY)
  42. MESSAGE(STATUS "Found LibXml2: ${LIBXML2_LIBRARIES}")
  43. ENDIF (NOT LibXml2_FIND_QUIETLY)
  44. ELSE (LIBXML2_FOUND)
  45. IF (LibXml2_FIND_REQUIRED)
  46. MESSAGE(SEND_ERROR "Could NOT find LibXml2")
  47. ENDIF (LibXml2_FIND_REQUIRED)
  48. ENDIF (LIBXML2_FOUND)
  49. MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES)