FindCups.cmake 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. FindCups
  5. --------
  6. Find the Common UNIX Printing System (CUPS).
  7. Set ``CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE`` to ``TRUE`` if you need a version which
  8. features this function (i.e. at least ``1.1.19``)
  9. Imported targets
  10. ^^^^^^^^^^^^^^^^
  11. This module defines :prop_tgt:`IMPORTED` target ``Cups::Cups``, if Cups has
  12. been found.
  13. Result variables
  14. ^^^^^^^^^^^^^^^^
  15. This module will set the following variables in your project:
  16. ``CUPS_FOUND``
  17. true if CUPS headers and libraries were found
  18. ``CUPS_INCLUDE_DIRS``
  19. the directory containing the Cups headers
  20. ``CUPS_LIBRARIES``
  21. the libraries to link against to use CUPS.
  22. ``CUPS_VERSION_STRING``
  23. the version of CUPS found (since CMake 2.8.8)
  24. Cache variables
  25. ^^^^^^^^^^^^^^^
  26. The following cache variables may also be set:
  27. ``CUPS_INCLUDE_DIR``
  28. the directory containing the Cups headers
  29. #]=======================================================================]
  30. find_path(CUPS_INCLUDE_DIR cups/cups.h )
  31. find_library(CUPS_LIBRARIES NAMES cups )
  32. if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
  33. include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
  34. include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
  35. cmake_push_check_state()
  36. set(CMAKE_REQUIRED_QUIET ${Cups_FIND_QUIETLY})
  37. # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint)
  38. CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE)
  39. cmake_pop_check_state()
  40. endif ()
  41. if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h")
  42. file(STRINGS "${CUPS_INCLUDE_DIR}/cups/cups.h" cups_version_str
  43. REGEX "^#[\t ]*define[\t ]+CUPS_VERSION_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
  44. unset(CUPS_VERSION_STRING)
  45. foreach(VPART MAJOR MINOR PATCH)
  46. foreach(VLINE ${cups_version_str})
  47. if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$")
  48. set(CUPS_VERSION_PART "${CMAKE_MATCH_1}")
  49. if(CUPS_VERSION_STRING)
  50. string(APPEND CUPS_VERSION_STRING ".${CUPS_VERSION_PART}")
  51. else()
  52. set(CUPS_VERSION_STRING "${CUPS_VERSION_PART}")
  53. endif()
  54. endif()
  55. endforeach()
  56. endforeach()
  57. endif ()
  58. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  59. if (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
  60. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups
  61. REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR CUPS_HAS_IPP_DELETE_ATTRIBUTE
  62. VERSION_VAR CUPS_VERSION_STRING)
  63. else ()
  64. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups
  65. REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR
  66. VERSION_VAR CUPS_VERSION_STRING)
  67. endif ()
  68. mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES)
  69. if (CUPS_FOUND)
  70. set(CUPS_INCLUDE_DIRS "${CUPS_INCLUDE_DIR}")
  71. if (NOT TARGET Cups::Cups)
  72. add_library(Cups::Cups INTERFACE IMPORTED)
  73. set_target_properties(Cups::Cups PROPERTIES
  74. INTERFACE_LINK_LIBRARIES "${CUPS_LIBRARIES}"
  75. INTERFACE_INCLUDE_DIRECTORIES "${CUPS_INCLUDE_DIR}")
  76. endif ()
  77. endif ()