Still missing: pkg-config file Alexei: What's that ftver.rc file even for? Is it needed?
>From 428af497d42d3d34c85c4b04dda250f983b55bec Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:34:24 +0100 Subject: [PATCH 01/19] Add build/ to .gitignore
Used in the CMake invocation examples. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b5db9d874..a47f568e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.mk objs/vc2010/ +build -- 2.14.3
>From f87f9ed99129db26c6dcad6677bd417bcf1c82af Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:35:10 +0100 Subject: [PATCH 02/19] Update FindHarfBuzz.cmake: Do not look for and link against icu library --- builds/cmake/FindHarfBuzz.cmake | 45 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/builds/cmake/FindHarfBuzz.cmake b/builds/cmake/FindHarfBuzz.cmake index f394b82bf..c8444d325 100644 --- a/builds/cmake/FindHarfBuzz.cmake +++ b/builds/cmake/FindHarfBuzz.cmake @@ -31,42 +31,39 @@ # HARFBUZZ_LIBRARIES - containg the HarfBuzz library include(FindPkgConfig) +pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz) -pkg_check_modules(PC_HARFBUZZ harfbuzz>=0.9.7) - -find_path(HARFBUZZ_INCLUDE_DIRS NAMES hb.h - HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR} +find_path(HARFBUZZ_INCLUDE_DIRS + NAMES hb.h + HINTS ${PC_HARFBUZZ_INCLUDEDIR} + ${PC_HARFBUZZ_INCLUDE_DIRS} + PATH_SUFFIXES harfbuzz ) find_library(HARFBUZZ_LIBRARIES NAMES harfbuzz - HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR} + HINTS ${PC_HARFBUZZ_LIBDIR} + ${PC_HARFBUZZ_LIBRARY_DIRS} ) -# HarfBuzz 0.9.18 split ICU support into a separate harfbuzz-icu library. -if ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "0.9.17") - if (HarfBuzz_FIND_REQUIRED) - set(_HARFBUZZ_REQUIRED REQUIRED) - else () - set(_HARFBUZZ_REQUIRED "") - endif () - pkg_check_modules(PC_HARFBUZZ_ICU harfbuzz-icu>=0.9.18 ${_HARFBUZZ_REQUIRED}) - find_library(HARFBUZZ_ICU_LIBRARIES NAMES harfbuzz-icu - HINTS ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} ${PC_HARFBUZZ_ICU_LIBDIR} - ) - if (HARFBUZZ_ICU_LIBRARIES) - list(APPEND HARFBUZZ_LIBRARIES "${HARFBUZZ_ICU_LIBRARIES}") +if (HARFBUZZ_INCLUDE_DIRS) + if (EXISTS "${HARFBUZZ_INCLUDE_DIRS}/hb-version.h") + file(READ "${HARFBUZZ_INCLUDE_DIRS}/hb-version.h" _harfbuzz_version_content) + + string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\\.[0-9]+\\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}") + set(HARFBUZZ_VERSION "${CMAKE_MATCH_1}") endif () - set(_HARFBUZZ_EXTRA_REQUIRED_VAR "HARFBUZZ_ICU_LIBRARIES") -else () - set(_HARFBUZZ_EXTRA_REQUIRED_VAR "") +endif () + +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 DEFAULT_MSG HARFBUZZ_INCLUDE_DIRS - HARFBUZZ_LIBRARIES ${_HARFBUZZ_EXTRA_REQUIRED_VAR}) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Harfbuzz REQUIRED_VARS HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES + VERSION_VAR HARFBUZZ_VERSION) mark_as_advanced( - HARFBUZZ_ICU_LIBRARIES HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES + HARFBUZZ_ICU_LIBRARIES ) -- 2.14.3
>From a411396242fb000334eb136ac30397811f69721a Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:36:44 +0100 Subject: [PATCH 03/19] CMakeLists: Update invocation examples Use platform- and build system agnostic examples for configuration and building. --- CMakeLists.txt | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32006d3c7..901e3b5bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,35 +12,44 @@ # fully. # # -# As a preliminary, create a compilation directory and change into it, for -# example +# The following will 1. create a build directory and 2. change into it and +# call cmake to configure the build with default parameters as a static +# library. # -# mkdir ~/freetype2.compiled -# cd ~/freetype2.compiled -# -# Now you can say -# -# cmake <path-to-freetype2-src-dir> -# -# to create a Makefile that builds a static version of the library. +# cmake -E make_directory build +# cmake -E chdir build cmake .. # # For a dynamic library, use # -# cmake -D BUILD_SHARED_LIBS:BOOL=true <path-to-freetype2-src-dir> +# cmake -E chdir build cmake -D BUILD_SHARED_LIBS:BOOL=true .. # # For a framework on OS X, use # -# cmake -D BUILD_FRAMEWORK:BOOL=true -G Xcode <path-to-freetype2-src-dir> -# -# instead. +# cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true .. # # For an iOS static library, use # -# cmake -D IOS_PLATFORM=OS -G Xcode <path-to-freetype2-src-dir> +# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=OS .. # # or # -# cmake -D IOS_PLATFORM=SIMULATOR -G Xcode <path-to-freetype2-src-dir> +# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR .. +# +# Finally, build the project with: +# +# cmake --build build +# +# Install it with +# +# (sudo) cmake --build build --target install +# +# A binary distribution can be made with +# +# 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 cb9f85e6063f4eddcb5c441f9f70cc00f349d8f0 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:37:41 +0100 Subject: [PATCH 04/19] CMakeLists.txt: Declare FreeType a C project This makes CMake not look for a C++ compiler. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 901e3b5bb..0206cab95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,7 @@ else () endif () -project(freetype) +project(freetype C) # Disallow in-source builds -- 2.14.3
>From 1423c462a7ee3a2490bc18fdc2088b0905ca0a23 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:42:43 +0100 Subject: [PATCH 05/19] CMakeLists.txt: Raise minimum required CMake version to 2.8.11.2 FreeType will be built as part of the freetype-py bindings to provide binaries to Python users. The Linux build will be done inside a CentOS 5.11 container with CMake 2.8.11.2 installed, so it's the version that will actually be exercised. --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0206cab95..8ef0fc947 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,9 +83,12 @@ # (this is compatible with the same CMake variables in zlib's CMake # support). - -cmake_minimum_required(VERSION 2.6) - +# 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) include(CheckIncludeFile) -- 2.14.3
>From cbf549f2042293c8e87fef906e6423d2871bc5b4 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:48:17 +0100 Subject: [PATCH 06/19] CMakeLists.txt: hide symbols by default for static and shared builds FreeType explicitly marks functions to export. This change mimics the Autotools build where a symbol list is generated and used. Due to the old CMake version required, a policy override has to be set. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ef0fc947..00d8916f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,10 +89,11 @@ # 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) include(CheckIncludeFile) - # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which # configures the base build environment and references the toolchain file if (APPLE) @@ -352,6 +353,10 @@ add_library(freetype ${BASE_SRCS} ) +set_target_properties( + freetype PROPERTIES + C_VISIBILITY_PRESET hidden) + if (BUILD_SHARED_LIBS) set_target_properties(freetype PROPERTIES -- 2.14.3
>From bea6c9a47bcb2a0bf85372f2cb69c271d908b087 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:54:45 +0100 Subject: [PATCH 07/19] CMakeLists.txt: Remove -Dfreetype_EXPORTS This did nothing. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00d8916f8..f27010e3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -362,7 +362,6 @@ if (BUILD_SHARED_LIBS) set_target_properties(freetype PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} - COMPILE_DEFINITIONS freetype_EXPORTS ) endif () -- 2.14.3
>From fcd9db900df23880926ba3d6bc07459198af3514 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:55:32 +0100 Subject: [PATCH 08/19] CMakeLists.txt: Explicitly set library and .so version Cribbed from the libssh CMakeLists.txt. --- CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f27010e3f..f5c2a4198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,17 @@ endif () project(freetype C) +# SOVERSION scheme: CURRENT.AGE.REVISION +# If there was an incompatible interface change: +# Increment CURRENT. Set AGE and REVISION to 0 +# If there was a compatible interface change: +# Increment AGE. Set REVISION to 0 +# If the source code was changed, but there were no interface changes: +# Increment REVISION. +set(LIBRARY_VERSION "6.16.0") +set(LIBRARY_SOVERSION "6") + + # Disallow in-source builds if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") message(FATAL_ERROR @@ -165,10 +176,6 @@ set(VERSION_MAJOR "2") set(VERSION_MINOR "9") set(VERSION_PATCH "0") -set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) -set(SHARED_LIBRARY_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) - - # Compiler definitions for building the library add_definitions(-DFT2_BUILD_LIBRARY) if (WIN32) @@ -360,9 +367,8 @@ set_target_properties( if (BUILD_SHARED_LIBS) set_target_properties(freetype PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${SHARED_LIBRARY_VERSION} - ) + VERSION ${LIBRARY_VERSION} + SOVERSION ${LIBRARY_SOVERSION}) endif () -- 2.14.3
>From 022a90efa56ed1dd6318d91cc958840c27d36ada Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:57:13 +0100 Subject: [PATCH 09/19] CMakeLists.txt: Cosmetic, move version declaration up. --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5c2a4198..0debc9496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,9 @@ endif () project(freetype C) +set(VERSION_MAJOR "2") +set(VERSION_MINOR "9") +set(VERSION_PATCH "0") # SOVERSION scheme: CURRENT.AGE.REVISION # If there was an incompatible interface change: @@ -172,10 +175,6 @@ if (BUILD_FRAMEWORK) endif () -set(VERSION_MAJOR "2") -set(VERSION_MINOR "9") -set(VERSION_PATCH "0") - # Compiler definitions for building the library add_definitions(-DFT2_BUILD_LIBRARY) if (WIN32) -- 2.14.3
>From 7a70b6908e353a461b826e43aa899188f29d95d5 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 21:59:42 +0100 Subject: [PATCH 10/19] CMakeLists.txt: Update build-elsewhere msg with `cmake` commands. CMake comes with system-agnostic commands for common command line build managment tasks. --- CMakeLists.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0debc9496..d1171e53a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,15 +149,13 @@ set(LIBRARY_SOVERSION "6") # Disallow in-source builds if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") message(FATAL_ERROR - " -In-source builds are not permitted! Make a separate folder for" - " building, e.g.," - " - mkdir build; cd build; cmake .." - " -Before that, remove the files created by this failed run with" - " - rm -rf CMakeCache.txt CMakeFiles") + "In-source builds are not permitted! Make a separate folder for" + " building, e.g.,\n" + " cmake -E make_directory build\n" + " cmake -E chdir build cmake ..\n" + "Before that, remove the files created by this failed run with\n" + " cmake -E remove CMakeCache.txt\n" + " cmake -E remove_directory CMakeFiles") endif () -- 2.14.3
>From fe21bd3dc1840ca8ddf8e82179370b41faa98b11 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:03:23 +0100 Subject: [PATCH 11/19] CMakeLists.txt: Cosmetic, use list() for appending to lists --- CMakeLists.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1171e53a..5ffe975c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,7 +160,7 @@ endif () # Add local cmake modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/builds/cmake) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake) if (BUILD_FRAMEWORK) @@ -331,25 +331,23 @@ set(BASE_SRCS ) if (WIN32) - set(BASE_SRCS ${BASE_SRCS} builds/windows/ftdebug.c) + list(APPEND BASE_SRCS builds/windows/ftdebug.c) elseif (WINCE) - set(BASE_SRCS ${BASE_SRCS} builds/wince/ftdebug.c) + list(APPEND BASE_SRCS builds/wince/ftdebug.c) else () - set(BASE_SRCS ${BASE_SRCS} src/base/ftdebug.c) + list(APPEND BASE_SRCS src/base/ftdebug.c) endif () - if (BUILD_FRAMEWORK) - set(BASE_SRCS - ${BASE_SRCS} - builds/mac/freetype-Info.plist - ) + list(APPEND BASE_SRCS builds/mac/freetype-Info.plist) endif () + if (NOT DISABLE_FORCE_DEBUG_POSTFIX) set(CMAKE_DEBUG_POSTFIX d) endif() + add_library(freetype ${PUBLIC_HEADERS} ${PUBLIC_CONFIG_HEADERS} -- 2.14.3
>From 800126e040d9e7c025b50825f9cd10a714fe59ce Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:04:52 +0100 Subject: [PATCH 12/19] CMakeLists.txt: Cosmetic, don't print ftconfig.h/ftoption.h messages Noise. --- CMakeLists.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ffe975c1..3b884a125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,15 +199,7 @@ foreach (d ZLIB BZip2 PNG HarfBuzz) endforeach () -message(STATUS - "Creating directory ${PROJECT_BINARY_DIR}/include/freetype/config") -file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include/freetype/config") - - # Create the configuration file -message(STATUS - "Creating file ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h") - if (UNIX) check_include_file("unistd.h" HAVE_UNISTD_H) check_include_file("fcntl.h" HAVE_FCNTL_H) @@ -246,9 +238,6 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different # Create the options file -message(STATUS - "Creating file ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h") - file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h" FTOPTION_H) if (ZLIB_FOUND) -- 2.14.3
>From 9e5b043326d546e408cad28f0b8b7b9cb21d9dab Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:05:35 +0100 Subject: [PATCH 13/19] CMakeLists.txt: ftconfig.h, match Autotools output for header checks --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b884a125..b39dcfb90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,17 +209,17 @@ if (UNIX) FTCONFIG_H) if (HAVE_UNISTD_H) string(REGEX REPLACE - "#undef +(HAVE_UNISTD_H)" "#define \\1" + "#undef +(HAVE_UNISTD_H)" "#define \\1 1" FTCONFIG_H "${FTCONFIG_H}") endif () if (HAVE_FCNTL_H) string(REGEX REPLACE - "#undef +(HAVE_FCNTL_H)" "#define \\1" + "#undef +(HAVE_FCNTL_H)" "#define \\1 1" FTCONFIG_H "${FTCONFIG_H}") endif () if (HAVE_STDINT_H) string(REGEX REPLACE - "#undef +(HAVE_STDINT_H)" "#define \\1" + "#undef +(HAVE_STDINT_H)" "#define \\1 1" FTCONFIG_H "${FTCONFIG_H}") endif () string(REPLACE "/undef " "#undef " -- 2.14.3
>From 0911e9bd3cb4bfca3d4f18dec218a7602124a896 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:08:16 +0100 Subject: [PATCH 14/19] CMakeLists.txt: don't write ft(config|option).h-new Instead, write the configuration directly to the target files. On UNIX, ftconfig.h was always written anyway. --- CMakeLists.txt | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b39dcfb90..b497ce32c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,17 +224,9 @@ if (UNIX) endif () string(REPLACE "/undef " "#undef " FTCONFIG_H "${FTCONFIG_H}") - file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h-new" - "${FTCONFIG_H}") -else () - file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h" - FTCONFIG_H) - file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h-new" + file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h" "${FTCONFIG_H}") endif () -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h-new" - "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h") # Create the options file @@ -260,13 +252,8 @@ if (HARFBUZZ_FOUND) "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1" FTOPTION_H "${FTOPTION_H}") endif () -file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h-new" +file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h" "${FTOPTION_H}") -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h-new" - "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h") - - # Specify library include directories include_directories("${PROJECT_SOURCE_DIR}/include") include_directories(BEFORE "${PROJECT_BINARY_DIR}/include") -- 2.14.3
>From 7a35a0d9c4303d927fd76d01885ab83109caba3a Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:12:21 +0100 Subject: [PATCH 15/19] CMakeLists.txt: Set defines locally, privately on the freetype target This makes the defines more hygienic: instead of writing them to the global definitions name space, they are set to only be used when compiling the FreeType library as such. --- CMakeLists.txt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b497ce32c..650c1f3a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,14 +173,6 @@ if (BUILD_FRAMEWORK) endif () -# Compiler definitions for building the library -add_definitions(-DFT2_BUILD_LIBRARY) -if (WIN32) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) -endif () - - # Find dependencies foreach (d ZLIB BZip2 PNG HarfBuzz) string(TOUPPER "${d}" D) @@ -335,6 +327,13 @@ set_target_properties( freetype PROPERTIES C_VISIBILITY_PRESET hidden) +target_compile_definitions( + freetype PRIVATE FT2_BUILD_LIBRARY) + +if (WIN32) + target_compile_definitions( + freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS) +endif () if (BUILD_SHARED_LIBS) set_target_properties(freetype PROPERTIES -- 2.14.3
>From 24069b36bdb13ab414c03616e7f572dbb4d622f1 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:17:29 +0100 Subject: [PATCH 16/19] CMakeLists.txt: Set include directories locally on freetype target As in the previous commit, set include directories that are only needed for building the library as such locally on the freetype target. This is cleaner than setting them globally. --- CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650c1f3a1..fc6f07f6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,9 +246,6 @@ if (HARFBUZZ_FOUND) endif () file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h" "${FTOPTION_H}") -# Specify library include directories -include_directories("${PROJECT_SOURCE_DIR}/include") -include_directories(BEFORE "${PROJECT_BINARY_DIR}/include") file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h") @@ -341,6 +338,14 @@ if (BUILD_SHARED_LIBS) SOVERSION ${LIBRARY_SOVERSION}) endif () +target_include_directories( + freetype BEFORE # Pick up ftconfig.h and ftoption.h generated above. + PRIVATE "${PROJECT_BINARY_DIR}/include") + +target_include_directories( + freetype + PRIVATE "${PROJECT_SOURCE_DIR}/include") + if (BUILD_FRAMEWORK) set_property(SOURCE ${PUBLIC_CONFIG_HEADERS} @@ -367,20 +372,20 @@ endif () if (ZLIB_FOUND) target_link_libraries(freetype ${MAYBE_PRIVATE} ${ZLIB_LIBRARIES}) - include_directories(${ZLIB_INCLUDE_DIRS}) + target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS}) endif () if (BZIP2_FOUND) target_link_libraries(freetype ${MAYBE_PRIVATE} ${BZIP2_LIBRARIES}) - include_directories(${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS + 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}) - include_directories(${PNG_INCLUDE_DIRS}) + target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS}) endif () if (HARFBUZZ_FOUND) target_link_libraries(freetype ${MAYBE_PRIVATE} ${HARFBUZZ_LIBRARIES}) - include_directories(${HARFBUZZ_INCLUDE_DIRS}) + target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS}) endif () -- 2.14.3
>From f6ff687bee31260bb5f5b2e9c5efd43a892e473a Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:20:09 +0100 Subject: [PATCH 17/19] CMakeLists.txt: Make optionally usable external libraries option()s This allows the user to toggle them from soft-required (read: Autotool's auto) to hard-required. To disable looking for them, the user has to specify -DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE to CMake, where `x' is the CMake package name (e.g. "BZip2" instead of "BZIP2"). --- CMakeLists.txt | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc6f07f6b..3b6534099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,15 @@ set(VERSION_PATCH "0") set(LIBRARY_VERSION "6.16.0") set(LIBRARY_SOVERSION "6") +# These options mean "require x and complain if not found". They'll get +# optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to disable +# searching for a packge entirely (x is the CMake package name, so "BZip2" +# instead of "BZIP2"). +option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF) +option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF) +option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF) +option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF) + # Disallow in-source builds if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") @@ -177,16 +186,10 @@ endif () foreach (d ZLIB BZip2 PNG HarfBuzz) string(TOUPPER "${d}" D) - if (DEFINED WITH_${d} OR DEFINED WITH_${D}) - if (WITH_${d} OR WITH_${D}) - find_package(${d} QUIET REQUIRED) - endif () - else () - find_package(${d} QUIET) - endif () - - if (${d}_FOUND OR ${D}_FOUND) - message(STATUS "Building with ${d}") + if (FT_WITH_${D} STREQUAL ON) + find_package(${d} REQUIRED) + else() + find_package(${d}) endif () endforeach () -- 2.14.3
>From e04aaaf4940f3886544d678848af39443bfff249 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:23:58 +0100 Subject: [PATCH 18/19] CMakeLists.txt: Use GNU installation paths The GNUInstallDirs macro makes it possible for the user to override the destination paths for library and headers. It also automatically installs to lib64/ if that's the distro default. The installation components are marked in case someone makes a CPack installer. --- CMakeLists.txt | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b6534099..10d2bbca1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -392,34 +392,38 @@ if (HARFBUZZ_FOUND) endif () -# Installations -# Note the trailing slash in the argument to the `DIRECTORY' directive +# Installation +include(GNUInstallDirs) + if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION include/freetype2 - PATTERN "internal" EXCLUDE - PATTERN "ftconfig.h" EXCLUDE - PATTERN "ftoption.h" EXCLUDE - ) - install(FILES - ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h - ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h - DESTINATION include/freetype2/freetype/config - ) + install( + # Note the trailing slash in the argument to `DIRECTORY'! + DIRECTORY ${PROJECT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2 + COMPONENT headers + PATTERN "internal" EXCLUDE + PATTERN "ftconfig.h" EXCLUDE + PATTERN "ftoption.h" EXCLUDE) + install( + FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h + ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config + COMPONENT headers) endif () if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) - install(TARGETS freetype + install( + TARGETS freetype + EXPORT freetype-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION Library/Frameworks + COMPONENT libraries) + install( EXPORT freetype-targets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - FRAMEWORK DESTINATION Library/Frameworks - ) - install(EXPORT freetype-targets - DESTINATION lib/cmake/freetype - FILE freetype-config.cmake - ) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype + FILE freetype-config.cmake + COMPONENT headers) endif () -- 2.14.3
>From fc26c94f2026562b765a0f0781d22b3843280f73 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler <[email protected]> Date: Sat, 7 Apr 2018 22:26:53 +0100 Subject: [PATCH 19/19] CMakeLists.txt: Trim CPack definitions, remove package_source target Autotools remains the default mechanism for generating source packages. A source package by CMake will not include ready-made Autotools files anyway. Instead, trim the defintions to produce just binary distributions. The extra component variables would make an installer possible. Cribbed from libssh. --- CMakeLists.txt | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10d2bbca1..63caaac7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -428,29 +428,30 @@ endif () # Packaging -# CPack version numbers for release tarball name. +set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/docs/LICENSE.TXT") + set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}}) -if (NOT DEFINED CPACK_PACKAGE_DESCRIPTION_SUMMARY) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME}") -endif () -if (NOT DEFINED CPACK_SOURCE_PACKAGE_FILE_NAME) - set(CPACK_SOURCE_PACKAGE_FILE_NAME - "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-r${PROJECT_REV}" - CACHE INTERNAL "tarball basename" - ) -endif () -set(CPACK_SOURCE_GENERATOR TGZ) -set(CPACK_SOURCE_IGNORE_FILES - "/CVS/;/.svn/;.swp$;.#;/#;/build/;/serial/;/ser/;/parallel/;/par/;~;/preconfig.out;/autom4te.cache/;/.config") -set(CPACK_GENERATOR TGZ) -include(CPack) +set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +if (WIN32) + set(CPACK_GENERATOR ZIP) +else() + set(CPACK_GENERATOR TGZ) +endif() -# Add `make dist' target if FREETYPE_DIST is set (which is the default) -if (NOT DEFINED FREETYPE_NO_DIST) - add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) -endif () +set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers") +set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION + "Library used to build programs which use FreeType") +set(CPACK_COMPONENT_HEADERS_DESCRIPTION + "C/C++ header files for use with FreeType") +set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) +set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") +set(CPACK_COMPONENT_HEADERS_GROUP "Development") -# eof +include(CPack) -- 2.14.3
_______________________________________________ Freetype-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype-devel
