FindLibXslt.cmake 2.4 KB

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