I have FFmpeg built from source on my system, to get around outdated distro packages. I also have a lot of additional functionality enabled, which means my FFmpeg libraries depend on a whole bunch of additional libraries like faac and faad, lame, schrödinger, theora and so on.
My first thought was to add these extra libraries to the CMAKE_EXE_LINKER_FLAGS variable. This is not
the place, because the expansion of this variable is included at the wrong point in the final link command, where they will not be used to resolve undefined symbols in the FFmpeg libraries. As a result, your link will fail.
To ensure these libraries are included at the right place, put them on the end of the FFMPEG_LIBRARIES value, after the FFmpeg libraries proper. They will similarly be included immediately after the FFmpeg libraries in the link command, thereby correctly resolving the necessary symbols.
For example, my FFMPEG_LIBRARIES definition currently looks like this (all on one line):
Everything up to and including “postproc” is an FFmpeg library; everything after that is a non-FFmpeg library needed to resolve dependencies in the FFmpeg libraries.