FindLibXslt.cmake 2.6 KB

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