Continued and tested on CMake 2.8.12.
>From d7f090759a0389ef9da2bcce684c30ff0e35e38e Mon Sep 17 00:00:00 2001
From: Nikolaus Waxweiler <[email protected]>
Date: Sun, 8 Apr 2018 01:29:28 +0100
Subject: [PATCH 1/3] FindHarfBuzz.cmake: Make work on CMake 2.8.12; export
 library on >= 3.1

Modern CMake Find* files export a library that targets can be simply
linked against without messing with definitions, include directories,
etc. Make such a library available in CMake >= 3.1 should we switch to
it one day.
---
 builds/cmake/FindHarfBuzz.cmake | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/builds/cmake/FindHarfBuzz.cmake b/builds/cmake/FindHarfBuzz.cmake
index c8444d325..96ecfd9a2 100644
--- a/builds/cmake/FindHarfBuzz.cmake
+++ b/builds/cmake/FindHarfBuzz.cmake
@@ -54,16 +54,28 @@ if (HARFBUZZ_INCLUDE_DIRS)
     endif ()
 endif ()
 
-if ("${Harfbuzz_FIND_VERSION}" VERSION_GREATER "${HARFBUZZ_VERSION}")
+if ("${harfbuzz_FIND_VERSION}" VERSION_GREATER "${HARFBUZZ_VERSION}")
     message(FATAL_ERROR "Required version (" ${Harfbuzz_FIND_VERSION} ") is higher than found version (" ${CAIRO_VERSION} ")")
 endif ()
 
 include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Harfbuzz REQUIRED_VARS HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES
-                                           VERSION_VAR HARFBUZZ_VERSION)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+    harfbuzz 
+        REQUIRED_VARS HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES
+        VERSION_VAR HARFBUZZ_VERSION)
 
 mark_as_advanced(
     HARFBUZZ_INCLUDE_DIRS
     HARFBUZZ_LIBRARIES
-    HARFBUZZ_ICU_LIBRARIES
 )
+
+# Allows easy linking as in 
+#   target_link_libraries(freetype PRIVATE Harfbuzz::Harfbuzz)
+if (NOT CMAKE_VERSION VERSION_LESS 3.1)
+    if (HARFBUZZ_FOUND AND NOT TARGET Harfbuzz::Harfbuzz)
+        add_library(Harfbuzz::Harfbuzz INTERFACE IMPORTED)
+        set_target_properties(
+            Harfbuzz::Harfbuzz PROPERTIES
+                INTERFACE_INCLUDE_DIRECTORIES "${HARFBUZZ_INCLUDE_DIRS}")
+    endif ()
+endif ()
-- 
2.14.3

>From 06501fad9fa6fb94e869c8ae72d22492d7ba2c1c Mon Sep 17 00:00:00 2001
From: Nikolaus Waxweiler <[email protected]>
Date: Sun, 8 Apr 2018 01:30:04 +0100
Subject: [PATCH 2/3] CMakeLists.txt: Remove package_source reference

We removed source packaging.
---
 CMakeLists.txt | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63caaac7e..1503551a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,10 +47,6 @@
 #
 #   cmake --build build --config Release --target package
 #
-# A source distribution can be made with
-#
-#   cmake --build build --target package_source
-#
 # Please refer to the cmake manual for further options, in particular, how
 # to modify compilation and linking parameters.
 #
-- 
2.14.3

>From e427681d95d99701ef67c65ea0216eaeef30e807 Mon Sep 17 00:00:00 2001
From: Nikolaus Waxweiler <[email protected]>
Date: Sun, 8 Apr 2018 01:33:44 +0100
Subject: [PATCH 3/3] CMakeLists.txt: Raise minimum version to 2.8.12

The first version to support the  C_VISIBILITY_HIDDEN property.
Necessary for a shared object that only exports explicitly marked APIs.
CMake >= 3.3 will also allow to set the property on static builds.

Minor clean-up of target_link_libraries() as 2.8.12 allows PRIVATE.

Minor clean-up of target_include_directories() as 2.8.12 allows the
INSTALL_INTERFACE generator expression.
---
 CMakeLists.txt | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1503551a9..0470168e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,14 +79,16 @@
 #   (this is compatible with the same CMake variables in zlib's CMake
 #   support).
 
-# FreeType is build as part of the Python binding freetype-py. Python
-# extensions for Linux are usually compiled against the manylinux1 target (PEP
-# 513); the Manylinux1 Docker container provided by PyPa happens to contain a
-# CentOS 5.11 with cmake 2.8.11.2 installed. Raising the minimum version makes
-# sure this requirement is actually tested.
-cmake_minimum_required(VERSION 2.8.11.2)
-# Allow symbol visibility settings also on static libraries.
-cmake_policy(SET CMP0063 NEW)
+# FreeType explicitly marks the API to be exported and relies on the compiler
+# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
+# starting with 2.8.12.
+cmake_minimum_required(VERSION 2.8.12)
+
+if (NOT CMAKE_VERSION VERSION_LESS 3.3)
+  # Allow symbol visibility settings also on static libraries. CMake < 3.3
+  # only sets the propery on a shared library build.
+  cmake_policy(SET CMP0063 NEW)
+endif ()
 
 include(CheckIncludeFile)
 
@@ -345,6 +347,9 @@ target_include_directories(
   freetype
     PRIVATE "${PROJECT_SOURCE_DIR}/include")
 
+target_include_directories(
+  freetype
+    PUBLIC $<INSTALL_INTERFACE:include/freetype2>)
 
 if (BUILD_FRAMEWORK)
   set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
@@ -358,32 +363,22 @@ if (BUILD_FRAMEWORK)
   )
 endif ()
 
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
-  target_include_directories(freetype
-    PUBLIC $<INSTALL_INTERFACE:include/freetype2>)
-endif ()
-
-if (CMAKE_VERSION VERSION_LESS 2.8.12)
-  set(MAYBE_PRIVATE "")
-else ()
-  set(MAYBE_PRIVATE "PRIVATE")
-endif ()
 
 if (ZLIB_FOUND)
-  target_link_libraries(freetype ${MAYBE_PRIVATE} ${ZLIB_LIBRARIES})
+  target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
   target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
 endif ()
 if (BZIP2_FOUND)
-  target_link_libraries(freetype ${MAYBE_PRIVATE} ${BZIP2_LIBRARIES})
+  target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
   target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
 endif ()
 if (PNG_FOUND)
-  add_definitions(${PNG_DEFINITIONS})
-  target_link_libraries(freetype ${MAYBE_PRIVATE} ${PNG_LIBRARIES})
+  target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
+  target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
   target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
 endif ()
 if (HARFBUZZ_FOUND)
-  target_link_libraries(freetype ${MAYBE_PRIVATE} ${HARFBUZZ_LIBRARIES})
+  target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES})
   target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
 endif ()
 
-- 
2.14.3

_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to