DEC
12
2008
|
How to get CMake find what you want it toSince some August or so we are now requiring CMake 2.6 for KDE svn trunk. One thing was has been added and which is very nice support for the new environment variable CMAKE_PREFIX_PATH. It's purpose is to help with getting CMake to find what you want it to find. Usually a software package is installed to some "prefix" directory, in the lib/ subdir of that prefix go the libraries, in the include/ subdir of that prefix go the headers, and in the bin/ subdir of that prefix go the programs. By default, if you use one of the find_(file|path|library|program)() commands, CMake searches in a set of such prefix directories, e.g. in /usr, /usr/local, /opt/csw and more (i.e. in the include/, library/ and bin/ directories depending on whether find_(file|path|library|program) was called. Have a look at Modules/Platform/UnixPath.cmake for the full set of default search directories. Since CMake 2.6 it also searches in CMAKE_INSTALL_PREFIX of the current project and in the directory where CMake itself is installed. But let's say, you have some custom install directories on your system, e.g. if you are a kdepim developer you might have kdesupport and kdelibs in /opt/kde4, while you install kdepimlibs and kdepim to $HOME/kdepim/. Or, as another example, I have kdesupport in /opt/kdesupport, kdelibs in /opt/kdelibs, kdepimlibs in /opt/kdepimlibs, qt-copy in /opt/qt-copy, the rest of KDE4 in /opt/kde4. What's the best way to get CMake 2.6 find all that ? So, this is what I do to get cmake find all my KDE4 stuff: $ export CMAKE_PREFIX_PATH=/opt/qt-copy:/opt/kdesupport:/opt/kdelibs:/opt/kdepimlibs:/opt/kde4 Did you notice that I also put the directory of qt-copy there ? This also makes sure that CMake finds the qmake sitting there first, and I don't have to change the PATH additionally. Now what would the aforementioned kdepim developer do ? $ export CMAKE_PREFIX_PATH=$HOME/kdepim:/opt/kde4 This environment variable has to be set (only) at CMake-time. And once CMake has found the stuff, it shouldn't be required anymore, authors of FindFoo.cmake modules should take care of that (i.e. that everything is properly stored in the cache). So, what to keep from that ? If you have some custom install directories on your system and you want CMake to find the stuff installed there, set CMAKE_PREFIX_PATH. Alex Now what's a good way to get CMake t |
![]() |
Comments
It does not work :-(
I attempt to compile kdebase from trunk against kdelibs and kdesupport in ~/kde. So following your instruction i set CMAKE_PREFIX_PATH to $HOME/kde. But cmake keeps finding nepomuk and soprano in /usr, making the build break.
It works. First, export the
It works. First, export the environment variable. Second, delete the build directory if exists. Last, build and enjoy:)
Yes, nearly nine years later, and it's still helpful
I've been trying many variants of this command, and at last, afer deleting the build directory, it's working great
Works! Great
Almost 8 years later and still google pointed me here and I solved my problem.
How to get CMake find what you want it to
Thanks. This helped.
Thank you!
I just want to say thank you for your post.