Issue
I want to link my C++ app with any library, for example with libavcodec.so. I tried Method I from href="https://stackoverflow.com/a/44489201/7915017">https://stackoverflow.com/a/44489201/7915017
set(CMAKE_PREFIX_PATH ${pkgconfig_path})
But when I try to build
cmake -S Qt_FFMpeg/src/ -B Qt_FFMpeg/build-host/ --fresh
I get error "A required package was not found". Ok, I try Method II
set(ENV{PKG_CONFIG_PATH} ${pkgconfig_path})
And it works. Why doesn't Method I work? Full code here
I use Ubuntu 22 x86_64, cmake 3.26.4
Solution
Now works! Thanks @Tsyvarev
With Environment Variables
cmake_path(SET pkgconfig_path "${CMAKE_CURRENT_LIST_DIR}/../../FFMpeg_themself/ffmpeg_build/lib/pkgconfig/" NORMALIZE)
set(ENV{PKG_CONFIG_PATH} ${pkgconfig_path})
message("I found $ENV{PKG_CONFIG_PATH}")
Without Environment Variables
cmake_path(SET pkgconfig_path "${CMAKE_CURRENT_LIST_DIR}/../../FFMpeg_themself/ffmpeg_build/" NORMALIZE)
set(CMAKE_PREFIX_PATH ${pkgconfig_path})
message("I found ${CMAKE_PREFIX_PATH}")
Answered By - Андрей Тернити Answer Checked By - Clifford M. (WPSolving Volunteer)