[CMake] FindGTK.cmake or gtk-config?

Brad King brad.king at kitware.com
Mon Mar 21 16:07:04 EST 2005


Juan José Aja Fernández wrote:
> I'm trying to develop an application using vtk and gtk, so I decided
> to use the cmake module FindGTK.cmake (version 2.0.5).
> I read two or three posts regarding that issue, but sincerely I didn't
> understand them very well.
> 
> Apparently it finds gtk (I arranged my CMakeLists.txt to display a
> confirmation message inside the IF (GTK_FOUND) statement) but gives a
> lot of errors regarding the includes in gtk.h (also I had to change:
> #include <gtk/gtk.h> to: #include </usr/include/gtk-1.2/gtk/gtk.h>
> because the former made the compiler tell me that gtk/gtk.h was not
> found).
> 
> I'm new to cmake, so I just wanted to know what's the proper way of
> telling cmake to pass to the compiler the necesary flags to compile
> with gtk.

Including FindGTK.cmake does what it says...it finds GTK.  It does not 
_use_ gtk automatically.  For that you have to add commands to include 
it in the build.  Try code like

FIND_PACKAGE(GTK)

IF(GTK_FOUND)
   INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIR})
   ADD_EXECUTABLE(my_gtk_exe my_gtk_exe.cxx)
   TARGET_LINK_LIBRARIES(my_gtk_exe ${GTK_LIBRARIES})
ENDIF(GTK_FOUND)

Read the top of FindGTK.cmake to see the set of variables it sets for you.

-Brad


More information about the CMake mailing list