1 # - Try to find the CAIRO library
2 # Once done this will define
4 # CAIRO_ROOT_DIR - Set this variable to the root installation of CAIRO
7 # CAIRO_FOUND - system has the CAIRO library
8 # CAIRO_INCLUDE_DIR - the CAIRO include directory
9 # CAIRO_LIBRARIES - The libraries needed to use CAIRO
10 # CAIRO_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8)
12 #=============================================================================
13 # Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru>
15 # Distributed under the OSI-approved BSD License (the "License");
16 # see accompanying file Copyright.txt for details.
18 # This software is distributed WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # See the License for more information.
21 #=============================================================================
22 # (To distribute this file outside of CMake, substitute the full
23 # License text for the above reference.)
25 find_package(PkgConfig)
28 pkg_check_modules(_CAIRO cairo)
29 endif (PKG_CONFIG_FOUND)
40 SET(_CAIRO_ROOT_HINTS_AND_PATHS
41 HINTS ${_CAIRO_ROOT_HINTS}
42 PATHS ${_CAIRO_ROOT_PATHS}
45 FIND_PATH(CAIRO_INCLUDE_DIR
50 ${_CAIRO_ROOT_HINTS_AND_PATHS}
56 IF(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN)
57 # MINGW should go here too
59 # Implementation details:
60 # We are using the libraries located in the VC subdir instead of the parent directory eventhough :
61 FIND_LIBRARY(CAIRO_DEBUG
64 ${_CAIRO_ROOT_HINTS_AND_PATHS}
71 FIND_LIBRARY(CAIRO_RELEASE
74 ${_CAIRO_ROOT_HINTS_AND_PATHS}
81 if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
83 set(CAIRO_DEBUG ${CAIRO_RELEASE})
84 endif(NOT CAIRO_DEBUG)
86 optimized ${CAIRO_RELEASE} debug ${CAIRO_DEBUG}
89 set( CAIRO_LIBRARIES ${CAIRO_RELEASE})
91 MARK_AS_ADVANCED(CAIRO_DEBUG CAIRO_RELEASE)
93 # same player, for MingW
97 ${_CAIRO_ROOT_HINTS_AND_PATHS}
103 MARK_AS_ADVANCED(CAIRO)
104 set( CAIRO_LIBRARIES ${CAIRO})
106 # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
112 ${_CAIRO_ROOT_HINTS_AND_PATHS}
117 MARK_AS_ADVANCED(CAIRO)
118 set( CAIRO_LIBRARIES ${CAIRO} )
122 FIND_LIBRARY(CAIRO_LIBRARY
127 ${_CAIRO_ROOT_HINTS_AND_PATHS}
133 MARK_AS_ADVANCED(CAIRO_LIBRARY)
136 SET(CAIRO_LIBRARIES ${CAIRO_LIBRARY})
140 #message( STATUS "Cairo_FIND_VERSION=${Cairo_FIND_VERSION}.")
141 #message( STATUS "CAIRO_INCLUDE_DIR=${CAIRO_INCLUDE_DIR}.")
143 # Fetch version from cairo-version.h if a version was requested by find_package()
144 if(CAIRO_INCLUDE_DIR AND Cairo_FIND_VERSION)
145 file(READ "${CAIRO_INCLUDE_DIR}/cairo-version.h" _CAIRO_VERSION_H_CONTENTS)
146 string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*"
147 "\\2" CAIRO_VERSION_MAJOR ${_CAIRO_VERSION_H_CONTENTS})
148 string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*"
149 "\\2" CAIRO_VERSION_MINOR ${_CAIRO_VERSION_H_CONTENTS})
150 string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*"
151 "\\2" CAIRO_VERSION_MICRO ${_CAIRO_VERSION_H_CONTENTS})
152 set(CAIRO_VERSION ${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}
153 CACHE INTERNAL "The version number for Cairo libraries")
156 include(FindPackageHandleStandardArgs)
158 find_package_handle_standard_args(Cairo
166 MARK_AS_ADVANCED(CAIRO_INCLUDE_DIR CAIRO_LIBRARIES)