summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2010-03-07 16:00:03 +0100
committerPino Toscano <pino@kde.org>2010-03-07 16:00:03 +0100
commitbcaf62b8e252594530d3050761ba563cf3b1fb6e (patch)
tree9f1806a3b2541aa647928e3db29e5143098bafb0 /cmake
parentc96aa0f5fc74ae04f483485b787aaf65f1791991 (diff)
[CMake] enhance/rewrite a bit the FindCairo module
make use of some features of CMake 2.6 (as we require it): - newer pkg-config handling (aka pkg_check_modules()) - version checking for modules (PACKAGE_FIND_VERSION*) - find_package_handle_standard_args() also, after the pkg-config search to win32, search for cairo again (double-check plus real search for win32) furthermore, introduce CAIRO_INCLUDE_DIRS with the include paths requires (kind of "obsoletes" CAIRO_CFLAGS, left there in case it is used again) apply the changes to the rest of the build system (specify the version needed, use the correct variable for includes)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindCairo.cmake64
1 files changed, 41 insertions, 23 deletions
diff --git a/cmake/modules/FindCairo.cmake b/cmake/modules/FindCairo.cmake
index a0a8400d..e3b65ec7 100644
--- a/cmake/modules/FindCairo.cmake
+++ b/cmake/modules/FindCairo.cmake
@@ -3,42 +3,60 @@
#
# CAIRO_FOUND - system has Cairo
# CAIRO_CFLAGS - the Cairo CFlags
+# CAIRO_INCLUDE_DIRS - the Cairo include directories
# CAIRO_LIBRARIES - Link these to use Cairo
#
-# Copyright (c) 2007, Pino Toscano, <pino@kde.org>
+# Copyright (C) 2007, 2010, Pino Toscano, <pino@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-if (NOT WIN32)
- include(UsePkgConfig)
-
- pkgconfig(cairo _LibCairoIncDir _LibCairoLinkDir _CairoLinkFlags _CairoCflags)
- set (CAIRO_FOUND FALSE)
- if (_LibCairoIncDir)
+if(CAIRO_INCLUDE_DIRS AND CAIRO_LIBRARIES)
+
+ # in cache already
+ set(CAIRO_FOUND TRUE)
+
+else(CAIRO_INCLUDE_DIRS AND CAIRO_LIBRARIES)
+
+if(NOT WIN32)
+ # use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ include(FindPkgConfig)
+ if(PACKAGE_FIND_VERSION_COUNT GREATER 0)
+ set(_cairo_version_cmp ">=${PACKAGE_FIND_VERSION}")
+ endif(PACKAGE_FIND_VERSION_COUNT GREATER 0)
+ pkg_check_modules(_pc_cairo cairo${_cairo_version_cmp})
+ if(_pc_cairo_FOUND)
+ set(CAIRO_FOUND TRUE)
+ endif(_pc_cairo_FOUND)
+else(NOT WIN32)
+ # assume so, for now
+ set(CAIRO_FOUND TRUE)
+endif(NOT WIN32)
- if (CAIRO_VERSION)
+if(CAIRO_FOUND)
+ # set it back as false
+ set(CAIRO_FOUND FALSE)
- exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=${CAIRO_VERSION} cairo RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
- if(_return_VALUE STREQUAL "0")
- set (CAIRO_CFLAGS ${_CairoCflags})
- set (CAIRO_LIBRARIES ${_CairoLinkFlags})
- endif(_return_VALUE STREQUAL "0")
+ find_library(CAIRO_LIBRARY cairo
+ HINTS ${_pc_cairo_LIBRARY_DIRS}
+ )
+ set(CAIRO_LIBRARIES "${CAIRO_LIBRARY}")
- else (CAIRO_VERSION)
- set (CAIRO_CFLAGS ${_CairoCflags})
- set (CAIRO_LIBRARIES ${_CairoLinkFlags})
- endif (CAIRO_VERSION)
+ find_path(CAIRO_INCLUDE_DIR cairo.h
+ HINTS ${_pc_cairo_INCLUDE_DIRS}
+ PATH_SUFFIXES cairo
+ )
+ set(CAIRO_INCLUDE_DIRS "${CAIRO_INCLUDE_DIR}")
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(Cairo DEFAULT_MSG CAIRO_LIBRARIES CAIRO_CFLAGS)
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Cairo DEFAULT_MSG CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS)
+endif(CAIRO_FOUND)
- endif (_LibCairoIncDir)
-
-endif(NOT WIN32)
+endif(CAIRO_INCLUDE_DIRS AND CAIRO_LIBRARIES)
mark_as_advanced(
CAIRO_CFLAGS
+ CAIRO_INCLUDE_DIRS
CAIRO_LIBRARIES
)
-