From aa9b26530219dc3fd060536ad0a5142dadb0ebda Mon Sep 17 00:00:00 2001 From: Sajina PK Date: Mon, 21 Jul 2025 14:07:00 -0400 Subject: [PATCH] Manually search for rocdecode and rocjpeg libraries in cmake (#294) * Manually search for rocdecode ad rocjpeg libraries * Update examples/jpegdecode/CMakeLists.txt Fix typo. Co-authored-by: David Galiffi --------- Co-authored-by: David Galiffi [ROCm/rocprofiler-systems commit: f4e9846e1ce6654cd1e3b7ce5518aa469781153f] --- .../examples/jpegdecode/CMakeLists.txt | 48 +++++++++++++++++-- .../examples/videodecode/CMakeLists.txt | 44 ++++++++++++++++- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/projects/rocprofiler-systems/examples/jpegdecode/CMakeLists.txt b/projects/rocprofiler-systems/examples/jpegdecode/CMakeLists.txt index e92c8f5e34..bc1eed1d55 100644 --- a/projects/rocprofiler-systems/examples/jpegdecode/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/jpegdecode/CMakeLists.txt @@ -60,7 +60,47 @@ if(ROCPROFSYS_DISABLE_EXAMPLES) endif() endif() -find_package(rocjpeg QUIET) +# find rocJPEG - library and headers +find_path( + rocjpeg_ROOT_DIR + NAMES include/rocjpeg/rocjpeg.h + HINTS ${ROCmVersion_DIR} ${ROCM_PATH} + PATHS ${ROCmVersion_DIR} ${ROCM_PATH} +) + +mark_as_advanced(rocjpeg_ROOT_DIR) + +find_path( + rocjpeg_INCLUDE_DIR + NAMES rocjpeg/rocjpeg.h + HINTS ${rocjpeg_ROOT_DIR} + PATHS ${rocjpeg_ROOT_DIR} + PATH_SUFFIXES include +) + +find_library( + rocjpeg_LIBRARY + NAMES rocjpeg + HINTS ${rocjpeg_ROOT_DIR} + PATHS ${rocjpeg_ROOT_DIR} + PATH_SUFFIXES lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + rocjpeg + FOUND_VAR rocjpeg_FOUND + REQUIRED_VARS rocjpeg_INCLUDE_DIR rocjpeg_LIBRARY +) + +if(rocjpeg_FOUND) + if(NOT TARGET rocjpeg::rocjpeg) + add_library(rocjpeg::rocjpeg INTERFACE IMPORTED) + target_link_libraries(rocjpeg::rocjpeg INTERFACE ${rocjpeg_LIBRARY}) + target_include_directories(rocjpeg::rocjpeg INTERFACE ${rocjpeg_INCLUDE_DIR}) + endif() +endif() + find_package(rocprofiler-register QUIET) # Copy image files to build directory @@ -107,7 +147,7 @@ if(HIP_FOUND AND rocjpeg_FOUND AND Threads_FOUND AND rocprofiler-register_FOUND) set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocprofiler-register::rocprofiler-register) # rocJPEG - message(STATUS "RocJPEG library found: ${rocjpeg_LIBRARIES}") + message(STATUS "RocJPEG library found: ${rocjpeg_LIBRARY}") include_directories(${rocjpeg_INCLUDE_DIR}) set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocjpeg::rocjpeg) list(APPEND SOURCES ${PROJECT_SOURCE_DIR} jpegdecodeperf.cpp) @@ -136,11 +176,11 @@ else() message(WARNING "-- ERROR!: rocJPEG Not Found! - please install rocJPEG!") endif() if(NOT Threads_FOUND) - message(FATAL_ERROR "-- ERROR!: Threads Not Found! - please insatll Threads!") + message(WARNING "-- ERROR!: Threads Not Found! - please install Threads!") endif() if(NOT rocprofiler-register_FOUND) message( - FATAL_ERROR + WARNING "-- ERROR!: rocprofiler-register Not Found! - please install rocprofiler-register!" ) endif() diff --git a/projects/rocprofiler-systems/examples/videodecode/CMakeLists.txt b/projects/rocprofiler-systems/examples/videodecode/CMakeLists.txt index f8e8fcbf09..4e4a5bb5a7 100644 --- a/projects/rocprofiler-systems/examples/videodecode/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/videodecode/CMakeLists.txt @@ -54,8 +54,48 @@ function(videodecode_message _MSG_TYPE) endfunction() # Find RocDecode -find_package(rocdecode QUIET) -if(NOT rocdecode_FOUND) +find_path( + rocdecode_ROOT_DIR + NAMES include/rocdecode/rocdecode.h + HINTS ${ROCmVersion_DIR} ${ROCM_PATH} + PATHS ${ROCmVersion_DIR} ${ROCM_PATH} +) + +mark_as_advanced(rocdecode_ROOT_DIR) + +find_path( + rocdecode_INCLUDE_DIR + NAMES rocdecode/rocdecode.h + HINTS ${rocdecode_ROOT_DIR} + PATHS ${rocdecode_ROOT_DIR} + PATH_SUFFIXES include +) + +find_library( + rocdecode_LIBRARY + NAMES rocdecode + HINTS ${rocdecode_ROOT_DIR} + PATHS ${rocdecode_ROOT_DIR} + PATH_SUFFIXES lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + rocdecode + FOUND_VAR rocdecode_FOUND + REQUIRED_VARS rocdecode_INCLUDE_DIR rocdecode_LIBRARY +) + +if(rocdecode_FOUND) + if(NOT TARGET rocdecode::rocdecode) + add_library(rocdecode::rocdecode INTERFACE IMPORTED) + target_link_libraries(rocdecode::rocdecode INTERFACE ${rocdecode_LIBRARY}) + target_include_directories( + rocdecode::rocdecode + INTERFACE ${rocdecode_INCLUDE_DIR} + ) + endif() +else() videodecode_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing RocDecode...") return() endif()