FindCups.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # - Try to find the Cups printing system
  2. # Once done this will define
  3. #
  4. # CUPS_FOUND - system has Cups
  5. # CUPS_INCLUDE_DIR - the Cups include directory
  6. # CUPS_LIBRARIES - Libraries needed to use Cups
  7. # CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8)
  8. # Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which
  9. # features this function (i.e. at least 1.1.19)
  10. #=============================================================================
  11. # Copyright 2006-2009 Kitware, Inc.
  12. # Copyright 2006 Alexander Neundorf <[email protected]>
  13. # Copyright 2012 Rolf Eike Beer <[email protected]>
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  18. # This software is distributed WITHOUT ANY WARRANTY; without even the
  19. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. # See the License for more information.
  21. #=============================================================================
  22. # (To distribute this file outside of CMake, substitute the full
  23. # License text for the above reference.)
  24. find_path(CUPS_INCLUDE_DIR cups/cups.h )
  25. find_library(CUPS_LIBRARIES NAMES cups )
  26. if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
  27. include(CheckLibraryExists)
  28. # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint)
  29. CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE)
  30. endif ()
  31. if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h")
  32. file(STRINGS "${CUPS_INCLUDE_DIR}/cups/cups.h" cups_version_str
  33. REGEX "^#[\t ]*define[\t ]+CUPS_VERSION_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
  34. unset(CUPS_VERSION_STRING)
  35. foreach(VPART MAJOR MINOR PATCH)
  36. foreach(VLINE ${cups_version_str})
  37. if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}")
  38. string(REGEX REPLACE "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$" "\\1"
  39. CUPS_VERSION_PART "${VLINE}")
  40. if(CUPS_VERSION_STRING)
  41. set(CUPS_VERSION_STRING "${CUPS_VERSION_STRING}.${CUPS_VERSION_PART}")
  42. else()
  43. set(CUPS_VERSION_STRING "${CUPS_VERSION_PART}")
  44. endif()
  45. endif()
  46. endforeach()
  47. endforeach()
  48. endif ()
  49. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  50. if (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
  51. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups
  52. REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR CUPS_HAS_IPP_DELETE_ATTRIBUTE
  53. VERSION_VAR CUPS_VERSION_STRING)
  54. else ()
  55. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups
  56. REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR
  57. VERSION_VAR CUPS_VERSION_STRING)
  58. endif ()
  59. mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES)