Debian Codegraph @

cmake/3rdparty/kwin/FindLibdrm.cmake

raw
1 #.rst:
2 # FindLibdrm
3 # -------
4 #
5 # Try to find libdrm on a Unix system.
6 #
7 # This will define the following variables:
8 #
9 # ``Libdrm_FOUND``
10 # True if (the requested version of) libdrm is available
11 # ``Libdrm_VERSION``
12 # The version of libdrm
13 # ``Libdrm_LIBRARIES``
14 # This can be passed to target_link_libraries() instead of the ``Libdrm::Libdrm``
15 # target
16 # ``Libdrm_INCLUDE_DIRS``
17 # This should be passed to target_include_directories() if the target is not
18 # used for linking
19 # ``Libdrm_DEFINITIONS``
20 # This should be passed to target_compile_options() if the target is not
21 # used for linking
22 #
23 # If ``Libdrm_FOUND`` is TRUE, it will also define the following imported target:
24 #
25 # ``Libdrm::Libdrm``
26 # The libdrm library
27 #
28 # In general we recommend using the imported target, as it is easier to use.
29 # Bear in mind, however, that if the target is in the link interface of an
30 # exported library, it must be made available by the package config file.
31
32 #=============================================================================
33 # Copyright 2014 Alex Merry <[email protected]>
34 # Copyright 2014 Martin Gräßlin <[email protected]>
35 #
36 # Redistribution and use in source and binary forms, with or without
37 # modification, are permitted provided that the following conditions
38 # are met:
39 #
40 # 1. Redistributions of source code must retain the copyright
41 # notice, this list of conditions and the following disclaimer.
42 # 2. Redistributions in binary form must reproduce the copyright
43 # notice, this list of conditions and the following disclaimer in the
44 # documentation and/or other materials provided with the distribution.
45 # 3. The name of the author may not be used to endorse or promote products
46 # derived from this software without specific prior written permission.
47 #
48 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
49 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
50 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
51 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
52 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
57 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 #=============================================================================
59
60 if(CMAKE_VERSION VERSION_LESS 2.8.12)
61 message(FATAL_ERROR "CMake 2.8.12 is required by FindLibdrm.cmake")
62 endif()
63 if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
64 message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibdrm.cmake")
65 endif()
66
67 if(NOT WIN32)
68 if (VXWORKS)
69 set(_vxworks_lib_search_path "$ENV{WIND_CC_SYSROOT}/usr/lib/common/")
70 set(_vxworks_lib_drm_library_name gfxLibDRM)
71 endif()
72
73 find_package(PkgConfig QUIET)
74 pkg_check_modules(PKG_Libdrm QUIET libdrm ${_vxworks_lib_drm_library_name})
75
76 set(Libdrm_DEFINITIONS ${PKG_Libdrm_CFLAGS_OTHER})
77 set(Libdrm_VERSION ${PKG_Libdrm_VERSION})
78
79 find_path(Libdrm_INCLUDE_DIR
80 NAMES
81 xf86drm.h
82 HINTS
83 ${PKG_Libdrm_INCLUDE_DIRS}
84 PATH_SUFFIXES
85 libdrm
86 )
87 find_library(Libdrm_LIBRARY
88 NAMES
89 drm
90 ${_vxworks_lib_drm_library_name}
91 HINTS
92 ${PKG_Libdrm_LIBRARY_DIRS}
93 "${_vxworks_lib_search_path}"
94 )
95
96 include(FindPackageHandleStandardArgs)
97 find_package_handle_standard_args(Libdrm
98 FOUND_VAR
99 Libdrm_FOUND
100 REQUIRED_VARS
101 Libdrm_LIBRARY
102 Libdrm_INCLUDE_DIR
103 VERSION_VAR
104 Libdrm_VERSION
105 )
106
107 if(Libdrm_FOUND AND NOT TARGET Libdrm::Libdrm)
108 add_library(Libdrm::Libdrm UNKNOWN IMPORTED)
109 set_target_properties(Libdrm::Libdrm PROPERTIES
110 IMPORTED_LOCATION "${Libdrm_LIBRARY}"
111 INTERFACE_COMPILE_OPTIONS "${Libdrm_DEFINITIONS}"
112 INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}"
113 )
114 foreach(suffix libdrm drm)
115 if(EXISTS "${Libdrm_INCLUDE_DIR}/${suffix}")
116 set_property(TARGET Libdrm::Libdrm APPEND PROPERTY
117 INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}/${suffix}"
118 )
119 endif()
120 endforeach()
121 endif()
122
123 mark_as_advanced(Libdrm_LIBRARY Libdrm_INCLUDE_DIR)
124
125 # compatibility variables
126 set(Libdrm_LIBRARIES ${Libdrm_LIBRARY})
127 set(Libdrm_INCLUDE_DIRS ${Libdrm_INCLUDE_DIR} "${Libdrm_INCLUDE_DIR}/libdrm" "${Libdrm_INCLUDE_DIR}/drm")
128 set(Libdrm_VERSION_STRING ${Libdrm_VERSION})
129
130 else()
131 message(STATUS "FindLibdrm.cmake cannot find libdrm on Windows systems.")
132 set(Libdrm_FOUND FALSE)
133 endif()
134
135 include(FeatureSummary)
136 set_package_properties(Libdrm PROPERTIES
137 URL "https://wiki.freedesktop.org/dri/"
138 DESCRIPTION "Userspace interface to kernel DRM services."
139 )