Files
TheRock/rocm-systems/projects/rocprofiler-systems/examples/jpegdecode/CMakeLists.txt
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

175 lines
5.4 KiB
CMake

# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
# Set AMD Clang as default compiler for standalone builds
if(NOT DEFINED CMAKE_CXX_COMPILER)
find_program(
_AMDCLANG
NAMES amdclang++
HINTS ${ROCM_PATH} $ENV{ROCM_PATH} /opt/rocm
PATH_SUFFIXES bin
)
if(_AMDCLANG)
set(CMAKE_CXX_COMPILER ${_AMDCLANG})
endif()
unset(_AMDCLANG)
endif()
project(rocprofiler-systems-jpegdecode-example LANGUAGES CXX)
# Support standalone builds
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/standalone-helpers.cmake OPTIONAL)
endif()
# This example requires hip and rocjpeg.
find_package(HIP QUIET)
if(NOT HIP_FOUND)
message(WARNING "hip is not found. Skip jpegdecode example.")
return()
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
list(APPEND CMAKE_PREFIX_PATH ${ROCmVersion_DIR}/lib/cmake ${ROCmVersion_DIR})
list(APPEND CMAKE_PREFIX_PATH ${ROCmVersion_DIR}/hip ${ROCmVersion_DIR})
list(APPEND CMAKE_MODULE_PATH ${ROCmVersion_DIR}/share/rocjpeg/cmake)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
# 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
function(copy_image_files_and_make_copies)
if(EXISTS "${rocjpeg_ROOT_DIR}/share/rocjpeg/images")
if(NOT EXISTS "${CMAKE_BINARY_DIR}/images")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/images")
endif()
file(GLOB_RECURSE image_files "${rocjpeg_ROOT_DIR}/share/rocjpeg/images/*")
file(COPY ${image_files} DESTINATION ${CMAKE_BINARY_DIR}/images)
set(NUM_COPIES 20)
# Loop over each file and make additional copies
foreach(file ${image_files})
get_filename_component(filename ${file} NAME)
foreach(i RANGE 1 ${NUM_COPIES})
file(
COPY ${file}
DESTINATION ${CMAKE_BINARY_DIR}/images/${filename}_copy${i}.jpg
)
endforeach()
endforeach()
else()
message(
AUTHOR_WARNING
"Source directory ${rocjpeg_ROOT_DIR}/share/rocjpeg/images does not exist"
)
endif()
endfunction()
# threads
find_package(Threads REQUIRED)
if(HIP_FOUND AND rocjpeg_FOUND AND Threads_FOUND AND rocprofiler-register_FOUND)
# HIP
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} hip::host)
# threads
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} Threads::Threads)
# std filesystem
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} stdc++fs)
# rocprofiler-register
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocprofiler-register::rocprofiler-register)
# rocJPEG
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)
add_executable(jpegdecode ${SOURCES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
target_link_libraries(jpegdecode ${LINK_LIBRARY_LIST})
target_compile_options(jpegdecode PRIVATE ${_FLAGS})
copy_image_files_and_make_copies()
if(ROCPROFSYS_INSTALL_EXAMPLES AND TARGET jpegdecode)
install(
TARGETS jpegdecode
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/rocprofiler-systems/examples
COMPONENT rocprofiler-systems-examples
)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/images/
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/rocprofiler-systems/examples/images
COMPONENT rocprofiler-systems-examples
)
endif()
else()
message(
"-- ERROR!: ${PROJECT_NAME} excluded! please install all the dependencies and try again!"
)
if(NOT HIP_FOUND)
message(FATAL_ERROR "-- ERROR!: HIP Not Found! - please install ROCm and HIP!")
endif()
if(NOT rocjpeg_FOUND)
message(WARNING "-- ERROR!: rocJPEG Not Found! - please install rocJPEG!")
endif()
if(NOT Threads_FOUND)
message(WARNING "-- ERROR!: Threads Not Found! - please install Threads!")
endif()
if(NOT rocprofiler-register_FOUND)
message(
WARNING
"-- ERROR!: rocprofiler-register Not Found! - please install rocprofiler-register!"
)
endif()
endif()