[PATCH] autodetect path to libdrm

Andres Rodriguez andresx7 at gmail.com
Sun Feb 5 21:26:21 UTC 2017


Hey Tom,

Overall in cmake calling pkg_check_modules() directly is usually not a
good practice. The common approach is to have a file in
cmake/modules/Find$(name).cmake that takes care of everything.

For example, you could use this FindLibdrm.cmake from the KDE project:
https://github.com/KDE/kwin/blob/master/cmake/modules/FindLibdrm.cmake

Alternatively a simple modification of the FindPCIAccess.cmake file that
Edward sent out could also work.

Sorry for the late feedback on a Sunday.

Regards,
Andres

On 2/5/2017 10:34 AM, Tom St Denis wrote:
> Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
> ---
>  CMakeLists.txt      | 4 +++-
>  src/lib/query_drm.c | 4 ++--
>  2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index bef94fdba788..d2f393f0fa9b 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -25,6 +25,8 @@ include_directories(${CURSES_INCLUDE_DIRS})
>  find_package(PCIAccess REQUIRED)
>  include_directories(${PCIACCESS_INCLUDE_DIR})
>
> +pkg_check_modules(DRM REQUIRED libdrm)
> +
>  set(REQUIRED_EXTERNAL_LIBS
>    ${CURSES_LIBRARIES}
>    ${PCIACCESS_LIBRARIES}
> @@ -34,7 +36,7 @@ set(REQUIRED_EXTERNAL_LIBS
>  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
>
>  # CFLAGS += -Wall -W -O2 -g3 -Isrc/ -DPIC -fPIC
> -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -O2 -g3")
> +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DRM_CFLAGS} -Wall -W -O2 -g3")
>
>  add_subdirectory(src)
>  add_subdirectory(doc)
> 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
>


More information about the amd-gfx mailing list