FindLibXslt.cmake 2.9 KB

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