summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2019-02-09 13:44:44 -0500
committerMike Frysinger <vapier@gentoo.org>2019-02-09 13:55:44 -0500
commite0cb1b76c305db68b251fe782faa12da5d357593 (patch)
treef7d18c3cc05ca01c67f168e9cd2b939dd55b398b /cmake
parenteaa28204bdb8e1b4e461346c12109bcf8375b892 (diff)
downloadlibgd-e0cb1b76c305db68b251fe782faa12da5d357593.tar.gz
cmake: update FindFreetype module
This pulls some fixes from upstream cmake.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindFreetype.cmake144
1 files changed, 93 insertions, 51 deletions
diff --git a/cmake/modules/FindFreetype.cmake b/cmake/modules/FindFreetype.cmake
index e8e3bc4..e592340 100644
--- a/cmake/modules/FindFreetype.cmake
+++ b/cmake/modules/FindFreetype.cmake
@@ -1,16 +1,25 @@
-# - Locate FreeType library
+#.rst:
+# FindFreetype
+# ------------
+#
+# Locate FreeType library
+#
# This module defines
-# FREETYPE_LIBRARIES, the library to link against
-# FREETYPE_FOUND, if false, do not try to link to FREETYPE
-# FREETYPE_INCLUDE_DIRS, where to find headers.
-# FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8)
-# This is the concatenation of the paths:
-# FREETYPE_INCLUDE_DIR_ft2build
-# FREETYPE_INCLUDE_DIR_freetype2
#
-# $FREETYPE_DIR is an environment variable that would
-# correspond to the ./configure --prefix=$FREETYPE_DIR
-# used in building FREETYPE.
+# ::
+#
+# FREETYPE_LIBRARIES, the library to link against
+# FREETYPE_FOUND, if false, do not try to link to FREETYPE
+# FREETYPE_INCLUDE_DIRS, where to find headers.
+# FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8)
+# This is the concatenation of the paths:
+# FREETYPE_INCLUDE_DIR_ft2build
+# FREETYPE_INCLUDE_DIR_freetype2
+#
+#
+#
+# $FREETYPE_DIR is an environment variable that would correspond to the
+# ./configure --prefix=$FREETYPE_DIR used in building FREETYPE.
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
@@ -59,70 +68,103 @@
# wants explicit full paths and this trickery doesn't work too well.
# I'm going to attempt to cut out the middleman and hope
# everything still works.
-find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
+
+set(FREETYPE_FIND_ARGS
HINTS
ENV FREETYPE_DIR
PATHS
+ /usr/X11R6
/usr/local/X11R6
/usr/local/X11
/usr/freeware
- PATH_SUFFIXES include/freetype2 include
+ ENV GTKMM_BASEPATH
+ [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
)
-find_path(FREETYPE_INCLUDE_DIR_freetype2 config/ftheader.h
- HINTS
- ENV FREETYPE_DIR
- PATHS
- /usr/local/X11R6
- /usr/local/X11
- /usr/freeware
- PATH_SUFFIXES include/freetype2 include
+find_path(
+ FREETYPE_INCLUDE_DIR_ft2build
+ ft2build.h
+ ${FREETYPE_FIND_ARGS}
+ PATH_SUFFIXES
+ include/freetype2
+ include
+ freetype2
+)
+
+find_path(
+ FREETYPE_INCLUDE_DIR_freetype2
+ NAMES
+ freetype/config/ftheader.h
+ config/ftheader.h
+ ${FREETYPE_FIND_ARGS}
+ PATH_SUFFIXES
+ include/freetype2
+ include
+ freetype2
)
find_library(FREETYPE_LIBRARY
- NAMES freetype libfreetype freetype219 freetype_a
- HINTS
- ENV FREETYPE_DIR
- PATH_SUFFIXES lib
- PATHS
- /usr/local/X11R6
- /usr/local/X11
- /usr/freeware
+ NAMES
+ freetype
+ libfreetype
+ freetype219
+ ${FREETYPE_FIND_ARGS}
+ PATH_SUFFIXES
+ lib
)
+unset(FREETYPE_FIND_ARGS)
+
# set the user variables
if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
+ list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIRS)
endif()
set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
-if(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
- file(STRINGS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h" freetype_version_str
- REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
-
- unset(FREETYPE_VERSION_STRING)
- foreach(VPART MAJOR MINOR PATCH)
- foreach(VLINE ${freetype_version_str})
- if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}")
- string(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1"
- FREETYPE_VERSION_PART "${VLINE}")
- if(FREETYPE_VERSION_STRING)
- set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
- else()
- set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
- endif()
- unset(FREETYPE_VERSION_PART)
- endif()
- endforeach()
+if(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
+ set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
+elseif(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h")
+ set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h")
+endif()
+
+if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H)
+ file(STRINGS "${FREETYPE_H}" freetype_version_str
+ REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
+
+ unset(FREETYPE_VERSION_STRING)
+ foreach(VPART MAJOR MINOR PATCH)
+ foreach(VLINE ${freetype_version_str})
+ if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$")
+ set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}")
+ if(FREETYPE_VERSION_STRING)
+ set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
+ else()
+ set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
+ endif()
+ unset(FREETYPE_VERSION_PART)
+ endif()
endforeach()
+ endforeach()
endif()
# handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype
- REQUIRED_VARS FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS
- VERSION_VAR FREETYPE_VERSION_STRING)
-mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)
+find_package_handle_standard_args(
+ Freetype
+ REQUIRED_VARS
+ FREETYPE_LIBRARY
+ FREETYPE_INCLUDE_DIRS
+ VERSION_VAR
+ FREETYPE_VERSION_STRING
+)
+
+mark_as_advanced(
+ FREETYPE_LIBRARY
+ FREETYPE_INCLUDE_DIR_freetype2
+ FREETYPE_INCLUDE_DIR_ft2build
+)