| 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 |
# SPDX-FileCopyrightText: 2014 Alex Merry <[email protected]> |
| 34 |
# SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]> |
| 35 |
# |
| 36 |
# SPDX-License-Identifier: BSD-3-Clause |
| 37 |
#============================================================================= |
| 38 |
|
| 39 |
if(CMAKE_VERSION VERSION_LESS 2.8.12) |
| 40 |
message(FATAL_ERROR "CMake 2.8.12 is required by FindLibdrm.cmake") |
| 41 |
endif() |
| 42 |
if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) |
| 43 |
message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibdrm.cmake") |
| 44 |
endif() |
| 45 |
|
| 46 |
if(NOT WIN32) |
| 47 |
# Use pkg-config to get the directories and then use these values |
| 48 |
# in the FIND_PATH() and FIND_LIBRARY() calls |
| 49 |
find_package(PkgConfig) |
| 50 |
pkg_check_modules(PKG_Libdrm QUIET libdrm) |
| 51 |
|
| 52 |
set(Libdrm_DEFINITIONS ${PKG_Libdrm_CFLAGS_OTHER}) |
| 53 |
set(Libdrm_VERSION ${PKG_Libdrm_VERSION}) |
| 54 |
|
| 55 |
find_path(Libdrm_INCLUDE_DIR |
| 56 |
NAMES |
| 57 |
xf86drm.h |
| 58 |
HINTS |
| 59 |
${PKG_Libdrm_INCLUDE_DIRS} |
| 60 |
) |
| 61 |
find_library(Libdrm_LIBRARY |
| 62 |
NAMES |
| 63 |
drm |
| 64 |
HINTS |
| 65 |
${PKG_Libdrm_LIBRARY_DIRS} |
| 66 |
) |
| 67 |
|
| 68 |
include(FindPackageHandleStandardArgs) |
| 69 |
find_package_handle_standard_args(Libdrm |
| 70 |
FOUND_VAR |
| 71 |
Libdrm_FOUND |
| 72 |
REQUIRED_VARS |
| 73 |
Libdrm_LIBRARY |
| 74 |
Libdrm_INCLUDE_DIR |
| 75 |
VERSION_VAR |
| 76 |
Libdrm_VERSION |
| 77 |
) |
| 78 |
|
| 79 |
if(Libdrm_FOUND AND NOT TARGET Libdrm::Libdrm) |
| 80 |
add_library(Libdrm::Libdrm UNKNOWN IMPORTED) |
| 81 |
set_target_properties(Libdrm::Libdrm PROPERTIES |
| 82 |
IMPORTED_LOCATION "${Libdrm_LIBRARY}" |
| 83 |
INTERFACE_COMPILE_OPTIONS "${Libdrm_DEFINITIONS}" |
| 84 |
INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}" |
| 85 |
INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}/libdrm" |
| 86 |
) |
| 87 |
endif() |
| 88 |
|
| 89 |
mark_as_advanced(Libdrm_LIBRARY Libdrm_INCLUDE_DIR) |
| 90 |
|
| 91 |
# compatibility variables |
| 92 |
set(Libdrm_LIBRARIES ${Libdrm_LIBRARY}) |
| 93 |
set(Libdrm_INCLUDE_DIRS ${Libdrm_INCLUDE_DIR} "${Libdrm_INCLUDE_DIR}/libdrm") |
| 94 |
set(Libdrm_VERSION_STRING ${Libdrm_VERSION}) |
| 95 |
|
| 96 |
else() |
| 97 |
message(STATUS "FindLibdrm.cmake cannot find libdrm on Windows systems.") |
| 98 |
set(Libdrm_FOUND FALSE) |
| 99 |
endif() |
| 100 |
|
| 101 |
include(FeatureSummary) |
| 102 |
set_package_properties(Libdrm PROPERTIES |
| 103 |
URL "https://wiki.freedesktop.org/dri/" |
| 104 |
DESCRIPTION "Userspace interface to kernel DRM services" |
| 105 |
) |