[Beignet] [PATCH] Use pkg-config to check modules

Daniel McLellan daniel.mclellan at gmail.com
Wed Apr 9 07:45:40 PDT 2014


I cannot seem to build HEAD

CMake Error at utests/CMakeLists.txt:204 (ADD_LIBRARY):
  Cannot find source file:
    generated/builtin_acos_float.cpp
  generated/builtin_acos_float2.cpp

etc

On Tue, Apr 8, 2014 at 10:17 PM, Zhenyu Wang <zhenyuw at linux.intel.com> wrote:
> Instead of use pre-defined path for dependent modules, e.g libdrm,
> libdrm_intel, etc. Use pkg-config helper for cmake instead. This makes
> it easy to work with developer own built version of those dependences.
>
> Also remove libGL dependence for 'gbe_bin_generator' which is not required.
> libutest.so still requires libGL now but might be fixed by checking real
> GL dependence.
>
> Signed-off-by: Zhenyu Wang <zhenyuw at linux.intel.com>
> ---
>  CMake/FindDRM.cmake        | 42 -----------------------------------
>  CMake/FindDRMIntel.cmake   | 43 ------------------------------------
>  CMake/FindEGL.cmake        | 55 ----------------------------------------------
>  CMake/FindMesaSrc.cmake    | 26 ++++++++++++++++++++++
>  CMake/FindXext.cmake       | 35 -----------------------------
>  CMake/FindXfixes.cmake     | 35 -----------------------------
>  CMakeLists.txt             | 43 ++++++++++++++++++++++++------------
>  backend/src/CMakeLists.txt |  5 ++---
>  src/CMakeLists.txt         | 12 +++++-----
>  utests/CMakeLists.txt      |  3 ++-
>  10 files changed, 65 insertions(+), 234 deletions(-)
>  delete mode 100644 CMake/FindDRM.cmake
>  delete mode 100644 CMake/FindDRMIntel.cmake
>  delete mode 100644 CMake/FindEGL.cmake
>  create mode 100644 CMake/FindMesaSrc.cmake
>  delete mode 100644 CMake/FindXext.cmake
>  delete mode 100644 CMake/FindXfixes.cmake
>
> diff --git a/CMake/FindDRM.cmake b/CMake/FindDRM.cmake
> deleted file mode 100644
> index a5a4ebc..0000000
> --- a/CMake/FindDRM.cmake
> +++ /dev/null
> @@ -1,42 +0,0 @@
> -#
> -# Try to find X library and include path.
> -# Once done this will define
> -#
> -# DRM_FOUND
> -# DRM_INCLUDE_PATH
> -# DRM_LIBRARY
> -#
> -
> -FIND_PATH(DRM_INCLUDE_PATH
> -  NAMES
> -  drm.h
> -  PATHS
> -  ${CMAKE_INCLUDE_PATH}/include/libdrm/
> -  ~/include/libdrm/
> -  /usr/include/libdrm/
> -  /usr/local/include/libdrm/
> -  /sw/include/libdrm/
> -  /opt/local/include/libdrm/
> -  DOC "The directory where drm.h resides")
> -FIND_LIBRARY(DRM_LIBRARY
> -  NAMES DRM drm
> -  PATHS
> -  ${CMAKE_LIBRARY_PATH}/lib/
> -  ~/lib/
> -  /usr/lib64
> -  /usr/lib
> -  /usr/local/lib64
> -  /usr/local/lib
> -  /sw/lib
> -  /opt/local/lib
> -  DOC "The DRM library")
> -
> -IF(DRM_INCLUDE_PATH)
> -  INCLUDE_DIRECTORIES(${DRM_INCLUDE_PATH})
> -  SET(DRM_FOUND 1 CACHE STRING "Set to 1 if DRM is found, 0 otherwise")
> -ELSE(DRM_INCLUDE_PATH)
> -  SET(DRM_FOUND 0 CACHE STRING "Set to 1 if DRM is found, 0 otherwise")
> -ENDIF(DRM_INCLUDE_PATH)
> -
> -MARK_AS_ADVANCED(DRM_FOUND)
> -
> diff --git a/CMake/FindDRMIntel.cmake b/CMake/FindDRMIntel.cmake
> deleted file mode 100644
> index 0aab1c7..0000000
> --- a/CMake/FindDRMIntel.cmake
> +++ /dev/null
> @@ -1,43 +0,0 @@
> -#
> -# Try to find X library and include path.
> -# Once done this will define
> -#
> -# DRM_INTEL_FOUND
> -# DRM_INTEL_INCLUDE_PATH
> -#
> -
> -FIND_PATH(DRM_INTEL_INCLUDE_PATH
> -  NAMES
> -  intel_bufmgr.h
> -  PATHS
> -  ${CMAKE_INCLUDE_PATH}/include/libdrm/
> -  ~/include/libdrm/
> -  /usr/include/libdrm/
> -  /usr/local/include/libdrm/
> -  /sw/include/libdrm/
> -  /opt/local/include/libdrm/
> -  DOC "The directory where intel_bufmgr.h resides")
> -
> -FIND_LIBRARY(DRM_INTEL_LIBRARY
> -  NAMES DRM_INTEL drm_intel
> -  PATHS
> -  ${CMAKE_LIBRARY_PATH}/lib/
> -  ~/lib/
> -  /usr/lib64
> -  /usr/lib
> -  /usr/local/lib64
> -  /usr/local/lib
> -  /sw/lib
> -  /opt/local/lib
> -  /usr/lib/i386-linux-gnu/
> -  DOC "The DRM_INTEL library")
> -
> -IF(DRM_INTEL_INCLUDE_PATH)
> -  INCLUDE_DIRECTORIES(${DRM_INTEL_INCLUDE_PATH})
> -  SET(DRM_INTEL_FOUND 1 CACHE STRING "Set to 1 if DRM_INTEL is found, 0 otherwise")
> -ELSE(DRM_INTEL_INCLUDE_PATH)
> -  SET(DRM_INTEL_FOUND 0 CACHE STRING "Set to 1 if DRM_INTEL is found, 0 otherwise")
> -ENDIF(DRM_INTEL_INCLUDE_PATH)
> -
> -MARK_AS_ADVANCED(DRM_INTEL_FOUND)
> -
> diff --git a/CMake/FindEGL.cmake b/CMake/FindEGL.cmake
> deleted file mode 100644
> index 597b4a5..0000000
> --- a/CMake/FindEGL.cmake
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -#
> -# Try to find EGL library and include path.
> -# Once done this will define
> -#
> -# EGL_FOUND
> -# EGL_INCLUDE_PATH
> -# EGL_LIBRARY
> -#
> -
> -FIND_PATH(EGL_INCLUDE_PATH EGL/egl.h
> -  ~/include/
> -  /usr/include/
> -  /usr/local/include/
> -  /sw/include/
> -  /opt/local/include/
> -  DOC "The directory where gen/program.h resides")
> -FIND_LIBRARY(EGL_LIBRARY
> -  NAMES EGL egl
> -  PATHS
> -  ~/lib/
> -  /usr/lib64
> -  /usr/lib
> -  /usr/local/lib64
> -  /usr/local/lib
> -  /sw/lib
> -  /opt/local/lib
> -  DOC "The EGL library")
> -
> -IF(EGL_INCLUDE_PATH)
> -  INCLUDE_DIRECTORIES(${EGL_INCLUDE_PATH})
> -  SET(EGL_FOUND 1 CACHE STRING "Set to 1 if EGL is found, 0 otherwise")
> -ELSE(EGL_INCLUDE_PATH)
> -  SET(EGL_FOUND 0 CACHE STRING "Set to 1 if EGL is found, 0 otherwise")
> -ENDIF(EGL_INCLUDE_PATH)
> -
> -# Find mesa source code.
> -FIND_PATH(MESA_SOURCE_PREFIX src/mesa/main/texobj.c
> -  $ENV{MESA_SOURCE_DIR}
> -  ${MAKE_CURRENT_SOURCE_DIR}/../mesa
> -  ~/mesa
> -  DOC "The mesa source directory which is needed for cl_khr_gl_sharing.")
> -
> -IF(MESA_SOURCE_PREFIX)
> -SET(MESA_SOURCE_INCLUDES ${MESA_SOURCE_PREFIX}/src/mesa
> -                         ${MESA_SOURCE_PREFIX}/include
> -                         ${MESA_SOURCE_PREFIX}/src/mapi
> -                         ${MESA_SOURCE_PREFIX}/src/mesa/drivers/dri/i965/
> -                         ${MESA_SOURCE_PREFIX}/src/mesa/drivers/dri/intel/
> -                         ${MESA_SOURCE_PREFIX}/src/mesa/drivers/dri/common/)
> -SET(MESA_SOURCE_FOUND 1 CACHE STRING "Set to 1 if mesa source code is found, 0 otherwise")
> -ELSE(MESA_SOURCE_PREFIX)
> -SET(MESA_SOURCE_FOUND 0 CACHE STRING "Set to 1 if mesa source code is found, 0 otherwise")
> -ENDIF(MESA_SOURCE_PREFIX)
> -
> -MARK_AS_ADVANCED(EGL_FOUND)
> diff --git a/CMake/FindMesaSrc.cmake b/CMake/FindMesaSrc.cmake
> new file mode 100644
> index 0000000..c1d4fc6
> --- /dev/null
> +++ b/CMake/FindMesaSrc.cmake
> @@ -0,0 +1,26 @@
> +#
> +# Try to find mesa source code
> +# Once done this will define
> +#
> +# MESA_SOURCE_FOUND
> +# MESA_SOURCE_INCLUDES
> +#
> +
> +# Find mesa source code.
> +FIND_PATH(MESA_SOURCE_PREFIX src/mesa/main/texobj.c
> +  $ENV{MESA_SOURCE_DIR}
> +  ${MAKE_CURRENT_SOURCE_DIR}/../mesa
> +  ~/mesa
> +  DOC "The mesa source directory which is needed for cl_khr_gl_sharing.")
> +
> +IF(MESA_SOURCE_PREFIX)
> +SET(MESA_SOURCE_INCLUDES ${MESA_SOURCE_PREFIX}/src/mesa
> +                         ${MESA_SOURCE_PREFIX}/include
> +                         ${MESA_SOURCE_PREFIX}/src/mapi
> +                         ${MESA_SOURCE_PREFIX}/src/mesa/drivers/dri/i965/
> +                         ${MESA_SOURCE_PREFIX}/src/mesa/drivers/dri/intel/
> +                         ${MESA_SOURCE_PREFIX}/src/mesa/drivers/dri/common/)
> +SET(MESA_SOURCE_FOUND 1 CACHE STRING "Set to 1 if mesa source code is found, 0 otherwise")
> +ELSE(MESA_SOURCE_PREFIX)
> +SET(MESA_SOURCE_FOUND 0 CACHE STRING "Set to 1 if mesa source code is found, 0 otherwise")
> +ENDIF(MESA_SOURCE_PREFIX)
> diff --git a/CMake/FindXext.cmake b/CMake/FindXext.cmake
> deleted file mode 100644
> index 5bbd719..0000000
> --- a/CMake/FindXext.cmake
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -#
> -# Try to find Xext library path.
> -# Once done this will define
> -#
> -# XEXT_FOUND
> -# XEXT_LIBRARY
> -#
> -
> -FIND_PATH(XEXT_INCLUDE_PATH X11/extensions/Xext.h
> -  /usr/include
> -  /usr/local/include
> -  /sw/include
> -  /opt/local/include
> -  DOC "The directory where Xext.h resides")
> -
> -FIND_LIBRARY(XEXT_LIBRARY
> -  NAMES XEXT Xext
> -  PATHS
> -  /usr/lib64
> -  /usr/lib
> -  /usr/local/lib64
> -  /usr/local/lib
> -  /sw/lib
> -  /opt/local/lib
> -  DOC "The XEXT library")
> -
> -IF(XEXT_INCLUDE_PATH)
> -  INCLUDE_DIRECTORIES(${XEXT_INCLUDE_PATH})
> -  SET(XEXT_FOUND 1 CACHE STRING "Set to 1 if XEXT is found, 0 otherwise")
> -ELSE(XEXT_INCLUDE_PATH)
> -  SET(XEXT_FOUND 0 CACHE STRING "Set to 1 if XEXT is found, 0 otherwise")
> -ENDIF(XEXT_INCLUDE_PATH)
> -
> -MARK_AS_ADVANCED(XEXT_FOUND)
> -
> diff --git a/CMake/FindXfixes.cmake b/CMake/FindXfixes.cmake
> deleted file mode 100644
> index 47259e1..0000000
> --- a/CMake/FindXfixes.cmake
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -#
> -# Try to find Xfixes library path.
> -# Once done this will define
> -#
> -# XFIXES_FOUND
> -# XFIXES_LIBRARY
> -#
> -
> -FIND_PATH(XFIXES_INCLUDE_PATH X11/extensions/Xfixes.h
> -  /usr/include
> -  /usr/local/include
> -  /sw/include
> -  /opt/local/include
> -  DOC "The directory where Xfixes.h resides")
> -
> -FIND_LIBRARY(XFIXES_LIBRARY
> -  NAMES XFIXES Xfixes
> -  PATHS
> -  /usr/lib64
> -  /usr/lib
> -  /usr/local/lib64
> -  /usr/local/lib
> -  /sw/lib
> -  /opt/local/lib
> -  DOC "The XFIXES library")
> -
> -IF(XFIXES_INCLUDE_PATH)
> -  INCLUDE_DIRECTORIES(${XFIXES_INCLUDE_PATH})
> -  SET(XFIXES_FOUND 1 CACHE STRING "Set to 1 if XFIXES is found, 0 otherwise")
> -ELSE(XFIXES_INCLUDE_PATH)
> -  SET(XFIXES_FOUND 0 CACHE STRING "Set to 1 if XFIXES is found, 0 otherwise")
> -ENDIF(XFIXES_INCLUDE_PATH)
> -
> -MARK_AS_ADVANCED(XFIXES_FOUND)
> -
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 4ed27b5..a4254f8 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -21,6 +21,8 @@ configure_file (
>
>  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
>
> +INCLUDE (FindPkgConfig)
> +
>  SET(CMAKE_VERBOSE_MAKEFILE "false")
>  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/")
>  if (NOT LIB_INSTALL_DIR)
> @@ -80,44 +82,57 @@ ELSE(X11_FOUND)
>  ENDIF(X11_FOUND)
>
>  # DRM
> -Find_Package(DRM)
> +pkg_check_modules(DRM REQUIRED libdrm)
>  IF(DRM_FOUND)
> -  MESSAGE(STATUS "Looking for DRM - found")
> +  MESSAGE(STATUS "Looking for DRM - found at ${DRM_PREFIX}")
> +  INCLUDE_DIRECTORIES(${DRM_INCLUDE_DIRS})
>  ELSE(DRM_FOUND)
>    MESSAGE(STATUS "Looking for DRM - not found")
>  ENDIF(DRM_FOUND)
>
> -# OpenGL
> -Find_Package(OpenGL)
> -# Threads
> -Find_Package(Threads)
>  # DRM Intel
> -Find_Package(DRMIntel)
> +pkg_check_modules(DRM_INTEL REQUIRED libdrm_intel)
>  IF(DRM_INTEL_FOUND)
> -  MESSAGE(STATUS "Looking for DRM Intel - found")
> +  INCLUDE_DIRECTORIES(${DRM_INTEL_INCLUDE_DIRS})
> +  MESSAGE(STATUS "Looking for DRM Intel - found at ${DRM_INTEL_PREFIX}")
>  ELSE(DRM_INTEL_FOUND)
>    MESSAGE(STATUS "Looking for DRM Intel - not found")
>  ENDIF(DRM_INTEL_FOUND)
>
> +# OpenGL (not use cmake helper)
> +pkg_check_modules(OPENGL REQUIRED gl)
> +IF(OPENGL_FOUND)
> +  INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIRS})
> +  MESSAGE(STATUS "Looking for OpenGL - found at ${OPENGL_PREFIX}")
> +ELSE(OPENGL_FOUND)
> +  MESSAGE(STATUS "Looking for OpenGL - not found")
> +ENDIF(OPENGL_FOUND)
> +
> +
> +# Threads
> +Find_Package(Threads)
> +
>  # Xext
> -Find_Package(Xext)
> +pkg_check_modules(XEXT REQUIRED xext)
>  IF(XEXT_FOUND)
> -  MESSAGE(STATUS "Looking for Xext - found")
> +  INCLUDE_DIRECTORIES(${XEXT_INCLUDE_DIRS})
> +  MESSAGE(STATUS "Looking for Xext - found at ${XEXT_PREFIX}")
>  ELSE(XEXT_FOUND)
>    MESSAGE(STATUS "Looking for Xext - not found")
>  ENDIF(XEXT_FOUND)
>
>  # Xfixes
> -Find_Package(Xfixes)
> +pkg_check_modules(XFIXES REQUIRED xfixes)
>  IF(XFIXES_FOUND)
> -  MESSAGE(STATUS "Looking for Xfixes - found")
> +  INCLUDE_DIRECTORIES(${XFIXES_INCLUDE_DIRS})
> +  MESSAGE(STATUS "Looking for Xfixes - found at ${XFIXES_PREFIX}")
>  ELSE(XFIXES_FOUND)
>    MESSAGE(STATUS "Looking for Xfixes - not found")
>  ENDIF(XFIXES_FOUND)
>
> -Find_Package(EGL)
> +pkg_check_modules(EGL egl)
>  IF(EGL_FOUND)
> -  MESSAGE(STATUS "Looking for EGL - found")
> +  MESSAGE(STATUS "Looking for EGL - found at ${EGL_PREFIX}")
>  ELSE(EGL_FOUND)
>    MESSAGE(STATUS "Looking for EGL - not found")
>  ENDIF(EGL_FOUND)
> diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt
> index 6e37d95..12d337b 100644
> --- a/backend/src/CMakeLists.txt
> +++ b/backend/src/CMakeLists.txt
> @@ -179,9 +179,8 @@ ll_add_library (${pcm_lib} pcm_sources)
>  ADD_DEPENDENCIES (gbe pch_object ${pcm_lib})
>  target_link_libraries(
>                        gbe
> -                      ${DRM_INTEL_LIBRARY}
> -                      ${DRM_LIBRARY}
> -                      ${OPENGL_LIBRARIES}
> +                      ${DRM_INTEL_LIBRARIES}
> +                      ${DRM_LIBRARIES}
>                        ${CLANG_LIBRARIES}
>                        ${LLVM_MODULE_LIBS}
>                        ${LLVM_SYSTEM_LIBS}
> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> index d690d9a..8164a44 100644
> --- a/src/CMakeLists.txt
> +++ b/src/CMakeLists.txt
> @@ -1,6 +1,6 @@
>  include_directories(${CMAKE_CURRENT_SOURCE_DIR}
> -                    ${DRM_INCLUDE_PATH}
> -                    ${DRM_INCLUDE_PATH}/../
> +                    ${DRM_INCLUDE_DIRS}
> +                    ${DRM_INCLUDE_DIRS}/../
>                      ${CMAKE_CURRENT_SOURCE_DIR}/../backend/src/backend/
>                      ${CMAKE_CURRENT_SOURCE_DIR}/../include
>                      ${MESA_SOURCE_INCLUDES})
> @@ -75,10 +75,10 @@ target_link_libraries(
>                        cl
>                        gbe
>                        ${XLIB_LIBRARY}
> -                      ${XEXT_LIBRARY}
> -                      ${XFIXES_LIBRARY}
> -                      ${DRM_INTEL_LIBRARY}
> -                      ${DRM_LIBRARY}
> +                      ${XEXT_LIBRARIES}
> +                      ${XFIXES_LIBRARIES}
> +                      ${DRM_INTEL_LIBRARIES}
> +                      ${DRM_LIBRARIES}
>                        ${OPENGL_LIBRARIES}
>                        ${OPTIONAL_EGL_LIBRARY})
>  install (TARGETS cl LIBRARY DESTINATION ${LIB_INSTALL_DIR}/beignet)
> diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
> index 9ca9c8b..4fcc5dd 100644
> --- a/utests/CMakeLists.txt
> +++ b/utests/CMakeLists.txt
> @@ -18,7 +18,8 @@ configure_file (
>    "setenv.sh"
>    )
>
> -link_directories (${LLVM_LIBRARY_DIR})
> +#XXX only need GL if required
> +link_directories (${LLVM_LIBRARY_DIR} ${OPENGL_LIBDIR})
>  set (utests_sources
>    utest_error.c
>    compiler_basic_arithmetic.cpp
> --
> 1.9.1
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list