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