Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CMake の FindGTK.cmake モジュールが gtk-1.2 を探すような古いものだったので、3.0 とか 2.0 を探せるようにしてみた。
message(STATUS "Find Gtk+ ...")
if(UNIX)
find_path(GTK_glibconfig_INCLUDE_PATH NAMES glibconfig.h
PATHS
/usr/lib/glib-2.0/include
/usr/local/lib/glib-2.0/include)
message(STATUS "Found header glibconfig by ${GTK_glibconfig_INCLUDE_PATH}")
find_path(GTK_glib_INCLUDE_PATH NAMES glib.h
PATH_SUFFIXES glib-2.0 glib-1.2 glib-1.0 glib
PATHS
/lib/include
/lib/local/include)
message(STATUS "Found header glib by ${GTK_glib_INCLUDE_PATH}")
find_path(GTK_gmodule_INCLUDE_PATH NAMES gmodule.h
PATH_SUFFIXES glib-2.0 glib-1.2 glib-1.0 glib
PATHS
/lib/include
/lib/local/include)
message(STATUS "Found header gmodule by ${GTK_gmodule_INCLUDE_PATH}")
find_path(GTK_gio_INCLUDE_PATH NAMES gio/gio.h
PATH_SUFFIXES glib-2.0 glib-1.2 glib-1.0 glib
PATHS
/lib/include
/lib/local/include)
message(STATUS "Found header gio by ${GTK_gio_INCLUDE_PATH}")
find_path(GTK_gthread_INCLUDE_PATH NAMES glib/gthread.h
PATH_SUFFIXES glib-2.0 glib-1.2 glib-1.0 glib
PATHS
/lib/include
/lib/local/include)
message(STATUS "Found header gthread by ${GTK_gthread_INCLUDE_PATH}")
find_path(GTK_gobject_INCLUDE_PATH NAMES gobject/gobject.h
PATH_SUFFIXES glib-2.0 glib-1.2 glib-1.0 glib
PATHS
/lib/include
/lib/local/include)
message(STATUS "Found header gobject by ${GTK_gobject_INCLUDE_PATH}")
find_path(GTK_gail_INCLUDE_PATH NAMES libgail-util/gail-util.h
PATH_SUFFIXES gail-3.0 gail3 gail-2.0 gail2 gail
PATHS
/usr/include
/usr/local/include)
if(NOT GTK_gail_INCLUDE_PATH)
message(STATUS "Not found header gail")
else()
message(STATUS "Found header gail by ${GTK_gail_INCLUDE_PATH}")
endif(NOT GTK_gail_INCLUDE_PATH)
find_path(GTK_gtk_INCLUDE_PATH NAMES gtk/gtk.h
PATH_SUFFIXES gtk-3.0 gtk3 gtk-2.0 gtk2 gtk
PATHS
/usr/include
/usr/local/include)
message(STATUS "Found header gtk by ${GTK_gtk_INCLUDE_PATH}")
find_path(GTK_gdk_INCLUDE_PATH NAMES gdk/gdk.h
PATH_SUFFIXES gtk-3.0 gtk3 gtk-2.0 gtk2 gtk
PATHS
/usr/include
/usr/local/include)
message(STATUS "Found header gdk by ${GTK_gdk_INCLUDE_PATH}")
find_library(GTK_glib_LIBRARY
NAMES glib-2.0 glib-1.2 glib
/usr/lib
/usr/local/lib)
message(STATUS "Found library glib by ${GTK_glib_LIBRARY}")
find_library(GTK_gio_LIBRARY
NAMES gio-2.0 gio-1.2 gio
/usr/lib
/usr/local/lib)
message(STATUS "Found library gio by ${GTK_gio_LIBRARY}")
find_library(GTK_gmodule_LIBRARY
NAMES gmodule-2.0 gmodule-1.2 gmodule
/usr/lib
/usr/local/lib)
message(STATUS "Found library gmodule by ${GTK_gmodule_LIBRARY}")
find_library(GTK_gobject_LIBRARY
NAMES gobject-2.0 gobject-1.2 gobject
/usr/lib
/usr/local/lib)
message(STATUS "Found library gobject by ${GTK_gobject_LIBRARY}")
find_library(GTK_gthread_LIBRARY
NAMES gthread-2.0 gthread-1.2 gthread
/usr/lib
/usr/local/lib)
message(STATUS "Found library gthread by ${GTK_gthread_LIBRARY}")
find_library(GTK_gtk_LIBRARY
NAMES gtk-3 gtk-2
PATHS
/usr/lib
/usr/local/lib)
message(STATUS "Found library gtk by ${GTK_gtk_LIBRARY}")
find_library(GDK_gdk_LIBRARY
NAMES gdk-3 gdk-2
PATHS
/usr/lib
/usr/local/lib)
message(STATUS "Found library gdk by ${GDK_gdk_LIBRARY}")
if(GTK_glibconfig_INCLUDE_PATH AND
GTK_glib_INCLUDE_PATH AND
GTK_gmodule_INCLUDE_PATH AND
GTK_gio_INCLUDE_PATH AND
GTK_gthread_INCLUDE_PATH AND
GTK_gobject_INCLUDE_PATH AND
GTK_gail_INCLUDE_PATH AND
GTK_gdk_INCLUDE_PATH AND
GTK_gtk_INCLUDE_PATH)
set(GTK_FOUND "YES")
set(GTK_INCLUDE_DIR
${GTK_glibconfig_INCLUDE_PATH}
${GTK_glib_INCLUDE_PATH}
${GTK_gmodule_INCLUDE_PATH}
${GTK_gio_INCLUDE_PATH}
${GTK_gthread_INCLUDE_PATH}
${GTK_gobject_INCLUDE_PATH}
${GTK_gail_INCLUDE_PATH}
${GTK_gdk_INCLUDE_PATH}
${GTK_gtk_INCLUDE_PATH})
set(GTK_LIBRARIES
${GTK_glib_LIBRARY}
${GTK_gtk_LIBRARY}
${GTK_gdk_LIBRARY})
if(GTK_gio_LIBRARY)
set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_gio_LIBRARY})
endif(GTK_gio_LIBRARY)
if(GTK_gmodule_LIBRARY)
set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_gmodule_LIBRARY})
endif(GTK_gmodule_LIBRARY)
if(GTK_gobject_LIBRARY)
set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_gobject_LIBRARY})
endif(GTK_gobject_LIBRARY)
if(GTK_gthread_LIBRARY)
set(GTK_LIBRARIES ${GTK_LIBRARIES} ${GTK_gthread_LIBRARY})
endif(GTK_gthread_LIBRARY)
endif(GTK_glibconfig_INCLUDE_PATH AND
GTK_glib_INCLUDE_PATH AND
GTK_gmodule_INCLUDE_PATH AND
GTK_gio_INCLUDE_PATH AND
GTK_gthread_INCLUDE_PATH AND
GTK_gobject_INCLUDE_PATH AND
GTK_gail_INCLUDE_PATH AND
GTK_gdk_INCLUDE_PATH AND
GTK_gtk_INCLUDE_PATH)
mark_as_advanced(GTK_glibconfig_INCLUDE_PATH
GTK_glib_INCLUDE_PATH
GTK_glib_LIBRARY
GTK_gmodule_INCLUDE_PATH
GTK_gmodule_LIBRARY
GTK_gio_INCLUDE_PATH
GTK_gio_LIBRARY
GTK_gthread_INCLUDE_PATH
GTK_gthread_LIBRARY
GTK_gobject_INCLUDE_PATH
GTK_gobject_LIBRARY
GTK_gail_INCLUDE_PATH
GTK_gdk_INCLUDE_PATH
GTK_gtk_INCLUDE_PATH)
endif(UNIX)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.