Skip to content

Commit 1030d99

Browse files
[7.0] Make CMakeFile fixes to align with rocDecode and rocJpeg changes (#290)
* Make CMakeFile fixes to align with rocDecode and rocJpeg changes (#281) * 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 <David.Galiffi@amd.com> --------- Co-authored-by: David Galiffi <David.Galiffi@amd.com> --------- Co-authored-by: Sajina PK <Sajina.PuthalathKandy@amd.com>
1 parent c57dad3 commit 1030d99

2 files changed

Lines changed: 94 additions & 14 deletions

File tree

examples/jpegdecode/CMakeLists.txt

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,47 @@ if(ROCPROFSYS_DISABLE_EXAMPLES)
6060
endif()
6161
endif()
6262

63-
find_package(ROCJPEG QUIET)
63+
# find rocJPEG - library and headers
64+
find_path(
65+
rocjpeg_ROOT_DIR
66+
NAMES include/rocjpeg/rocjpeg.h
67+
HINTS ${ROCmVersion_DIR} ${ROCM_PATH}
68+
PATHS ${ROCmVersion_DIR} ${ROCM_PATH}
69+
)
70+
71+
mark_as_advanced(rocjpeg_ROOT_DIR)
72+
73+
find_path(
74+
rocjpeg_INCLUDE_DIR
75+
NAMES rocjpeg/rocjpeg.h
76+
HINTS ${rocjpeg_ROOT_DIR}
77+
PATHS ${rocjpeg_ROOT_DIR}
78+
PATH_SUFFIXES include
79+
)
80+
81+
find_library(
82+
rocjpeg_LIBRARY
83+
NAMES rocjpeg
84+
HINTS ${rocjpeg_ROOT_DIR}
85+
PATHS ${rocjpeg_ROOT_DIR}
86+
PATH_SUFFIXES lib
87+
)
88+
89+
include(FindPackageHandleStandardArgs)
90+
find_package_handle_standard_args(
91+
rocjpeg
92+
FOUND_VAR rocjpeg_FOUND
93+
REQUIRED_VARS rocjpeg_INCLUDE_DIR rocjpeg_LIBRARY
94+
)
95+
96+
if(rocjpeg_FOUND)
97+
if(NOT TARGET rocjpeg::rocjpeg)
98+
add_library(rocjpeg::rocjpeg INTERFACE IMPORTED)
99+
target_link_libraries(rocjpeg::rocjpeg INTERFACE ${rocjpeg_LIBRARY})
100+
target_include_directories(rocjpeg::rocjpeg INTERFACE ${rocjpeg_INCLUDE_DIR})
101+
endif()
102+
endif()
103+
64104
find_package(rocprofiler-register QUIET)
65105

66106
# Copy image files to build directory
@@ -95,7 +135,7 @@ endfunction()
95135
# threads
96136
find_package(Threads REQUIRED)
97137

98-
if(HIP_FOUND AND ROCJPEG_FOUND AND Threads_FOUND AND rocprofiler-register_FOUND)
138+
if(HIP_FOUND AND rocjpeg_FOUND AND Threads_FOUND AND rocprofiler-register_FOUND)
99139
# HIP
100140
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} hip::host)
101141
# threads
@@ -107,9 +147,9 @@ if(HIP_FOUND AND ROCJPEG_FOUND AND Threads_FOUND AND rocprofiler-register_FOUND)
107147
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocprofiler-register::rocprofiler-register)
108148

109149
# rocJPEG
110-
message(STATUS "RocJPEG library found: ${ROCJPEG_LIBRARY}")
111-
include_directories(${ROCJPEG_INCLUDE_DIR})
112-
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${ROCJPEG_LIBRARY})
150+
message(STATUS "RocJPEG library found: ${rocjpeg_LIBRARY}")
151+
include_directories(${rocjpeg_INCLUDE_DIR})
152+
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocjpeg::rocjpeg)
113153
list(APPEND SOURCES ${PROJECT_SOURCE_DIR} jpegdecodeperf.cpp)
114154
add_executable(jpegdecode ${SOURCES})
115155
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
@@ -132,15 +172,15 @@ else()
132172
if(NOT HIP_FOUND)
133173
message(FATAL_ERROR "-- ERROR!: HIP Not Found! - please install ROCm and HIP!")
134174
endif()
135-
if(NOT ROCJPEG_FOUND)
175+
if(NOT rocjpeg_FOUND)
136176
message(WARNING "-- ERROR!: rocJPEG Not Found! - please install rocJPEG!")
137177
endif()
138178
if(NOT Threads_FOUND)
139-
message(FATAL_ERROR "-- ERROR!: Threads Not Found! - please insatll Threads!")
179+
message(WARNING "-- ERROR!: Threads Not Found! - please install Threads!")
140180
endif()
141181
if(NOT rocprofiler-register_FOUND)
142182
message(
143-
FATAL_ERROR
183+
WARNING
144184
"-- ERROR!: rocprofiler-register Not Found! - please install rocprofiler-register!"
145185
)
146186
endif()

