[CMake] how to link with a system library ?

Steven Samuel Cole steven.samuel.cole at gmail.com
Sun Sep 21 09:28:28 EDT 2008


Mike Jackson schrieb:
> include(FindGTK)
> add_executable (myexec ${sources} )
> 
> target_link_libraries(myexec ${GTK_LIBRARIES} )
> 
> 
> Note the order above.
> 
> Also, cmake variables are ALWAYS used with braces ${Variable} NOT 
> $Variable.
> 
> Mike

Thanks for that, Mike :-)

The sample code corresponds to what I'm doing, even the order happens to 
be the same. I still keep getting GTK include errors. Tried 
include_directories (... ${GTK_INCLUDE_DIR}) in all orders.

BTW: Why does the order matter ? How do I know the right order ?

When I use hand-coded include paths, I get GTK linker errors.

 > 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.

True,there is nothing GTK-related in the compile line.

So does FindGTK silently fail to find GTK inc/libs ?
If so, how can I fix that ?


> On Sep 21, 2008, at 5:23 AM, Steven Samuel Cole wrote:
> 
>> 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 ?
>>
>> Kind regards,
>>
>> Steve
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
> 



More information about the CMake mailing list