It is not clear if this is intentional or not, but with CMake 3.4.0
environment variables such as CXXFLAGS are passed to the compiler after the
directories added via the include_directories() command. In practice, this
means that we then end up with the following command-line:
${CXX} ... -I/usr/local/include ...
-I/usr/local/include/ffmpeg0/libavcodec
-I/usr/local/include/ffmpeg0 ...
which fails because of the following chain of events:
* The port brings in multimedia/ffmpeg indirectly.
* The source code includes headers as <avformat.h> like that, which turn
into /usr/local/include/ffmpeg0/libavformat/avformat.h to the compiler.
* Headers like avformat.h itself include other headers with
"libavcodec/avcodec.h", which, given the compiler command-line above,
becomes /usr/local/include/libavcodec/avcodec.h, coming from
multimedia/ffmpeg, not multimedia/ffmpeg0.
Fix it by making the port behave as it should have from the beginning:
* Stop setting C{PP,XX}FLAGS in the Makefile, as it does not help.
* Include the ffmpeg-related headers before the others, so that
/usr/local/include comes after them.
* Adjust patch-cmake so that it works correctly with the setup in ports:
instead of setting the <LIB>_LAVC variables which assume there is a
separate libavcodec installed, make the code fall back to the
<LIB>_FF_LAVC ones, which are set when there's a libavcodec inside an
ffmpeg tree (our case with ffmpeg0). This also takes care of setting
FFMPEG_INCLUDE_DIR with /usr/local/include/ffmpeg0 and passing it in the
right place in the command-line.
Tested with both CMake 3.3.1 and 3.4.0.