[cmake-developers] FindFreetype patch for Windows debug lib naming

Stuart Mentzer Stuart_Mentzer at objexx.com
Wed Jun 8 00:33:43 EDT 2016


Hello,

Here is a little patch that lets FindFreetype find the debug library on Windows, where it is named with a d suffix.

Much thanks to Rolf Eike Beer for help on this.

Cheers,
Stuart
-------------- next part --------------
From 93576b26f52017eb9b60705c123be1956a512a77 Mon Sep 17 00:00:00 2001
From: Stuart Mentzer <Stuart_Mentzer at objexx.com>
Date: Wed, 8 Jun 2016 00:26:31 -0400
Subject: [PATCH] FindFreetype updates for debug library name on Windows with d
 suffix

---
 Help/release/dev/FindFreetype-debug-libs.rst |  5 +++
 Modules/FindFreetype.cmake                   | 47 ++++++++++++++--------------
 2 files changed, 29 insertions(+), 23 deletions(-)
 create mode 100644 Help/release/dev/FindFreetype-debug-libs.rst

diff --git a/Help/release/dev/FindFreetype-debug-libs.rst b/Help/release/dev/FindFreetype-debug-libs.rst
new file mode 100644
index 0000000..2637fb0
--- /dev/null
+++ b/Help/release/dev/FindFreetype-debug-libs.rst
@@ -0,0 +1,5 @@
+FindFreetype-debug-libs
+--------------------------
+
+* The :module:`FindFreetype` module now finds the debug library on
+Windows where it is named with a d suffix.
diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake
index 7d46d15..9db34d5 100644
--- a/Modules/FindFreetype.cmake
+++ b/Modules/FindFreetype.cmake
@@ -51,9 +51,8 @@
 # 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
@@ -64,6 +63,12 @@ find_path(
     ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
+)
+
+find_path(
+  FREETYPE_INCLUDE_DIR_ft2build
+  ft2build.h
+  ${FREETYPE_FIND_ARGS}
   PATH_SUFFIXES
     include/freetype2
     include
@@ -75,16 +80,7 @@ find_path(
   NAMES
     freetype/config/ftheader.h
     config/ftheader.h
-  HINTS
-    ENV FREETYPE_DIR
-  PATHS
-    /usr/X11R6
-    /usr/local/X11R6
-    /usr/local/X11
-    /usr/freeware
-    ENV GTKMM_BASEPATH
-    [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
+  ${FREETYPE_FIND_ARGS}
   PATH_SUFFIXES
     include/freetype2
     include
@@ -96,19 +92,23 @@ find_library(FREETYPE_LIBRARY
     freetype
     libfreetype
     freetype219
-  HINTS
-    ENV FREETYPE_DIR
-  PATHS
-    /usr/X11R6
-    /usr/local/X11R6
-    /usr/local/X11
-    /usr/freeware
-    ENV GTKMM_BASEPATH
-    [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
+  ${FREETYPE_FIND_ARGS}
+  PATH_SUFFIXES
+    lib
+)
+find_library(FREETYPE_LIBRARY_DEBUG
+  NAMES
+    freetyped
+    libfreetyped
+    freetype219d
+  ${FREETYPE_FIND_ARGS}
   PATH_SUFFIXES
     lib
 )
+include(SelectLibraryConfigurations)
+select_library_configurations(FREETYPE)
+
+unset(FREETYPE_FIND_ARGS)
 
 # set the user variables
 if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
@@ -159,6 +159,7 @@ find_package_handle_standard_args(
 
 mark_as_advanced(
   FREETYPE_LIBRARY
+  FREETYPE_LIBRARY_DEBUG
   FREETYPE_INCLUDE_DIR_freetype2
   FREETYPE_INCLUDE_DIR_ft2build
 )
-- 
2.8.3.windows.1



More information about the cmake-developers mailing list