FindLibXslt.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #.rst:
  2. # FindLibXslt
  3. # -----------
  4. #
  5. # Try to find the LibXslt library
  6. #
  7. # Once done this will define
  8. #
  9. # ::
  10. #
  11. # LIBXSLT_FOUND - system has LibXslt
  12. # LIBXSLT_INCLUDE_DIR - the LibXslt include directory
  13. # LIBXSLT_LIBRARIES - Link these to LibXslt
  14. # LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt
  15. # LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8)
  16. #
  17. # Additionally, the following two variables are set (but not required
  18. # for using xslt):
  19. #
  20. # ``LIBXSLT_EXSLT_LIBRARIES``
  21. # Link to these if you need to link against the exslt library.
  22. # ``LIBXSLT_XSLTPROC_EXECUTABLE``
  23. # Contains the full path to the xsltproc executable if found.
  24. #=============================================================================
  25. # Copyright 2006-2009 Kitware, Inc.
  26. # Copyright 2006 Alexander Neundorf <neundorf@kde.org>
  27. #
  28. # Distributed under the OSI-approved BSD License (the "License");
  29. # see accompanying file Copyright.txt for details.
  30. #
  31. # This software is distributed WITHOUT ANY WARRANTY; without even the
  32. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  33. # See the License for more information.
  34. #=============================================================================
  35. # (To distribute this file outside of CMake, substitute the full
  36. # License text for the above reference.)
  37. # use pkg-config to get the directories and then use these values
  38. # in the find_path() and find_library() calls
  39. find_package(PkgConfig QUIET)
  40. PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt)
  41. set(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER})
  42. find_path(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h
  43. HINTS
  44. ${PC_LIBXSLT_INCLUDEDIR}
  45. ${PC_LIBXSLT_INCLUDE_DIRS}
  46. )
  47. find_library(LIBXSLT_LIBRARIES NAMES xslt libxslt
  48. HINTS
  49. ${PC_LIBXSLT_LIBDIR}
  50. ${PC_LIBXSLT_LIBRARY_DIRS}
  51. )
  52. find_library(LIBXSLT_EXSLT_LIBRARY NAMES exslt libexslt
  53. HINTS
  54. ${PC_LIBXSLT_LIBDIR}
  55. ${PC_LIBXSLT_LIBRARY_DIRS}
  56. )
  57. set(LIBXSLT_EXSLT_LIBRARIES ${LIBXSLT_EXSLT_LIBRARY} )
  58. find_program(LIBXSLT_XSLTPROC_EXECUTABLE xsltproc)
  59. if(PC_LIBXSLT_VERSION)
  60. set(LIBXSLT_VERSION_STRING ${PC_LIBXSLT_VERSION})
  61. elseif(LIBXSLT_INCLUDE_DIR AND EXISTS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h")
  62. file(STRINGS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h" libxslt_version_str
  63. REGEX "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\".*\"")
  64. string(REGEX REPLACE "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
  65. LIBXSLT_VERSION_STRING "${libxslt_version_str}")
  66. unset(libxslt_version_str)
  67. endif()
  68. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  69. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt
  70. REQUIRED_VARS LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR
  71. VERSION_VAR LIBXSLT_VERSION_STRING)
  72. mark_as_advanced(LIBXSLT_INCLUDE_DIR
  73. LIBXSLT_LIBRARIES
  74. LIBXSLT_EXSLT_LIBRARY
  75. LIBXSLT_XSLTPROC_EXECUTABLE)