Always the same concerns, Linkage error with ffmpeg

OPENCV: mater
FFmpeg: 4.2

root@PC:/home/opencv4/build# cmake -DOPENCV_EXTRA_MODULES_PATH=…/opencv_contrib-master/modules -DCMAKE_INSTALL_PREFIX=/usr/local/share/opencv4 -D WITH_FFMPEG=1 -D INSTALL_C_EXAMPLES=OFF …/opencv-master
root@PC:/home/opencv4/build# make

[ 51%] Linking CXX executable …/…/bin/opencv_perf_videoio
/usr/bin/ld: …/…/lib/ undefined reference to avformat_network_init' /usr/bin/ld: ../../lib/ undefined reference to av_bsf_init’
/usr/bin/ld: …/…/lib/ undefined reference to av_packet_rescale_ts' /usr/bin/ld: ../../lib/ undefined reference to avformat_find_stream_info’
/usr/bin/ld: …/…/lib/ undefined reference to avcodec_get_name' /usr/bin/ld: ../../lib/ undefined reference to av_frame_unref’
/usr/bin/ld: …/…/lib/ undefined reference to avformat_new_stream' /usr/bin/ld: ../../lib/ undefined reference to avcodec_receive_packet’
/usr/bin/ld: …/…/lib/ undefined reference to avformat_close_input' /usr/bin/ld: ../../lib/ undefined reference to av_frame_alloc’
/usr/bin/ld: …/…/lib/ undefined reference to `av_image_fill_arrays’

root@PC:/home/opencv4/build# ll /usr/lib/pkgconfig
total 44
drwxr-xr-x 2 root root 4096 Feb 17 06:02 ./
drwxr-xr-x 88 root root 12288 Feb 17 06:02 …/
-rw-r–r-- 1 root root 384 Feb 17 06:02 libavcodec.pc
-rw-r–r-- 1 root root 482 Feb 17 06:02 libavdevice.pc
-rw-r–r-- 1 root root 465 Feb 17 06:02 libavfilter.pc
-rw-r–r-- 1 root root 406 Feb 17 06:02 libavformat.pc
-rw-r–r-- 1 root root 324 Feb 17 06:02 libavutil.pc
-rw-r–r-- 1 root root 352 Feb 17 06:02 libswresample.pc
-rw-r–r-- 1 root root 345 Feb 17 06:02 libswscale.pc
/usr/lib/pkgconfig/libavformat.pc:Libs: -L${libdir} -lavformat -lm -lz

root@PC:/home/opencv4/build# cat /usr/local/share/ffmpeg/lib/pkgconfig/libavformat.pc

Name: libavformat
Description: FFmpeg container format library
Version: 58.67.100
Requires: libavcodec >= 58.123.100, libswresample >= 3.8.100, libavutil >= 56.65.100
Libs: -L${libdir} -lavformat -lm -lz
Cflags: -I${includedir}

root@PC:/home/opencv4/build# pkg-config --libs libavformat
-L/usr/local/share/ffmpeg/lib -lavformat -lm -lz -lavcodec -pthread -lm -llzma -lz -lswresample -lm -lavutil -pthread -lm

The concern is very recurrent, my solutions are very vagueness. So, I have everything I need how to compile opencv with with -lavformat ?

My installation ffmpeg is into /usr/local/share/ffmpeg and I use PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib/pkgconfig:/usr/local/share/ffmpeg/lib/pkgconfig (pkg-config ound configuration).