[Cmake] gtk-config / pkg-config
Mathieu Malaterre
Mathieu.Malaterre@creatis.insa-lyon.fr
Mon, 05 May 2003 14:46:23 +0200
Hi all,
I needed to test my class wxVTKRenderWindowInteractor:
http://www.creatis.insa-lyon.fr/~malaterre/wxVTK/
with GTK2 so I rewrote FindGTK.cmake (based on FindwxWindow) like this:
#######
IF(WIN32)
...
ELSE(WIN32)
FIND_PROGRAM(CMAKE_PKG_CONFIG pkg-config ../gtk/bin ../../gtk/bin)
IF(CMAKE_PKG_CONFIG)
SET(CMAKE_GTK_CXX_FLAGS "`${CMAKE_PKG_CONFIG} --cflags gtk+-2.0`")
SET(GTK_LIBRARIES "`${CMAKE_PKG_CONFIG} --libs gtk+-2.0`")
ELSE(CMAKE_PKG_CONFIG)
FIND_PROGRAM(CMAKE_GTK_CONFIG gtk-config ../gtk/bin ../../gtk/bin)
SET(CMAKE_GTK_CXX_FLAGS "`${CMAKE_GTK_CONFIG} --cxxflags`")
SET(GTK_LIBRARIES "`${CMAKE_GTK_CONFIG} --libs`")
ENDIF(CMAKE_PKG_CONFIG)
ENDIF(WIN32)
MARK_AS_ADVANCED(
CMAKE_GTK_CXX_FLAGS
GTK_INCLUDE_DIR
)
IF(GTK_LIBRARIES)
IF(CMAKE_GTK_CXX_FLAGS)
SET(GTK_FOUND 1)
ENDIF(CMAKE_GTK_CXX_FLAGS)
ENDIF(GTK_LIBRARIES)
#######
This take advantage of pkg-config which should replace *-config tool. See:
http://www.freedesktop.org/software/pkgconfig/
But I am stuck:
- I would like the user to choose either if he wants GTK 1.x or GTK 2.x
but I don't know how to handle this.
- Furthermore, the user should not be able to use GTK 2.x if pkg-config
can't be found (only gtk-config was found). There will be also some
problems if pkg-config is not in the path and is specified later...
Thanks for your suggestions,
mathieu
--
Mathieu Malaterre
CREATIS
28 Avenue du Doyen LEPINE
B.P. Lyon-Montchat
69394 Lyon Cedex 03
http://www.creatis.insa-lyon.fr/~malaterre/