[CMake] Problem with pkg_check_modules and imlib2

David Demelier demelier.david at gmail.com
Fri May 13 05:44:15 EDT 2011


On 13/05/2011 11:03, Michael Hertling wrote:
> 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.

Oh I even didn't think the problem can come from link_directories() ! I 
added it before the add_executable() and it works, thanks!


>
> Regards,
>
> Michael
> _______________________________________________
> 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


-- 
David Demelier


More information about the CMake mailing list