On 11.01.11 10:27:02, Thomas Petazzoni wrote: > Hello, > > On Tue, 11 Jan 2011 01:42:47 +0100 > Michael Hertling <mhertl...@online.de> wrote: > > > Since CMake prefers to specify libraries by path instead of using > > -l/-L or the like, there's usually no need for the LINK_DIRECTORIES() > > command, IMO. > > Sorry to jump into the discussion, but I'm having a problem that I > think is related to that. > > I have an application that links against Qt and another library which > is found using pkg-config (and the PkgConfig CMake module). Due to the > fact that I'm cross-compiling, the library is in a non-standard > location (i.e: $HOME/something/usr/lib instead of /usr/lib). > Unfortunately, the xxx_LIBRARIES variable filled by the PkgConfig > module only contains "-lfoobar". So I'd like to either :
Don't use the results of the PkgConfig module directly when finding libraries. Instead simply use it as hint to the find_library() cmake function to get the real libraries. For example this might work: set( MyPkg_LIBS ) foreach( lib ${MyPkg_LIBRARIES} ) find_library( _lib NAMES ${lib} HINTS ${MyPkg_LIBRARY_DIRS} ) list( APPEND MyPkg_LIBS ${_lib} ) endforeach() This will make sure that the libraries extracted by using the PkgConfig module are found with their absolute path and put into the MyPkg_LIBS variable. If you want to, you can also create individual variables for each library. The HINTS argument will make sure that CMake first searches for your library in the paths extracted from the pkg-config file. Andreas -- You recoil from the crude; you tend naturally toward the exquisite. _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake