Qt image dialog
[texmacs.git] / src / cmake / FindCairo.cmake
blob7338845a3dc25c413c6b2f14e32ada869e9a4cbe
1 # from http://zi.fi/cmake/Modules/FindCairo.cmake
2 # modified
4 # - Try to find Cairo
5 # Once done, this will define
7 #  Cairo_FOUND - system has Cairo
8 #  Cairo_INCLUDE_DIRS - the Cairo include directories
9 #  Cairo_LIBRARIES - link these to use Cairo
11 include(LibFindMacros)
12 include(CheckCSourceCompiles)
14 # Dependencies
15 libfind_package(Cairo Freetype)
17 # Use pkg-config to get hints about paths
18 libfind_pkg_check_modules(Cairo_PKGCONF cairo)
20 # Include dir
21 find_path(Cairo_INCLUDE_DIR
22   NAMES cairo.h
23   PATHS ${Cairo_PKGCONF_INCLUDE_DIRS}
24   PATH_SUFFIXES cairo
27 # Finally the library itself
28 find_library(Cairo_LIBRARY
29   NAMES cairo
30   PATHS ${Cairo_PKGCONF_LIBRARY_DIRS}
33 # Set the include dir variables and the libraries and let libfind_process do the rest.
34 # NOTE: Singular variables for this library, plural for libraries this this lib depends on.
35 set(Cairo_PROCESS_INCLUDES Cairo_INCLUDE_DIR Freetype_INCLUDE_DIRS)
36 set(Cairo_PROCESS_LIBS Cairo_LIBRARY Freetype_LIBRARIES)
37 libfind_process(Cairo)
39 IF (Cairo_FOUND)
41 #### check if cairo works
43 SET(CMAKE_REQUIRED_FLAGS ${CAIRO_CFLAGS} ${CAIRO_CFLAGS_OTHERS})
44 SET(CMAKE_REQUIRED_INCLUDES ${Cairo_INCLUDE_DIRS})
45 SET(CMAKE_REQUIRED_LIBRARIES ${Cairo_LIBRARIES})
46 #SET(CMAKE_REQUIRED_LIBDIRS ${CAIRO_LIBRARY_DIRS})
49 CHECK_C_SOURCE_COMPILES(  "#include <cairo.h>
50    void main() {
51     cairo_surface_t *surface;
52     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);
53    }" _cairo_works)
55 IF(_cairo_works)
56   MESSAGE(STATUS "Cairo works")
57 ELSE(_cairo_works)
58   MESSAGE(WARNING "Cairo is not working properly: disabling")  
59   SET(Cairo_FOUND NO)
60 ENDIF(_cairo_works)
62 ENDIF (Cairo_FOUND)