examples/videodecode/CMakeLists.txt

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,48 @@ function(videodecode_message _MSG_TYPE)
5454
endfunction()
5555

5656
# Find RocDecode
57-
find_package(ROCDECODE QUIET)
58-
if(NOT ROCDECODE_FOUND)
57+
find_path(
58+
rocdecode_ROOT_DIR
59+
NAMES include/rocdecode/rocdecode.h
60+
HINTS ${ROCmVersion_DIR} ${ROCM_PATH}
61+
PATHS ${ROCmVersion_DIR} ${ROCM_PATH}
62+
)
63+
64+
mark_as_advanced(rocdecode_ROOT_DIR)
65+
66+
find_path(
67+
rocdecode_INCLUDE_DIR
68+
NAMES rocdecode/rocdecode.h
69+
HINTS ${rocdecode_ROOT_DIR}
70+
PATHS ${rocdecode_ROOT_DIR}
71+
PATH_SUFFIXES include
72+
)
73+
74+
find_library(
75+
rocdecode_LIBRARY
76+
NAMES rocdecode
77+
HINTS ${rocdecode_ROOT_DIR}
78+
PATHS ${rocdecode_ROOT_DIR}
79+
PATH_SUFFIXES lib
80+
)
81+
82+
include(FindPackageHandleStandardArgs)
83+
find_package_handle_standard_args(
84+
rocdecode
85+
FOUND_VAR rocdecode_FOUND
86+
REQUIRED_VARS rocdecode_INCLUDE_DIR rocdecode_LIBRARY
87+
)
88+
89+
if(rocdecode_FOUND)
90+
if(NOT TARGET rocdecode::rocdecode)
91+
add_library(rocdecode::rocdecode INTERFACE IMPORTED)
92+
target_link_libraries(rocdecode::rocdecode INTERFACE ${rocdecode_LIBRARY})
93+
target_include_directories(
94+
rocdecode::rocdecode
95+
INTERFACE ${rocdecode_INCLUDE_DIR}
96+
)
97+
endif()
98+
else()
5999
videodecode_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing RocDecode...")
60100
return()
61101
endif()
@@ -102,7 +142,7 @@ set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR})
102142

103143
mark_as_advanced(FFMPEG_INCLUDE_DIR AVCODEC_LIBRARY AVFORMAT_LIBRARY AVUTIL_LIBRARY)
104144

105-
if(FFMPEG_FOUND AND ROCDECODE_FOUND)
145+
if(FFMPEG_FOUND AND rocdecode_FOUND)
106146
# HIP
107147
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} hip::host)
108148

@@ -116,8 +156,8 @@ if(FFMPEG_FOUND AND ROCDECODE_FOUND)
116156
endif()
117157

118158
# rocDecode
119-
include_directories(${ROCDECODE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
120-
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${ROCDECODE_LIBRARY})
159+
include_directories(${rocdecode_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
160+
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} rocdecode::rocdecode)
121161

122162
# Threads
123163
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -155,7 +195,7 @@ else()
155195
if(NOT FFMPEG_FOUND)
156196
message(WARNING "-- ERROR!: FFMPEG Not Found! - please install FFMPEG!")
157197
endif()
158-
if(NOT ROCDECODE_FOUND)
198+
if(NOT rocdecode_FOUND)
159199
message(WARNING "-- ERROR!: rocDecode Not Found! - please install rocDecode!")
160200
endif()
161201
endif()

0 commit comments

Comments
 (0)