[CMake] first look for Cairo, then for GLib/GDK/GTK

this starts to align to the searches done with autotools
also, move the CAIRO_FEATURE to the main CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a96484..d76d31c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,15 +79,18 @@
 endif(JPEG_FOUND)
 macro_optional_find_package(Qt3)
 macro_optional_find_package(Qt4)
-macro_optional_find_package(GTK)
-if(GLIB_FOUND)
-  macro_optional_find_package(Cairo ${CAIRO_VERSION})
+macro_optional_find_package(Cairo ${CAIRO_VERSION})
+if(CAIRO_FOUND)
   set(HAVE_CAIRO ${CAIRO_FOUND})
-  set(POPPLER_WITH_GDK ${GDK_FOUND})
-  if(CAIRO_FOUND)
-    set(CAIRO_REQ "cairo")
-  endif(CAIRO_FOUND)
-endif(GLIB_FOUND)
+  set(CAIRO_FEATURE "#define POPPLER_HAS_CAIRO 1")
+  set(CAIRO_REQ "cairo")
+  macro_optional_find_package(GTK)
+  if(GLIB_FOUND)
+    set(POPPLER_WITH_GDK ${GDK_FOUND})
+  endif(GLIB_FOUND)
+else(CAIRO_FOUND)
+  set(CAIRO_FEATURE "#undef POPPLER_HAS_CAIRO")
+endif(CAIRO_FOUND)
 if(ENABLE_CPP)
   macro_optional_find_package(Iconv)
   set(ENABLE_CPP ${ICONV_FOUND})
diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt
index 3761c6f..39fbbaf 100644
--- a/glib/CMakeLists.txt
+++ b/glib/CMakeLists.txt
@@ -5,7 +5,6 @@
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CAIRO_INCLUDE_DIRS}
 )
-set (CAIRO_FEATURE "#define POPPLER_HAS_CAIRO 1")
 add_definitions(${CAIRO_CFLAGS})
 
 if (GDK_FOUND)