cmake/sdlchecks.cmake
changeset 11175 cbc6a8a5b701
parent 11139 4c165b1a0596
child 11207 4ed2e42b7497
     1.1 --- a/cmake/sdlchecks.cmake	Mon Jul 31 13:49:22 2017 -0400
     1.2 +++ b/cmake/sdlchecks.cmake	Wed Aug 02 10:22:48 2017 -0700
     1.3 @@ -1149,3 +1149,46 @@
     1.4      endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
     1.5    endif(VIDEO_RPI)
     1.6  endmacro(CheckRPI)
     1.7 +
     1.8 +# Requires:
     1.9 +# - EGL
    1.10 +# - PkgCheckModules
    1.11 +# Optional:
    1.12 +# - KMSDRM_SHARED opt
    1.13 +# - HAVE_DLOPEN opt
    1.14 +macro(CheckKMSDRM)
    1.15 +  if(VIDEO_KMSDRM)
    1.16 +    pkg_check_modules(KMSDRM libdrm gbm egl)
    1.17 +    if(KMSDRM_FOUND)
    1.18 +      link_directories(
    1.19 +        ${KMSDRM_LIBRARY_DIRS}
    1.20 +      )
    1.21 +      include_directories(
    1.22 +        ${KMSDRM_INCLUDE_DIRS}
    1.23 +      )
    1.24 +      set(HAVE_VIDEO_KMSDRM TRUE)
    1.25 +      set(HAVE_SDL_VIDEO TRUE)
    1.26 +
    1.27 +      file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c)
    1.28 +      set(SOURCE_FILES ${SOURCE_FILES} ${KMSDRM_SOURCES})
    1.29 +
    1.30 +      list(APPEND EXTRA_CFLAGS ${KMSDRM_CLFLAGS})
    1.31 +
    1.32 +      set(SDL_VIDEO_DRIVER_KMSDRM 1)
    1.33 +
    1.34 +      if(KMSDRM_SHARED)
    1.35 +        if(NOT HAVE_DLOPEN)
    1.36 +          message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
    1.37 +        else()
    1.38 +          FindLibraryAndSONAME(drm)
    1.39 +          FindLibraryAndSONAME(gbm)
    1.40 +          set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
    1.41 +          set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
    1.42 +          set(HAVE_KMSDRM_SHARED TRUE)
    1.43 +        endif()
    1.44 +      else()
    1.45 +        set(EXTRA_LIBS ${KMSDRM_LIBRARIES} ${EXTRA_LIBS})
    1.46 +      endif()
    1.47 +    endif()
    1.48 +  endif()
    1.49 +endmacro()