cmake: add LibDRM module

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-02-15 18:43:07 +02:00
parent de3a8cf44f
commit d35c0b1e0b
2 changed files with 43 additions and 0 deletions

View file

@ -46,6 +46,7 @@ set(cmakeFiles
FindKipi.cmake
FindKSane.cmake
FindLibAttica.cmake
FindLibDRM.cmake
FindLibGcrypt.cmake
FindLibGPS.cmake
FindLibintl.cmake

View file

@ -0,0 +1,42 @@
# - Try to find libdrm library
#
# Once done this will define
#
# LIBDRM_FOUND - system has libdrm
# LIBDRM_INCLUDE_DIR - the libdrm include directory
# LIBDRM_LIBRARIES - the libraries needed to use libdrm
#
# Copyright (c) 2021, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_LIBDRM QUIET libdrm)
set(LIBDRM_INCLUDE_DIR ${PC_LIBDRM_INCLUDE_DIRS})
set(LIBDRM_LIBRARIES ${PC_LIBDRM_LIBRARIES})
endif()
set(LIBDRM_VERSION ${PC_LIBDRM_VERSION})
if(NOT LIBDRM_INCLUDE_DIR OR NOT LIBDRM_LIBRARIES)
find_path(LIBDRM_INCLUDE_DIR
NAMES libdrm/drm.h
HINTS $ENV{LIBDRMDIR}/include
)
find_library(LIBDRM_LIBRARIES
NAMES drm
HINTS $ENV{LIBDRMDIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibDRM
VERSION_VAR LIBDRM_VERSION
REQUIRED_VARS LIBDRM_LIBRARIES LIBDRM_INCLUDE_DIR
)
mark_as_advanced(LIBDRM_INCLUDE_DIR LIBDRM_LIBRARIES)