[CMake] how to link with a system library ?
Mike Jackson
mike.jackson at bluequartz.net
Sun Sep 21 09:15:01 EDT 2008
On Sep 21, 2008, at 9:10 AM, Steven Samuel Cole wrote:
> Christian Ehrlicher schrieb:
>> Steven Samuel Cole schrieb:
>>> Eric Noulard schrieb:
>>>> 2008/9/21 Steven Samuel Cole <steven.samuel.cole at gmail.com>:
>>>>> I would like to link a system library into an executable, GTK in
>>>>> this case.
>>>>> What I'm trying to do is
>>>>>
>>>>> include(FindGTK)
>>>>>
>>>>> target_link_libraries(myexec $GTK_LIBRARIES)
>>>>>
>>>>> add_executable (myexec sources)
>>>>>
>>>>> Result:
>>>>>
>>>>> CMake Error: Attempt to add link library "GTK_LIBRARIES" to
>>>>> target "myexec"
>>>>> which is not built by this project.
>>>>>
>>>>> What am I doing wrong ?
>>>>
>>>> You may be missing curly brace around variable could you try:
>>>>
>>>>
>>>> target_link_libraries(myexec ${GTK_LIBRARIES})
>>>>
>>>
>>> Thanks for your help! :-)
>>>
>>> ${GTK_LIBRARIES} instead of $GTK_LIBRARIES fixes the CMake Error
>>> problem, but I still get GTK link errors. Also, even though I do
>>> include_directories(${GTK_INCLUDE_DIR}), I still get
>>> gtk/gtk.h: No such file or directory.
>>>
>>> Has anyone ever seen this working ?
>> Are you sure you have set GTK_INCLUDE_DIR at all?
>> -> cmake documentation FIND_PACKAGE() should help here
>> Christian
>
> Why would I want to set GTK_INCLUDE_DIR ?
> I want to _use_ it, so I don't have to specify include paths myself.
>
> I have read the documentation on FIND_PACKAGE() and FindGTK(), but I
> can't seem to figure out how this is supposed to work.
>
> Could someone provide a code snippet ?
>
If you are having cmake generate makefiles then run make in the
following fashion:
make VERBOSE=1
and carefully inspect the compile line. From that you should be able
to deduce why gtk/gtk.h is NOT on the include paths.
_________________________________________________
| Mike Jackson - Principal Software Engineer |
| BlueQuartz Software |
| mike.jackson at bluequartz.net |
| www.bluequartz.net |
---------------------------------------------------
More information about the CMake
mailing list