CMakeLists: Use pkgconfig more effectively with DRM_DIR
Instead of hard-coding lib64 and other include locations, just prepend the DRM_DIR to the beginning of the CMake prefix path. Then let pkgconfig find the package, the same way that it would if DRM_DIR wasn't set. DRM_DIR takes precedence, but the default paths will be used if DRM_DIR isn't set, or doesn't point to where libdrm is housed Note that /lib and /lib/$ARCH aren't required for DRM_DIR, just the path to the root folder for the package (e.g. /opt/amdgpu instead of /opt/amdgpu/lib or /opt/amdgpu/lib64 or /opt/amdgpu/lib/x86_64-linux-gnu etc) Change-Id: I56767db28476d14e3fa77be1089c3904e2a32450
Этот коммит содержится в:
+5
-12
@@ -166,20 +166,13 @@ message(STATUS "NUMA:" ${NUMA})
|
||||
|
||||
## If environment variable DRM_DIR is set, the script
|
||||
## will pick up the corresponding libraries from that path.
|
||||
if( DEFINED ENV{DRM_DIR} )
|
||||
#assume header files and libraries are under the same path
|
||||
set ( DRM_DIR $ENV{DRM_DIR} )
|
||||
set ( DRM_INCLUDE_DIRS ${DRM_DIR}/include )
|
||||
link_directories(${DRM_DIR}/lib64)
|
||||
set ( DRM_LIBRARIES drm )
|
||||
set ( DRM_AMDGPU_LIBRARIES drm_amdgpu )
|
||||
else()
|
||||
list (PREPEND CMAKE_PREFIX_PATH "${DRM_DIR}")
|
||||
|
||||
# The module name passed to pkg_check_modules() is determined by the
|
||||
# name of file *.pc
|
||||
pkg_check_modules(DRM REQUIRED libdrm)
|
||||
pkg_check_modules(DRM_AMDGPU REQUIRED libdrm_amdgpu)
|
||||
include_directories(${DRM_AMDGPU_INCLUDE_DIRS})
|
||||
endif()
|
||||
pkg_check_modules(DRM REQUIRED libdrm)
|
||||
pkg_check_modules(DRM_AMDGPU REQUIRED libdrm_amdgpu)
|
||||
include_directories(${DRM_AMDGPU_INCLUDE_DIRS})
|
||||
include_directories(${DRM_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries ( ${HSAKMT_TARGET}
|
||||
|
||||
@@ -92,20 +92,12 @@ set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core")
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
if( DEFINED ENV{DRM_DIR} )
|
||||
#assume header files and libraries are under the same path
|
||||
set ( DRM_DIR $ENV{DRM_DIR} )
|
||||
set ( DRM_INCLUDE_DIRS ${DRM_DIR}/include )
|
||||
link_directories(${DRM_DIR}/lib64)
|
||||
set ( DRM_LIBRARIES drm )
|
||||
set ( DRM_AMDGPU_LIBRARIES drm_amdgpu )
|
||||
else()
|
||||
list (PREPEND CMAKE_PREFIX_PATH "${DRM_DIR}")
|
||||
# The module name passed to pkg_check_modules() is determined by the
|
||||
# name of file *.pc
|
||||
pkg_check_modules(DRM REQUIRED libdrm)
|
||||
pkg_check_modules(DRM_AMDGPU REQUIRED libdrm_amdgpu)
|
||||
include_directories(${DRM_AMDGPU_INCLUDE_DIRS})
|
||||
endif()
|
||||
pkg_check_modules(DRM REQUIRED libdrm)
|
||||
pkg_check_modules(DRM_AMDGPU REQUIRED libdrm_amdgpu)
|
||||
include_directories(${DRM_AMDGPU_INCLUDE_DIRS})
|
||||
|
||||
if( DEFINED ENV{LIBHSAKMT_PATH} )
|
||||
set ( LIBHSAKMT_PATH $ENV{LIBHSAKMT_PATH} )
|
||||
|
||||
Ссылка в новой задаче
Block a user