[PATCH] Autodetect libdrm path (v2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(v2):  Use findLibDRM script instead of directly finding path

Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
 CMakeLists.txt                 |  3 +++
 cmake_modules/FindLibDRM.cmake | 35 +++++++++++++++++++++++++++++++++++
 src/lib/query_drm.c            |  4 ++--
 3 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 cmake_modules/FindLibDRM.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bef94fdba788..ef78c97ad763 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,9 @@ include_directories(${CURSES_INCLUDE_DIRS})
 find_package(PCIAccess REQUIRED)
 include_directories(${PCIACCESS_INCLUDE_DIR})
 
+find_package(LibDRM REQUIRED)
+include_directories(${LIBDRM_INCLUDE_DIR})
+
 set(REQUIRED_EXTERNAL_LIBS
   ${CURSES_LIBRARIES}
   ${PCIACCESS_LIBRARIES}
diff --git a/cmake_modules/FindLibDRM.cmake b/cmake_modules/FindLibDRM.cmake
new file mode 100644
index 000000000000..e840c4d1bfd0
--- /dev/null
+++ b/cmake_modules/FindLibDRM.cmake
@@ -0,0 +1,35 @@
+# Try to find libdrm
+#
+# Once done, this will define
+#
+# LIBDRM_FOUND
+# LIBDRM_INCLUDE_DIR
+# LIBDRM_LIBRARIES
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_LIBDRM QUIET libdrm)
+
+find_path(LIBDRM_INCLUDE_DIR NAMES amdgpu_drm.h
+    HINTS
+    ${PC_LIBDRM_INCLUDEDIR}
+    ${PC_LIBDRM_INCLUDE_DIRS}
+    /usr/include
+)
+
+find_library(LIBDRM_LIBRARY NAMES libdrm_amdgpu.so.1
+    HINTS
+    ${PC_LIBDRM_LIBDIR}
+    ${PC_LIBDRM_LIBRARY_DIRS}
+    /usr/lib64
+    /usr/lib
+)
+
+SET(LIBDRM_LIBRARIES optimized ${LIBDRM_LIBRARY})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LIBDRM DEFAULT_MSG
+	LIBDRM_LIBRARIES LIBDRM_INCLUDE_DIR
+)
+
+mark_as_advanced(LIBDRM_INCLUDE_DIR LIBDRM_LIBRARIES)
diff --git a/src/lib/query_drm.c b/src/lib/query_drm.c
index b9d80a8fc0c8..755c65fbc662 100644
--- a/src/lib/query_drm.c
+++ b/src/lib/query_drm.c
@@ -25,8 +25,8 @@
 #include "umr.h"
 #include <asm/ioctl.h>
 #include <sys/ioctl.h>
-#include <drm/drm.h>
-#include <drm/amdgpu_drm.h>
+#include <drm.h>
+#include <amdgpu_drm.h>
 
 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
 #define DRM_IOC_WRITE           _IOC_WRITE
-- 
2.11.0



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux