[Beignet] [PATCH 2/2] CMake: use CHECK_LIBRARY_EXISTS to check the function instead of version.

Song, Ruiling ruiling.song at intel.com
Wed Jun 22 05:19:37 UTC 2016


The patchset LGTM

Thanks!
Ruiling
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Yang Rong
> Sent: Wednesday, June 15, 2016 4:14 PM
> To: beignet at lists.freedesktop.org
> Cc: Yang, Rong R <rong.r.yang at intel.com>
> Subject: [Beignet] [PATCH 2/2] CMake: use CHECK_LIBRARY_EXISTS to check the
> function instead of version.
> 
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
>  CMakeLists.txt     | 25 ++++++++++++++-----------
>  src/CMakeLists.txt | 40 ++++++++++++++++++++--------------------
>  2 files changed, 34 insertions(+), 31 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 7f43fa2..fae3e88 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -129,27 +129,30 @@ ELSE(DRM_FOUND)
>    MESSAGE(STATUS "Looking for DRM - not found")
>  ENDIF(DRM_FOUND)
> 
> +include(CheckLibraryExists)
>  # DRM Intel
>  pkg_check_modules(DRM_INTEL libdrm_intel>=2.4.52)
>  IF(DRM_INTEL_FOUND)
>    INCLUDE_DIRECTORIES(${DRM_INTEL_INCLUDE_DIRS})
>    MESSAGE(STATUS "Looking for DRM Intel - found at ${DRM_INTEL_PREFIX}
> ${DRM_INTEL_VERSION}")
> -  #userptr support starts from 2.4.57, but 2.4.58 is the actual stable release
> -  IF(DRM_INTEL_VERSION VERSION_GREATER 2.4.57)
> +  CHECK_LIBRARY_EXISTS(drm_intel "drm_intel_bo_alloc_userptr" ""
> HAVE_DRM_INTEL_USERPTR)
> +  IF(HAVE_DRM_INTEL_USERPTR)
>      MESSAGE(STATUS "Enable userptr support")
> -    SET(DRM_INTEL_USERPTR "enable")
> -  ELSE(DRM_INTEL_VERSION VERSION_GREATER 2.4.57)
> +  ELSE(HAVE_DRM_INTEL_USERPTR)
>      MESSAGE(STATUS "Disable userptr support")
> -  ENDIF(DRM_INTEL_VERSION VERSION_GREATER 2.4.57)
> -  IF(DRM_INTEL_VERSION VERSION_GREATER 2.4.59)
> +  ENDIF(HAVE_DRM_INTEL_USERPTR)
> +  CHECK_LIBRARY_EXISTS(drm_intel "drm_intel_get_eu_total" ""
> HAVE_DRM_INTEL_EU_TOTAL)
> +  IF(HAVE_DRM_INTEL_EU_TOTAL)
>      MESSAGE(STATUS "Enable EU total query support")
> -    SET(DRM_INTEL_EU_TOTAL "enable")
> -    MESSAGE(STATUS "Enable subslice total query support")
> -    SET(DRM_INTEL_SUBSLICE_TOTAL "enable")
> -  ELSE(DRM_INTEL_VERSION VERSION_GREATER 2.4.59)
> +  ELSE(HAVE_DRM_INTEL_EU_TOTAL)
>      MESSAGE(STATUS "Disable EU total query support")
> +  ENDIF(HAVE_DRM_INTEL_EU_TOTAL)
> +  CHECK_LIBRARY_EXISTS(drm_intel "drm_intel_get_subslice_total" ""
> HAVE_DRM_INTEL_SUBSLICE_TOTAL)
> +  IF(HAVE_DRM_INTEL_SUBSLICE_TOTAL)
> +    MESSAGE(STATUS "Enable subslice total query support")
> +  ELSE(HAVE_DRM_INTEL_SUBSLICE_TOTAL)
>      MESSAGE(STATUS "Disable subslice total query support")
> -  ENDIF(DRM_INTEL_VERSION VERSION_GREATER 2.4.59)
> +  ENDIF(HAVE_DRM_INTEL_SUBSLICE_TOTAL)
>  ELSE(DRM_INTEL_FOUND)
>    MESSAGE(FATAL_ERROR "Looking for DRM Intel (>= 2.4.52) - not found")
>  ENDIF(DRM_INTEL_FOUND)
> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> index 96a470c..98f8423 100644
> --- a/src/CMakeLists.txt
> +++ b/src/CMakeLists.txt
> @@ -109,34 +109,34 @@ if (CMRT_FOUND)
>  endif (CMRT_FOUND)
> 
>  if (EGL_FOUND AND MESA_SOURCE_FOUND)
> -set (OPENCL_SRC ${OPENCL_SRC} cl_mem_gl.c cl_gl_api.c
> x11/mesa_egl_extension.c x11/mesa_egl_res_share.c
> intel/intel_dri_resource_sharing.c)
> -SET(CMAKE_CXX_FLAGS "-DHAS_EGL ${CMAKE_CXX_FLAGS}")
> -SET(CMAKE_C_FLAGS "-DHAS_EGL ${CMAKE_C_FLAGS}")
> -SET(OPTIONAL_EGL_LIBRARY "${EGL_LIBRARY}")
> +  set (OPENCL_SRC ${OPENCL_SRC} cl_mem_gl.c cl_gl_api.c
> x11/mesa_egl_extension.c x11/mesa_egl_res_share.c
> intel/intel_dri_resource_sharing.c)
> +  SET(CMAKE_CXX_FLAGS "-DHAS_EGL ${CMAKE_CXX_FLAGS}")
> +  SET(CMAKE_C_FLAGS "-DHAS_EGL ${CMAKE_C_FLAGS}")
> +  SET(OPTIONAL_EGL_LIBRARY "${EGL_LIBRARY}")
>  else(EGL_FOUND AND MESA_SOURCE_FOUND)
> -SET(OPTIONAL_EGL_LIBRARY "")
> +  SET(OPTIONAL_EGL_LIBRARY "")
>  endif (EGL_FOUND AND MESA_SOURCE_FOUND)
> 
>  if (OCLIcd_FOUND)
> -set (OPENCL_SRC ${OPENCL_SRC} cl_khr_icd.c)
> -SET(CMAKE_CXX_FLAGS "-DHAS_OCLIcd ${CMAKE_CXX_FLAGS}")
> -SET(CMAKE_C_FLAGS "-DHAS_OCLIcd ${CMAKE_C_FLAGS}")
> +  set (OPENCL_SRC ${OPENCL_SRC} cl_khr_icd.c)
> +  SET(CMAKE_CXX_FLAGS "-DHAS_OCLIcd ${CMAKE_CXX_FLAGS}")
> +  SET(CMAKE_C_FLAGS "-DHAS_OCLIcd ${CMAKE_C_FLAGS}")
>  endif (OCLIcd_FOUND)
> 
> -if (DRM_INTEL_USERPTR)
> -SET(CMAKE_CXX_FLAGS "-DHAS_USERPTR ${CMAKE_CXX_FLAGS}")
> -SET(CMAKE_C_FLAGS "-DHAS_USERPTR ${CMAKE_C_FLAGS}")
> -endif (DRM_INTEL_USERPTR)
> +if (HAVE_DRM_INTEL_USERPTR)
> +  SET(CMAKE_CXX_FLAGS "-DHAS_USERPTR ${CMAKE_CXX_FLAGS}")
> +  SET(CMAKE_C_FLAGS "-DHAS_USERPTR ${CMAKE_C_FLAGS}")
> +endif (HAVE_DRM_INTEL_USERPTR)
> 
> -if (DRM_INTEL_EU_TOTAL)
> -SET(CMAKE_CXX_FLAGS "-DHAS_EU_TOTAL ${CMAKE_CXX_FLAGS}")
> -SET(CMAKE_C_FLAGS "-DHAS_EU_TOTAL ${CMAKE_C_FLAGS}")
> -endif (DRM_INTEL_EU_TOTAL)
> +if (HAVE_DRM_INTEL_EU_TOTAL)
> +  SET(CMAKE_CXX_FLAGS "-DHAS_EU_TOTAL ${CMAKE_CXX_FLAGS}")
> +  SET(CMAKE_C_FLAGS "-DHAS_EU_TOTAL ${CMAKE_C_FLAGS}")
> +endif (HAVE_DRM_INTEL_EU_TOTAL)
> 
> -if (DRM_INTEL_SUBSLICE_TOTAL)
> -SET(CMAKE_CXX_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_CXX_FLAGS}")
> -SET(CMAKE_C_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_C_FLAGS}")
> -endif (DRM_INTEL_SUBSLICE_TOTAL)
> +if (HAVE_DRM_INTEL_SUBSLICE_TOTAL)
> +  SET(CMAKE_CXX_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_CXX_FLAGS}")
> +  SET(CMAKE_C_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_C_FLAGS}")
> +endif (HAVE_DRM_INTEL_SUBSLICE_TOTAL)
> 
>  set(GIT_SHA1 "git_sha1.h")
>  add_custom_target(${GIT_SHA1} ALL
> --
> 2.1.4
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list