Skip to content

Commit

Permalink
cmake: Notice if the install directory has been deleted.
Browse files Browse the repository at this point in the history
The cmake process for building the MythTV sub-project expects to find
FFmpeg executables already in the install directory.  It runs one of
these programs to determine available features.  If the program is no
longer present, complain and stop instead of continuing with
incomplete information.

The results of find_xxx are cached, so if the program has been deleted
since the first run, find_xx stills return the location of where it
used to be.  The new "if" test is executed every time to see if the
program is actually still there.
  • Loading branch information
linuxdude42 committed Dec 23, 2024
1 parent e465a03 commit 6012678
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions mythtv/cmake/MythFindPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux|Windows" AND CMAKE_SYSTEM_PROCESSOR MATCHES
find_program(_ffmpeg mythffmpeg)
find_library(_avcodec mythavdevice)
cmake_path(GET _avcodec PARENT_PATH _avcodec_path)
if(_ffmpeg AND _avcodec)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${_avcodec_path}
${_ffmpeg} -decoders
OUTPUT_VARIABLE _output
ERROR_QUIET)
string(FIND ${_output} cuvid CUVID_OFFSET)
if(NOT EXISTS ${_ffmpeg})
message(FATAL_ERROR "Cannot find our ffmpeg executable at ${_ffmpeg}")
endif()
if(NOT EXISTS ${_avcodec})
message(FATAL_ERROR "Cannot find our mythavdevice library ${_avcodec}")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${_avcodec_path}
${_ffmpeg} -decoders
OUTPUT_VARIABLE _output
ERROR_QUIET)
string(FIND ${_output} cuvid CUVID_OFFSET)
if(NOT CUVID_OFFSET EQUAL -1)
target_compile_definitions(PkgConfig::FFNVCODEC INTERFACE USING_NVDEC)
endif()
Expand Down Expand Up @@ -513,14 +517,19 @@ if(APPLE)
find_program(_ffmpeg mythffmpeg)
find_library(_avcodec mythavdevice)
cmake_path(GET _avcodec PARENT_PATH _avcodec_path)
if(_ffmpeg AND _avcodec)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${_avcodec_path}
${_ffmpeg} -decoders
OUTPUT_VARIABLE _output
ERROR_QUIET)
string(FIND ${_output} videotoolbox VIDEOTOOLBOX_OFFSET)
endif()
if(NOT EXISTS ${_ffmpeg})
message(FATAL_ERROR "Cannot find our ffmpeg executable at ${_ffmpeg}")
endif()
if(NOT EXISTS ${_avcodec})
message(FATAL_ERROR "Cannot find our mythavdevice library ${_avcodec}")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${_avcodec_path}
${_ffmpeg} -decoders
OUTPUT_VARIABLE _output
ERROR_QUIET)
message(STATUS "Looking for videotoolbox: ${_output}")
string(FIND ${_output} videotoolbox VIDEOTOOLBOX_OFFSET)
if(VIDEOTOOLBOX_OFFSET EQUAL -1)
unset(APPLE_VIDEOTOOLBOX_LIBRARY)
endif()
Expand Down

0 comments on commit 6012678

Please sign in to comment.