[CMake] Problem with pkg_check_modules and imlib2
Michael Hertling
mhertling at online.de
Fri May 13 05:03:15 EDT 2011
On 05/12/2011 10:40 PM, David Demelier wrote:
> Hello,
>
> I have some trouble to link my project to the imlib2 library. The
> library is installed correctly and a command like :
>
> gcc test.c -o test `pkg-config --libs --cflags imlib2`
>
> works and link to imlib2.
>
> I have this CMakeLists.txt http://markand.malikania.fr/CMakeLists.txt
> but it does not work, as you can see it detects fine the library dirs
> and include dirs :
>
> markand at Melon ~/devel/wmfs/build $ cmake ..
> -- INFO: XDG_CONFIG_DIR set /usr/local/etc/
> -- INFO: imlib2 enabled
> -- INFO: imlib2 under /usr/local/include;/usr/local/include/freetype2
> -- INFO: imlib2 under /usr/local/lib
> -- INFO: imlib2 under Imlib2
>
> But it does not link :
>
> markand at Melon ~/devel/wmfs/build $ make
> Linking C executable wmfs
> /usr/bin/ld: cannot find -lImlib2
>
> What am I doing wrong? Also the CMakeCache is set with the good parameters :
>
> [...]
> IMLIB2_INCLUDEDIR:INTERNAL=/usr/local/include
> IMLIB2_INCLUDE_DIRS:INTERNAL=/usr/local/include;/usr/local/include/freetype2
> IMLIB2_LIBRARIES:INTERNAL=Imlib2
> IMLIB2_LIBRARY_DIRS:INTERNAL=/usr/local/lib
> IMLIB2_LDFLAGS:INTERNAL=-L/usr/local/lib;-lImlib2
> [...]
>
> Cheers,
Citing from the documentation of LINK_DIRECTORIES():
"The command will apply only to targets created *after* it is called."
Thus, I suppose "-L/usr/local/lib" does not appear in the link command
for the wmfs target? If so, rearrange your CMakeLists.txt so that wmfs
is defined after the LINK_DIRECTORIES() command, or use IMLIB2_LDFLAGS
in TARGET_LINK_LIBRARIES() instead of IMLIB2_LIBRARIES, and drop the
LINK_DIRECTORIES() command completely.
'hope that helps.
Regards,
Michael
More information about the CMake
mailing list