Rollup of build changes needed for compat with TheRock. (#1086)

* Rollup of build changes needed for compat with TheRock.
* When built for a non-default ROCM location, the HIP headers can't be found by a few targets.
* Uses pkg_check for DRM libraries like ROCR-Runtime does (which avoids accidental fallback to system versions).
* Robust fix for nolink targets
* nolink targets essentially exist for include directories
* all nolink targets are automatically added to rocprofiler-sdk-headers with a $<BUILD_INTERFACE:...> generator expression
* Re-add previously used mechanism to find drm libs

---------

Co-authored-by: Marius Brehler <marius.brehler@amd.com>
Co-authored-by: Stella Laurenzo <stellaraccident@gmail.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Этот коммит содержится в:
Marius Brehler
2025-10-01 00:39:10 +02:00
коммит произвёл GitHub
родитель c6d44b47d4
Коммит 026a4e82a3
4 изменённых файлов: 57 добавлений и 47 удалений
+38 -25
Просмотреть файл
@@ -252,35 +252,48 @@ rocprofiler_config_nolink_target(rocprofiler-sdk-hsakmt-nolink hsakmt::hsakmt)
#
# ----------------------------------------------------------------------------------------#
find_path(
drm_INCLUDE_DIR
NAMES drm.h
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATH_SUFFIXES include/drm include/libdrm include REQUIRED)
find_package(PkgConfig)
find_path(
xf86drm_INCLUDE_DIR
NAMES xf86drm.h
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATH_SUFFIXES include/drm include/libdrm include REQUIRED)
if(PkgConfig_FOUND)
pkg_check_modules(DRM REQUIRED IMPORTED_TARGET libdrm)
pkg_check_modules(DRM_AMDGPU REQUIRED IMPORTED_TARGET libdrm_amdgpu)
find_library(
drm_LIBRARY
NAMES drm
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu REQUIRED)
target_include_directories(rocprofiler-sdk-drm SYSTEM
INTERFACE ${DRM_INCLUDE_DIRS} ${DRM_AMDGPU_INCLUDE_DIRS})
target_link_libraries(rocprofiler-sdk-drm INTERFACE PkgConfig::DRM
PkgConfig::DRM_AMDGPU)
else()
find_path(
drm_INCLUDE_DIR
NAMES drm.h
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATH_SUFFIXES include/drm include/libdrm include REQUIRED)
find_library(
drm_amdgpu_LIBRARY
NAMES drm_amdgpu
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu REQUIRED)
find_path(
xf86drm_INCLUDE_DIR
NAMES xf86drm.h
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATH_SUFFIXES include/drm include/libdrm include REQUIRED)
target_include_directories(rocprofiler-sdk-drm SYSTEM INTERFACE ${drm_INCLUDE_DIR}
${xf86drm_INCLUDE_DIR})
target_link_libraries(rocprofiler-sdk-drm INTERFACE ${drm_LIBRARY} ${drm_amdgpu_LIBRARY})
find_library(
drm_LIBRARY
NAMES drm
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu REQUIRED)
find_library(
drm_amdgpu_LIBRARY
NAMES drm_amdgpu
HINTS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${rocm_version_DIR} ${ROCM_PATH} /opt/amdgpu REQUIRED)
target_include_directories(rocprofiler-sdk-drm SYSTEM
INTERFACE ${drm_INCLUDE_DIR} ${xf86drm_INCLUDE_DIR})
target_link_libraries(rocprofiler-sdk-drm INTERFACE ${drm_LIBRARY}
${drm_amdgpu_LIBRARY})
endif()
# ----------------------------------------------------------------------------------------#
#
+7 -8
Просмотреть файл
@@ -92,21 +92,20 @@ rocprofiler_add_interface_library(rocprofiler-sdk-drm "drm (amdgpu) library" INT
# runtime library
#
rocprofiler_add_interface_library(
rocprofiler_add_nolink_interface_library(
rocprofiler-sdk-hip-nolink "rocprofiler-sdk-hip without linking to HIP library"
IMPORTED)
rocprofiler_add_interface_library(
rocprofiler_add_nolink_interface_library(
rocprofiler-sdk-hsa-runtime-nolink
"rocprofiler-sdk-hsa-runtime without linking to HSA library" IMPORTED)
rocprofiler_add_interface_library(
rocprofiler_add_nolink_interface_library(
rocprofiler-sdk-hsakmt-nolink
"rocprofiler-sdk-hsakmt without linking to HSAKMT library" IMPORTED)
rocprofiler_add_interface_library(rocprofiler-sdk-rccl-nolink
"RCCL headers without linking to RCCL library" IMPORTED)
rocprofiler_add_interface_library(
rocprofiler_add_nolink_interface_library(
rocprofiler-sdk-rccl-nolink "RCCL headers without linking to RCCL library" IMPORTED)
rocprofiler_add_nolink_interface_library(
rocprofiler-sdk-rocdecode-nolink
"ROCDECODE headers without linking to ROCDECODE library" IMPORTED)
rocprofiler_add_interface_library(
rocprofiler_add_nolink_interface_library(
rocprofiler-sdk-rocjpeg-nolink "ROCJPEG headers without linking to ROCJPEG library"
IMPORTED)
+10
Просмотреть файл
@@ -350,6 +350,16 @@ function(ROCPROFILER_ADD_INTERFACE_LIBRARY _TARGET _DESCRIPT)
endif()
endfunction()
# ----------------------------------------------------------------------------------------#
# macro to add an interface lib for nolink targets
#
function(ROCPROFILER_ADD_NOLINK_INTERFACE_LIBRARY _TARGET _DESCRIPT)
rocprofiler_add_interface_library(${_TARGET} "${_DESCRIPT}" ${ARGN})
# this is a nolink target so it's include dirs, etc. should propagate to the headers
# target
target_link_libraries(rocprofiler-sdk-headers INTERFACE $<BUILD_INTERFACE:${_TARGET}>)
endfunction()
# -----------------------------------------------------------------------
# function add_feature(<NAME> <DOCSTRING>) Add a project feature, whose activation is
# specified by the existence of the variable <NAME>, to the list of enabled/disabled
+2 -14
Просмотреть файл
@@ -60,18 +60,12 @@ add_subdirectory(ompt)
target_link_libraries(
rocprofiler-sdk-object-library
PUBLIC rocprofiler-sdk::rocprofiler-sdk-headers
rocprofiler-sdk::rocprofiler-sdk-hip-nolink
rocprofiler-sdk::rocprofiler-sdk-hsa-runtime-nolink
rocprofiler-sdk::rocprofiler-sdk-rccl-nolink
rocprofiler-sdk::rocprofiler-sdk-rocdecode-nolink
rocprofiler-sdk::rocprofiler-sdk-rocjpeg-nolink
PRIVATE rocprofiler-sdk::rocprofiler-sdk-build-flags
rocprofiler-sdk::rocprofiler-sdk-memcheck
rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-amd-comgr
rocprofiler-sdk::rocprofiler-sdk-hsa-aql
rocprofiler-sdk::rocprofiler-sdk-drm
rocprofiler-sdk::rocprofiler-sdk-hsakmt-nolink
rocprofiler-sdk::rocprofiler-sdk-dw)
target_compile_definitions(rocprofiler-sdk-object-library PRIVATE rocprofiler_EXPORTS=1)
@@ -95,12 +89,8 @@ target_sources(
shared_library.cpp)
target_link_libraries(
rocprofiler-sdk-shared-library
INTERFACE rocprofiler-sdk::rocprofiler-sdk-headers
$<BUILD_INTERFACE:rocprofiler-sdk::rocprofiler-sdk-hsa-runtime-nolink>
$<BUILD_INTERFACE:rocprofiler-sdk::rocprofiler-sdk-hip-nolink>
PRIVATE rocprofiler-sdk::rocprofiler-sdk-hsa-runtime-nolink
rocprofiler-sdk::rocprofiler-sdk-hip-nolink
rocprofiler-sdk::rocprofiler-sdk-build-flags
PUBLIC rocprofiler-sdk::rocprofiler-sdk-headers
PRIVATE rocprofiler-sdk::rocprofiler-sdk-build-flags
rocprofiler-sdk::rocprofiler-sdk-memcheck
rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-cxx-filesystem
@@ -140,8 +130,6 @@ target_sources(rocprofiler-sdk-static-library
target_link_libraries(
rocprofiler-sdk-static-library
PUBLIC rocprofiler-sdk::rocprofiler-sdk-headers
rocprofiler-sdk::rocprofiler-sdk-hsa-runtime-nolink
rocprofiler-sdk::rocprofiler-sdk-hip-nolink
$<BUILD_INTERFACE:rocprofiler-sdk::rocprofiler-sdk-dw>
PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-object-library)