Skip to content

Commit f7dfcad

Browse files
committed
build(cmake): conditionally linking ffnvcodec and installing stubs
1 parent a2cdf3c commit f7dfcad

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

cmake/Dependencies.cmake

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ ome_find_pkg(PKG_LIBAVUTIL libavutil OME_VER_LIBAVUTIL REINSTAL
330330

331331
# NVIDIA CUDA/NVML
332332
if(OME_HWACCEL_NVIDIA)
333+
ome_find_pkg(PKG_FFNVCODEC ffnvcodec OME_VER_NVCC_HDR REINSTALL_TARGET ffnvcodec)
334+
333335
set(_CUDA_ROOT "/usr/local/cuda")
334336
find_library(_NV_CUDA_LIB cuda HINTS ${_CUDA_ROOT}/lib64 ${_CUDA_ROOT}/lib64/stubs /usr/lib/x86_64-linux-gnu)
335337
find_library(_NV_CUDART_LIB cudart HINTS ${_CUDA_ROOT}/lib64 /usr/lib/x86_64-linux-gnu)
@@ -392,6 +394,26 @@ if(OME_HWACCEL_NILOGAN)
392394
endif()
393395
endif()
394396

397+
# Stubs
398+
# - Stubs lack pkg-config entries, so check for the stubs directory and install if missing.
399+
if(OME_HWACCEL_NVIDIA OR OME_HWACCEL_XMA OR OME_HWACCEL_NILOGAN)
400+
if(NOT IS_DIRECTORY "${OME_DEP_PREFIX}/lib/stubs")
401+
message(STATUS "[OME] ${OME_DEP_PREFIX}/lib/stubs not found - installing stubs libraries ...")
402+
execute_process(
403+
COMMAND ${CMAKE_COMMAND}
404+
-DOME_DEP_PREFIX=${OME_DEP_PREFIX}
405+
-DTARGET=stubs
406+
-P "${CMAKE_SOURCE_DIR}/cmake/InstallPrerequisites.cmake"
407+
RESULT_VARIABLE _stubs_ret
408+
)
409+
if(NOT _stubs_ret EQUAL 0)
410+
message(FATAL_ERROR "[OME] Failed to install stubs.")
411+
endif()
412+
unset(_stubs_ret)
413+
endif()
414+
endif()
415+
416+
395417
# jemalloc - required for Release builds, optional for Debug (can be forced with OME_ENABLE_JEMALLOC=ON)
396418
# Note: when built with --enable-prof, jemalloc reports its pkg-config version as "<ver>_0"
397419
# (e.g. "5.3.0_0"), so we use >= instead of = to avoid a false version mismatch.
@@ -440,24 +462,6 @@ else()
440462
message(STATUS "[OME] libx264: disabled by OME_ENABLE_X264=OFF")
441463
endif()
442464

443-
# ==============================================================================
444-
# Stubs (GPU stub .so files) are installed unconditionally, regardless of hardware support.
445-
# ==============================================================================
446-
if(NOT IS_DIRECTORY "${OME_DEP_PREFIX}/lib/stubs")
447-
message(STATUS "[OME] ${OME_DEP_PREFIX}/lib/stubs not found - installing stubs libraries ...")
448-
execute_process(
449-
COMMAND ${CMAKE_COMMAND}
450-
-DOME_DEP_PREFIX=${OME_DEP_PREFIX}
451-
-DTARGET=stubs
452-
-P "${CMAKE_SOURCE_DIR}/cmake/InstallPrerequisites.cmake"
453-
RESULT_VARIABLE _stubs_ret
454-
)
455-
if(NOT _stubs_ret EQUAL 0)
456-
message(FATAL_ERROR "[OME] Failed to install stubs.")
457-
endif()
458-
unset(_stubs_ret)
459-
endif()
460-
461465

462466
# uuid (system library, not pkg-config)
463467
find_library(UUID_LIB uuid REQUIRED)

src/projects/main/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ target_link_libraries(OvenMediaEngine PRIVATE
7272
# ==============================================================================
7373
# Optional hardware acceleration libs
7474
# ==============================================================================
75-
if(OME_HWACCEL_NVIDIA AND PKG_FFNVCODEC_FOUND)
76-
target_link_libraries(OvenMediaEngine PRIVATE
77-
PkgConfig::PKG_FFNVCODEC
78-
${OME_NVIDIA_LIBS}
79-
)
75+
if(OME_HWACCEL_NVIDIA)
76+
target_link_libraries(OvenMediaEngine PRIVATE ${OME_NVIDIA_LIBS})
77+
target_link_libraries(OvenMediaEngine PRIVATE PkgConfig::PKG_FFNVCODEC)
8078
endif()
8179

8280
if(OME_HWACCEL_XMA AND PKG_LIBXMA2API_FOUND)

0 commit comments

Comments
 (0)