summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/FindKMS.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/cmake/FindKMS.cmake b/cmake/FindKMS.cmake
new file mode 100644
index 00000000..55679ad1
--- /dev/null
+++ b/cmake/FindKMS.cmake
@@ -0,0 +1,33 @@
+# - FindKMS
+#
+# Copyright © 2017 Keith Packard <keithp@keithp.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+
+# Use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+#
+FIND_PACKAGE(PkgConfig)
+PKG_CHECK_MODULES(PKG_KMS QUIET libdrm)
+
+SET(KMS_DEFINITIONS ${PKG_KMS_CFLAGS})
+
+FIND_PATH(KMS_TOP_INCLUDE_DIR NAMES xf86drm.h HINTS ${PKG_KMS_INCLUDE_DIRS})
+FIND_PATH(KMS_DRM_INCLUDE_DIR NAMES drm.h HINTS ${PKG_KMS_INCLUDE_DIRS})
+SET(KMS_INCLUDE_DIR ${KMS_TOP_INCLUDE_DIR} ${KMS_DRM_INCLUDE_DIR})
+FIND_LIBRARY(KMS_LIBRARIES NAMES drm HINTS ${PKG_KMS_LIBRARY_DIRS})
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(KMS DEFAULT_MSG KMS_LIBRARIES KMS_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(KMS_INCLUDE_DIR KMS_LIBRARIES)
+