|
| 1 | +# MIT License |
| 2 | +# |
| 3 | +# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +set(example_name rocal_basic) |
| 24 | + |
| 25 | +cmake_minimum_required(VERSION 3.21 FATAL_ERROR) |
| 26 | +project(${example_name} LANGUAGES CXX) |
| 27 | + |
| 28 | +if(GPU_RUNTIME STREQUAL "CUDA") |
| 29 | + message(STATUS "rocAL examples do not support the CUDA runtime") |
| 30 | + return() |
| 31 | +endif() |
| 32 | + |
| 33 | +set(CMAKE_CXX_STANDARD 17) |
| 34 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 35 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 36 | + |
| 37 | +if(CMAKE_SYSTEM_NAME MATCHES "Windows") |
| 38 | + message(STATUS "rocAL examples are only available on Linux") |
| 39 | + return() |
| 40 | +else() |
| 41 | + set(ROCM_ROOT |
| 42 | + "/opt/rocm" |
| 43 | + CACHE PATH |
| 44 | + "Root directory of the ROCm installation" |
| 45 | + ) |
| 46 | +endif() |
| 47 | + |
| 48 | +list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}") |
| 49 | + |
| 50 | +find_library(ROCAL_LIBRARY |
| 51 | + NAMES rocal |
| 52 | + PATHS"${ROCM_ROOT}/lib" |
| 53 | + PATH_SUFFIXES lib lib64 |
| 54 | + REQUIRED |
| 55 | +) |
| 56 | + |
| 57 | +find_package(OpenCV REQUIRED) |
| 58 | + |
| 59 | +add_executable(${example_name} main.cpp) |
| 60 | +# Make example runnable using ctest |
| 61 | +add_test(NAME ${example_name} COMMAND ${example_name}) |
| 62 | + |
| 63 | +# Link to rocAL library |
| 64 | +target_link_libraries(${example_name} PRIVATE ${ROCAL_LIBRARY} ${OpenCV_LIBS}) |
| 65 | + |
| 66 | +# Include directories |
| 67 | +target_include_directories( |
| 68 | + ${example_name} |
| 69 | + PRIVATE "../../../External" ${ROCM_ROOT}/include ${ROCM_ROOT}/include/rocal ${OpenCV_INCLUDE_DIRS} |
| 70 | +) |
| 71 | + |
| 72 | +# Set example data directory as compile definition |
| 73 | +target_compile_definitions( |
| 74 | + ${example_name} |
| 75 | + PRIVATE EXAMPLE_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../data" |
| 76 | +) |
| 77 | + |
| 78 | +install(TARGETS ${example_name}) |
0 commit comments