clangen / musikcube

a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++
https://musikcube.com
BSD 3-Clause "New" or "Revised" License
4.18k stars 295 forks source link

find_library should have PATHS for FFMpeg components, and allow user to specify those (or switch to PkgConfig for that) #691

Open barracuda156 opened 2 months ago

barracuda156 commented 2 months ago

Setting include path is not sufficient to find libraries of FFMpeg, when those are not in default paths.

What is needed is either of the following:

  1. Use PkgConfig to set correct paths for FFMpeg.
  2. Allow user to define paths explicitly, and that should also be done for libraries, not only for includes.

For example, this works:

include_directories("/opt/local/libexec/ffmpeg7/include")
find_library(AVCODEC NAMES avcodec PATHS /opt/local/libexec/ffmpeg7/lib)

While trying it without PATHS specified results in configure error (even when include_directories points to the correct path):

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
AVCODEC
    linked by target "ffmpegdecoder" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/ffmpegdecoder
    linked by target "stockencoders" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/stockencoders
AVFORMAT
    linked by target "ffmpegdecoder" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/ffmpegdecoder
    linked by target "stockencoders" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/stockencoders
AVUTIL
    linked by target "ffmpegdecoder" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/ffmpegdecoder
    linked by target "stockencoders" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/stockencoders
SWRESAMPLE
    linked by target "ffmpegdecoder" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/ffmpegdecoder
    linked by target "stockencoders" in directory /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_multimedia_musikcube/musikcube/work/musikcube-3.0.3/src/plugins/stockencoders