FindLibXslt.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindLibXslt
  5. -----------
  6. Try to find the LibXslt library
  7. Once done this will define
  8. ::
  9. LIBXSLT_FOUND - system has LibXslt
  10. LIBXSLT_INCLUDE_DIR - the LibXslt include directory
  11. LIBXSLT_LIBRARIES - Link these to LibXslt
  12. LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt
  13. LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8)
  14. Additionally, the following two variables are set (but not required
  15. for using xslt):
  16. ``LIBXSLT_EXSLT_LIBRARIES``
  17. Link to these if you need to link against the exslt library.
  18. ``LIBXSLT_XSLTPROC_EXECUTABLE``
  19. Contains the full path to the xsltproc executable if found.
  20. #]=======================================================================]
  21. # use pkg-config to get the directories and then use these values
  22. # in the find_path() and find_library() calls
  23. find_package(PkgConfig QUIET)
  24. PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt)
  25. set(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER})
  26. find_path(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h
  27. HINTS
  28. ${PC_LIBXSLT_INCLUDEDIR}
  29. ${PC_LIBXSLT_INCLUDE_DIRS}
  30. )
  31. find_library(LIBXSLT_LIBRARIES NAMES xslt libxslt
  32. HINTS
  33. ${PC_LIBXSLT_LIBDIR}
  34. ${PC_LIBXSLT_LIBRARY_DIRS}
  35. )
  36. find_library(LIBXSLT_EXSLT_LIBRARY NAMES exslt libexslt
  37. HINTS
  38. ${PC_LIBXSLT_LIBDIR}
  39. ${PC_LIBXSLT_LIBRARY_DIRS}
  40. )
  41. set(LIBXSLT_EXSLT_LIBRARIES ${LIBXSLT_EXSLT_LIBRARY} )
  42. find_program(LIBXSLT_XSLTPROC_EXECUTABLE xsltproc)
  43. if(PC_LIBXSLT_VERSION)
  44. set(LIBXSLT_VERSION_STRING ${PC_LIBXSLT_VERSION})
  45. elseif(LIBXSLT_INCLUDE_DIR AND EXISTS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h")
  46. file(STRINGS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h" libxslt_version_str
  47. REGEX "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\".*\"")
  48. string(REGEX REPLACE "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
  49. LIBXSLT_VERSION_STRING "${libxslt_version_str}")
  50. unset(libxslt_version_str)
  51. endif()
  52. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  53. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt
  54. REQUIRED_VARS LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR
  55. VERSION_VAR LIBXSLT_VERSION_STRING)
  56. mark_as_advanced(LIBXSLT_INCLUDE_DIR
  57. LIBXSLT_LIBRARIES
  58. LIBXSLT_EXSLT_LIBRARY
  59. LIBXSLT_XSLTPROC_EXECUTABLE)