11
votes

I am compiling a dependency for a project on Ubuntu 10.10, and instead of having it install to /usr/local by default, I am instead installing it to /tmp/stage/usr/local. How do I go about informing CMake of the location of this custom installed dependency when I call it to generate the build files for said project.

I am running CMake 2.8.1, and I have tried to set CMAKE_PREFIX_PATH on the cmake command line, like so

cmake -D CMAKE_PREFIX_PATH=/tmp/stage/usr/local

but this doesn't seem to make a difference - the project doesn't seem to detect the dependency.

Also, if it matters, the project in question is OpenCV 2.2, and the dependency in question is FFMPEG...

1
I am confused by this question, are you saying that you have FFMPEG installed in /tmp/stage/usr/local and you are trying to build opencv against that FFMPEG? Or are you trying to install something with cmake in /tmp/stage/usr/local?ltc
FFMPEG is installed in /tmp/stage/usr/local and I am trying to build OpenCV against that FFMPEG, yes...hatboyzero

1 Answers

23
votes

I figured out how to fix my problem, and trying to point CMake at the appropriate install location isn't the issue.

Apparently, CMake is unable to find the pkg-config files for FFMPEG (i.e. libavcodec.pc, libavdevice.pc, etc.) that tell it where the FFMPEG headers and libraries are located. In a typical install scenario, these files would be located at /usr/lib/pkgconfig. However because of the custom install location, they are instead located at /tmp/stage/usr/local/lib/pkgconfig.

So that CMake could find these files, I had to add the following environment variable:

export PKG_CONFIG_PATH=/tmp/stage/usr/local/lib/pkgconfig

After which point, OpenCV built against FFMPEG as expected.