aboutsummaryrefslogtreecommitdiff
path: root/modules/FindFreetype.cmake
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2011-06-28 17:13:05 -0400
committerAllen Winter <allen.winter@kdab.com>2011-06-28 17:13:05 -0400
commite15ffacc69242c89107afbfda6f8ece9f2b56633 (patch)
tree34bed177321c49f883d9d75616947a18f38c037f /modules/FindFreetype.cmake
parent5c79bed7250cb2f854bfb4f20e4d266925d94b54 (diff)
parentc06badd8d431583071cad638fea082ca0776a0a3 (diff)
downloadextra-cmake-modules-e15ffacc69242c89107afbfda6f8ece9f2b56633.tar.gz
extra-cmake-modules-e15ffacc69242c89107afbfda6f8ece9f2b56633.tar.bz2
Merge branch 'allen' of /data/kde/trunk/KDE/kdelibs
Diffstat (limited to 'modules/FindFreetype.cmake')
-rw-r--r--modules/FindFreetype.cmake73
1 files changed, 73 insertions, 0 deletions
diff --git a/modules/FindFreetype.cmake b/modules/FindFreetype.cmake
new file mode 100644
index 00000000..61e44a1f
--- /dev/null
+++ b/modules/FindFreetype.cmake
@@ -0,0 +1,73 @@
+# - Try to find the freetype library
+# Once done this will define
+#
+# FREETYPE_FOUND - system has Freetype
+# FREETYPE_INCLUDE_DIRS - the FREETYPE include directories
+# FREETYPE_LIBRARIES - Link these to use FREETYPE
+# FREETYPE_INCLUDE_DIR - internal
+
+# Copyright (c) 2006, Laurent Montel, <montel@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 (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIR)
+
+ # in cache already
+ set(FREETYPE_FOUND TRUE)
+
+else (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIR)
+
+ find_program(FREETYPECONFIG_EXECUTABLE NAMES freetype-config PATHS
+ /opt/local/bin
+ )
+
+ #reset vars
+ set(FREETYPE_LIBRARIES)
+ set(FREETYPE_INCLUDE_DIR)
+
+ # if freetype-config has been found
+ if(FREETYPECONFIG_EXECUTABLE)
+
+ exec_program(${FREETYPECONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE FREETYPE_LIBRARIES)
+
+ exec_program(${FREETYPECONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _freetype_pkgconfig_output)
+ if(FREETYPE_LIBRARIES AND _freetype_pkgconfig_output)
+ set(FREETYPE_FOUND TRUE)
+
+ # freetype-config can print out more than one -I, so we need to chop it up
+ # into a list and process each entry separately
+ separate_arguments(_freetype_pkgconfig_output)
+ foreach(value ${_freetype_pkgconfig_output})
+ string(REGEX REPLACE "-I(.+)" "\\1" value "${value}")
+ set(FREETYPE_INCLUDE_DIR ${FREETYPE_INCLUDE_DIR} ${value})
+ endforeach(value)
+ endif(FREETYPE_LIBRARIES AND _freetype_pkgconfig_output)
+
+ set( FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} )
+
+ mark_as_advanced(FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIR)
+
+ else(FREETYPECONFIG_EXECUTABLE)
+ find_path (FREETYPE_INCLUDE_DIR freetype/freetype.h PATH_SUFFIXES freetype2)
+ find_library(FREETYPE_LIBRARIES freetype)
+ if(FREETYPE_INCLUDE_DIR AND FREETYPE_LIBRARIES)
+ set(FREETYPE_FOUND TRUE)
+ endif(FREETYPE_INCLUDE_DIR AND FREETYPE_LIBRARIES)
+ endif(FREETYPECONFIG_EXECUTABLE)
+
+
+ if (FREETYPE_FOUND)
+ if (NOT Freetype_FIND_QUIETLY)
+ message(STATUS "Found Freetype: ${FREETYPE_LIBRARIES}")
+ endif (NOT Freetype_FIND_QUIETLY)
+ else (FREETYPE_FOUND)
+ if (Freetype_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find FreeType library")
+ endif (Freetype_FIND_REQUIRED)
+ endif (FREETYPE_FOUND)
+
+endif (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIR)
+
+set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR}")