Modernize CMake build.
* CMakeLists.txt, builds/cmake/FindHarfBuzz.cmake: Extensive modernization measures. * .gitignore: Add build/, as that's the example directory used in CMakeLists.txt. This brings up the minimum required CMake version to 2.8.12. The installation paths follow the GNU defaults now, e.g. installing on a 64 bit host will place binaries into the lib64/ folder on e.g. Fedora. Symbols are hidden by default (e.g. `-fvisibility=hidden' on GCC). CMake will no longer look for a C++ compiler. Library and .so version now match the Autotools build. Comments in the build file and informational messages now use platform agnostic example commands. ftoption.h and ftconfig.h are written directly without a redundant `-new' copy. External dependencies are expressed as option()s and will turn up as such in cmake-gui. Internal: Properties such as dependencies and include directories are now privately set on the freetype library instead of globally. The CPack definitions have been cleaned up, the `make dist' has been removed. Source packages generated with CPack don't contain Autotools files and aren't used by the maintainters anyway. On Windows, src/base/ftver.rc is compiled to decorate the library with version and copyright information. A pkg-config file is now generated and installed.
This commit is contained in:
parent
bd9400bd46
commit
029721d69c
|
@ -1,2 +1,3 @@
|
||||||
config.mk
|
config.mk
|
||||||
objs/vc2010/
|
objs/vc2010/
|
||||||
|
build
|
||||||
|
|
393
CMakeLists.txt
393
CMakeLists.txt
|
@ -12,35 +12,40 @@
|
||||||
# fully.
|
# fully.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# As a preliminary, create a compilation directory and change into it, for
|
# The following will 1. create a build directory and 2. change into it and
|
||||||
# example
|
# call cmake to configure the build with default parameters as a static
|
||||||
|
# library.
|
||||||
#
|
#
|
||||||
# mkdir ~/freetype2.compiled
|
# cmake -E make_directory build
|
||||||
# cd ~/freetype2.compiled
|
# cmake -E chdir build cmake ..
|
||||||
#
|
|
||||||
# Now you can say
|
|
||||||
#
|
|
||||||
# cmake <path-to-freetype2-src-dir>
|
|
||||||
#
|
|
||||||
# to create a Makefile that builds a static version of the library.
|
|
||||||
#
|
#
|
||||||
# For a dynamic library, use
|
# 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
|
# For a framework on OS X, use
|
||||||
#
|
#
|
||||||
# cmake -D BUILD_FRAMEWORK:BOOL=true -G Xcode <path-to-freetype2-src-dir>
|
# cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true ..
|
||||||
#
|
|
||||||
# instead.
|
|
||||||
#
|
#
|
||||||
# For an iOS static library, use
|
# 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
|
# 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
|
||||||
#
|
#
|
||||||
# Please refer to the cmake manual for further options, in particular, how
|
# Please refer to the cmake manual for further options, in particular, how
|
||||||
# to modify compilation and linking parameters.
|
# to modify compilation and linking parameters.
|
||||||
|
@ -59,28 +64,33 @@
|
||||||
# . `CMakeLists.txt' is provided as-is since it is normally not used by the
|
# . `CMakeLists.txt' is provided as-is since it is normally not used by the
|
||||||
# developer team.
|
# developer team.
|
||||||
#
|
#
|
||||||
# . If you want to disable the automatic generation of the distribution
|
# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG', and
|
||||||
# targets, add the `-D FREETYPE_NO_DIST=true' command line argument.
|
# `FT_WITH_HARFBUZZ' CMake variables to `ON' to force using a dependency.
|
||||||
#
|
|
||||||
# . Set the `WITH_ZLIB', `WITH_BZip2', `WITH_PNG', and `WITH_HarfBuzz'
|
|
||||||
# CMake variables to `ON' or `OFF' to force or skip using a dependency.
|
|
||||||
# Leave a variable undefined (which is the default) to use the dependency
|
# Leave a variable undefined (which is the default) to use the dependency
|
||||||
# only if it is available. Example:
|
# only if it is available. Set `CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE' to
|
||||||
|
# disable a dependency completely (CMake package name, so `BZip2' instead of
|
||||||
|
# `BZIP2'). Example:
|
||||||
#
|
#
|
||||||
# cmake ... -DWITH_ZLIB=ON -DWITH_HarfBuzz=OFF ...
|
# cmake -DFT_WITH_ZLIB=ON -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE [...]
|
||||||
#
|
#
|
||||||
# . Installation of FreeType can be controlled with the CMake variables
|
# . Installation of FreeType can be controlled with the CMake variables
|
||||||
# `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL'
|
# `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL'
|
||||||
# (this is compatible with the same CMake variables in zlib's CMake
|
# (this is compatible with the same CMake variables in zlib's CMake
|
||||||
# support).
|
# support).
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.6)
|
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)
|
include(CheckIncludeFile)
|
||||||
|
|
||||||
|
|
||||||
# CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
|
# CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
|
||||||
# configures the base build environment and references the toolchain file
|
# configures the base build environment and references the toolchain file
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -116,26 +126,47 @@ else ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
project(freetype)
|
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:
|
||||||
|
# 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")
|
||||||
|
|
||||||
|
# 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
|
# Disallow in-source builds
|
||||||
if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
|
if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"
|
"In-source builds are not permitted! Make a separate folder for"
|
||||||
In-source builds are not permitted! Make a separate folder for"
|
" building, e.g.,\n"
|
||||||
" building, e.g.,"
|
" cmake -E make_directory build\n"
|
||||||
"
|
" cmake -E chdir build cmake ..\n"
|
||||||
mkdir build; cd build; cmake .."
|
"Before that, remove the files created by this failed run with\n"
|
||||||
"
|
" cmake -E remove CMakeCache.txt\n"
|
||||||
Before that, remove the files created by this failed run with"
|
" cmake -E remove_directory CMakeFiles")
|
||||||
"
|
|
||||||
rm -rf CMakeCache.txt CMakeFiles")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
# Add local cmake modules
|
# 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)
|
if (BUILD_FRAMEWORK)
|
||||||
|
@ -148,49 +179,32 @@ if (BUILD_FRAMEWORK)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
set(VERSION_MAJOR "2")
|
# Find dependencies
|
||||||
set(VERSION_MINOR "9")
|
if (FT_WITH_HARFBUZZ)
|
||||||
set(VERSION_PATCH "0")
|
find_package(HarfBuzz 1.3.0 REQUIRED)
|
||||||
|
else ()
|
||||||
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
find_package(HarfBuzz 1.3.0)
|
||||||
set(SHARED_LIBRARY_VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
|
||||||
|
|
||||||
|
|
||||||
# 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 ()
|
endif ()
|
||||||
|
|
||||||
|
if (FT_WITH_PNG)
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
else ()
|
||||||
|
find_package(PNG)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Find dependencies
|
if (FT_WITH_ZLIB)
|
||||||
foreach (d ZLIB BZip2 PNG HarfBuzz)
|
find_package(ZLIB REQUIRED)
|
||||||
string(TOUPPER "${d}" D)
|
else ()
|
||||||
|
find_package(ZLIB)
|
||||||
if (DEFINED WITH_${d} OR DEFINED WITH_${D})
|
endif ()
|
||||||
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}")
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
|
|
||||||
message(STATUS
|
|
||||||
"Creating directory ${PROJECT_BINARY_DIR}/include/freetype/config")
|
|
||||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include/freetype/config")
|
|
||||||
|
|
||||||
|
if (FT_WITH_BZIP2)
|
||||||
|
find_package(BZip2 REQUIRED)
|
||||||
|
else ()
|
||||||
|
find_package(BZip2)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Create the configuration file
|
# Create the configuration file
|
||||||
message(STATUS
|
|
||||||
"Creating file ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h")
|
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
check_include_file("unistd.h" HAVE_UNISTD_H)
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||||
check_include_file("fcntl.h" HAVE_FCNTL_H)
|
check_include_file("fcntl.h" HAVE_FCNTL_H)
|
||||||
|
@ -200,38 +214,27 @@ if (UNIX)
|
||||||
FTCONFIG_H)
|
FTCONFIG_H)
|
||||||
if (HAVE_UNISTD_H)
|
if (HAVE_UNISTD_H)
|
||||||
string(REGEX REPLACE
|
string(REGEX REPLACE
|
||||||
"#undef +(HAVE_UNISTD_H)" "#define \\1"
|
"#undef +(HAVE_UNISTD_H)" "#define \\1 1"
|
||||||
FTCONFIG_H "${FTCONFIG_H}")
|
FTCONFIG_H "${FTCONFIG_H}")
|
||||||
endif ()
|
endif ()
|
||||||
if (HAVE_FCNTL_H)
|
if (HAVE_FCNTL_H)
|
||||||
string(REGEX REPLACE
|
string(REGEX REPLACE
|
||||||
"#undef +(HAVE_FCNTL_H)" "#define \\1"
|
"#undef +(HAVE_FCNTL_H)" "#define \\1 1"
|
||||||
FTCONFIG_H "${FTCONFIG_H}")
|
FTCONFIG_H "${FTCONFIG_H}")
|
||||||
endif ()
|
endif ()
|
||||||
if (HAVE_STDINT_H)
|
if (HAVE_STDINT_H)
|
||||||
string(REGEX REPLACE
|
string(REGEX REPLACE
|
||||||
"#undef +(HAVE_STDINT_H)" "#define \\1"
|
"#undef +(HAVE_STDINT_H)" "#define \\1 1"
|
||||||
FTCONFIG_H "${FTCONFIG_H}")
|
FTCONFIG_H "${FTCONFIG_H}")
|
||||||
endif ()
|
endif ()
|
||||||
string(REPLACE "/undef " "#undef "
|
string(REPLACE "/undef " "#undef "
|
||||||
FTCONFIG_H "${FTCONFIG_H}")
|
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}")
|
|
||||||
else ()
|
|
||||||
file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h"
|
|
||||||
FTCONFIG_H)
|
|
||||||
file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h-new"
|
|
||||||
"${FTCONFIG_H}")
|
"${FTCONFIG_H}")
|
||||||
endif ()
|
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
|
# 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"
|
file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
|
||||||
FTOPTION_H)
|
FTOPTION_H)
|
||||||
if (ZLIB_FOUND)
|
if (ZLIB_FOUND)
|
||||||
|
@ -254,16 +257,8 @@ if (HARFBUZZ_FOUND)
|
||||||
"/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
|
"/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
|
||||||
FTOPTION_H "${FTOPTION_H}")
|
FTOPTION_H "${FTOPTION_H}")
|
||||||
endif ()
|
endif ()
|
||||||
file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h-new"
|
file(WRITE "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h"
|
||||||
"${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")
|
|
||||||
|
|
||||||
|
|
||||||
file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
|
file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
|
||||||
|
@ -314,25 +309,25 @@ set(BASE_SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(BASE_SRCS ${BASE_SRCS} builds/windows/ftdebug.c)
|
enable_language(RC)
|
||||||
|
list(APPEND BASE_SRCS builds/windows/ftdebug.c
|
||||||
|
src/base/ftver.rc)
|
||||||
elseif (WINCE)
|
elseif (WINCE)
|
||||||
set(BASE_SRCS ${BASE_SRCS} builds/wince/ftdebug.c)
|
list(APPEND BASE_SRCS builds/wince/ftdebug.c)
|
||||||
else ()
|
else ()
|
||||||
set(BASE_SRCS ${BASE_SRCS} src/base/ftdebug.c)
|
list(APPEND BASE_SRCS src/base/ftdebug.c)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
if (BUILD_FRAMEWORK)
|
if (BUILD_FRAMEWORK)
|
||||||
set(BASE_SRCS
|
list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
|
||||||
${BASE_SRCS}
|
|
||||||
builds/mac/freetype-Info.plist
|
|
||||||
)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
|
if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
|
||||||
set(CMAKE_DEBUG_POSTFIX d)
|
set(CMAKE_DEBUG_POSTFIX d)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_library(freetype
|
add_library(freetype
|
||||||
${PUBLIC_HEADERS}
|
${PUBLIC_HEADERS}
|
||||||
${PUBLIC_CONFIG_HEADERS}
|
${PUBLIC_CONFIG_HEADERS}
|
||||||
|
@ -340,15 +335,35 @@ add_library(freetype
|
||||||
${BASE_SRCS}
|
${BASE_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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)
|
if (BUILD_SHARED_LIBS)
|
||||||
set_target_properties(freetype PROPERTIES
|
set_target_properties(freetype PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${LIBRARY_VERSION}
|
||||||
SOVERSION ${SHARED_LIBRARY_VERSION}
|
SOVERSION ${LIBRARY_SOVERSION})
|
||||||
COMPILE_DEFINITIONS freetype_EXPORTS
|
|
||||||
)
|
|
||||||
endif ()
|
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")
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
freetype
|
||||||
|
PUBLIC $<INSTALL_INTERFACE:include/freetype2>)
|
||||||
|
|
||||||
if (BUILD_FRAMEWORK)
|
if (BUILD_FRAMEWORK)
|
||||||
set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
|
set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
|
||||||
|
@ -362,91 +377,121 @@ if (BUILD_FRAMEWORK)
|
||||||
)
|
)
|
||||||
endif ()
|
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(PKG_CONFIG_REQUIRED_PRIVATE "")
|
||||||
set(MAYBE_PRIVATE "")
|
|
||||||
else ()
|
|
||||||
set(MAYBE_PRIVATE "PRIVATE")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (ZLIB_FOUND)
|
if (ZLIB_FOUND)
|
||||||
target_link_libraries(freetype ${MAYBE_PRIVATE} ${ZLIB_LIBRARIES})
|
target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
|
||||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
|
||||||
|
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE zlib)
|
||||||
endif ()
|
endif ()
|
||||||
if (BZIP2_FOUND)
|
if (BZIP2_FOUND)
|
||||||
target_link_libraries(freetype ${MAYBE_PRIVATE} ${BZIP2_LIBRARIES})
|
target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
|
||||||
include_directories(${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
|
target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
|
||||||
|
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE bzip2)
|
||||||
endif ()
|
endif ()
|
||||||
if (PNG_FOUND)
|
if (PNG_FOUND)
|
||||||
add_definitions(${PNG_DEFINITIONS})
|
target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
|
||||||
target_link_libraries(freetype ${MAYBE_PRIVATE} ${PNG_LIBRARIES})
|
target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
|
||||||
include_directories(${PNG_INCLUDE_DIRS})
|
target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
|
||||||
|
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE libpng)
|
||||||
endif ()
|
endif ()
|
||||||
if (HARFBUZZ_FOUND)
|
if (HARFBUZZ_FOUND)
|
||||||
target_link_libraries(freetype ${MAYBE_PRIVATE} ${HARFBUZZ_LIBRARIES})
|
target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES})
|
||||||
include_directories(${HARFBUZZ_INCLUDE_DIRS})
|
target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
|
||||||
|
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE harfbuzz)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
# Installations
|
# Installation
|
||||||
# Note the trailing slash in the argument to the `DIRECTORY' directive
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
|
if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
|
||||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
install(
|
||||||
DESTINATION include/freetype2
|
# Note the trailing slash in the argument to `DIRECTORY'!
|
||||||
PATTERN "internal" EXCLUDE
|
DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
||||||
PATTERN "ftconfig.h" EXCLUDE
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2
|
||||||
PATTERN "ftoption.h" EXCLUDE
|
COMPONENT headers
|
||||||
)
|
PATTERN "internal" EXCLUDE
|
||||||
install(FILES
|
PATTERN "ftconfig.h" EXCLUDE
|
||||||
${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h
|
PATTERN "ftoption.h" EXCLUDE)
|
||||||
${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h
|
install(
|
||||||
DESTINATION include/freetype2/freetype/config
|
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 ()
|
endif ()
|
||||||
|
|
||||||
if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
||||||
install(TARGETS freetype
|
# Generate the pkg-config file
|
||||||
|
if (UNIX)
|
||||||
|
file(READ ${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in FREETYPE2_PC_IN)
|
||||||
|
|
||||||
|
string(REPLACE ";" ", " PKG_CONFIG_REQUIRED_PRIVATE "${PKG_CONFIG_REQUIRED_PRIVATE}")
|
||||||
|
|
||||||
|
string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
string(REPLACE "%exec_prefix%" "\${prefix}"
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
string(REPLACE "%ft_version%" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
string(REPLACE "%REQUIRES_PRIVATE%" "${PKG_CONFIG_REQUIRED_PRIVATE}"
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
string(REPLACE "%LIBS_PRIVATE%" "" # All libs support pkg-config
|
||||||
|
FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
|
||||||
|
|
||||||
|
file(WRITE ${PROJECT_BINARY_DIR}/freetype2.pc ${FREETYPE2_PC_IN})
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${PROJECT_BINARY_DIR}/freetype2.pc
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
||||||
|
COMPONENT pkgconfig)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
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
|
EXPORT freetype-targets
|
||||||
RUNTIME DESTINATION bin
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
|
||||||
LIBRARY DESTINATION lib
|
FILE freetype-config.cmake
|
||||||
ARCHIVE DESTINATION lib
|
COMPONENT headers)
|
||||||
FRAMEWORK DESTINATION Library/Frameworks
|
|
||||||
)
|
|
||||||
install(EXPORT freetype-targets
|
|
||||||
DESTINATION lib/cmake/freetype
|
|
||||||
FILE freetype-config.cmake
|
|
||||||
)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
# Packaging
|
# 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_MAJOR ${VERSION_MAJOR})
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}})
|
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
||||||
if (NOT DEFINED CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME}")
|
|
||||||
endif ()
|
if (WIN32)
|
||||||
if (NOT DEFINED CPACK_SOURCE_PACKAGE_FILE_NAME)
|
set(CPACK_GENERATOR ZIP)
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
else()
|
||||||
"${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-r${PROJECT_REV}"
|
set(CPACK_GENERATOR TGZ)
|
||||||
CACHE INTERNAL "tarball basename"
|
endif()
|
||||||
)
|
|
||||||
endif ()
|
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
|
||||||
set(CPACK_SOURCE_GENERATOR TGZ)
|
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
|
||||||
set(CPACK_SOURCE_IGNORE_FILES
|
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
|
||||||
"/CVS/;/.svn/;.swp$;.#;/#;/build/;/serial/;/ser/;/parallel/;/par/;~;/preconfig.out;/autom4te.cache/;/.config")
|
"Library used to build programs which use FreeType")
|
||||||
set(CPACK_GENERATOR TGZ)
|
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")
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
||||||
|
|
||||||
# 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 ()
|
|
||||||
|
|
||||||
# eof
|
|
||||||
|
|
37
ChangeLog
37
ChangeLog
|
@ -1,3 +1,40 @@
|
||||||
|
2018-04-10 Nikolaus Waxweiler <madigens@gmail.com>
|
||||||
|
|
||||||
|
* CMakeLists.txt, builds/cmake/FindHarfBuzz.cmake: Extensive
|
||||||
|
modernization measures.
|
||||||
|
|
||||||
|
This brings up the minimum required CMake version to 2.8.12.
|
||||||
|
|
||||||
|
The installation paths follow the GNU defaults now, e.g. installing on a
|
||||||
|
64 bit host will place binaries into the lib64/ folder on e.g. Fedora.
|
||||||
|
|
||||||
|
Symbols are hidden by default (e.g. `-fvisibility=hidden' on GCC).
|
||||||
|
|
||||||
|
CMake will no longer look for a C++ compiler.
|
||||||
|
|
||||||
|
Library and .so version now match the Autotools build.
|
||||||
|
|
||||||
|
Comments in the build file and informational messages now use platform
|
||||||
|
agnostic example commands.
|
||||||
|
|
||||||
|
ftoption.h and ftconfig.h are written directly without a redundant `-new'
|
||||||
|
copy.
|
||||||
|
|
||||||
|
External dependencies are expressed as option()s and will turn up as such
|
||||||
|
in cmake-gui.
|
||||||
|
|
||||||
|
Internal: Properties such as dependencies and include directories are now
|
||||||
|
privately set on the freetype library instead of globally.
|
||||||
|
|
||||||
|
The CPack definitions have been cleaned up, the `make dist' has been
|
||||||
|
removed. Source packages generated with CPack don't contain Autotools
|
||||||
|
files and aren't used by the maintainters anyway.
|
||||||
|
|
||||||
|
On Windows, src/base/ftver.rc is compiled to decorate the library with
|
||||||
|
version and copyright information.
|
||||||
|
|
||||||
|
A pkg-config file is now generated and installed.
|
||||||
|
|
||||||
2018-04-09 Werner Lemberg <wl@gnu.org>
|
2018-04-09 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[truetype] Integer overflow issues.
|
[truetype] Integer overflow issues.
|
||||||
|
|
|
@ -31,42 +31,51 @@
|
||||||
# HARFBUZZ_LIBRARIES - containg the HarfBuzz library
|
# HARFBUZZ_LIBRARIES - containg the HarfBuzz library
|
||||||
|
|
||||||
include(FindPkgConfig)
|
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
|
||||||
find_path(HARFBUZZ_INCLUDE_DIRS NAMES hb.h
|
HINTS ${PC_HARFBUZZ_INCLUDEDIR}
|
||||||
HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR}
|
${PC_HARFBUZZ_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES harfbuzz
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(HARFBUZZ_LIBRARIES NAMES 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 (HARFBUZZ_INCLUDE_DIRS)
|
||||||
if ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "0.9.17")
|
if (EXISTS "${HARFBUZZ_INCLUDE_DIRS}/hb-version.h")
|
||||||
if (HarfBuzz_FIND_REQUIRED)
|
file(READ "${HARFBUZZ_INCLUDE_DIRS}/hb-version.h" _harfbuzz_version_content)
|
||||||
set(_HARFBUZZ_REQUIRED REQUIRED)
|
|
||||||
else ()
|
string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\\.[0-9]+\\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}")
|
||||||
set(_HARFBUZZ_REQUIRED "")
|
set(HARFBUZZ_VERSION "${CMAKE_MATCH_1}")
|
||||||
endif ()
|
endif ()
|
||||||
pkg_check_modules(PC_HARFBUZZ_ICU harfbuzz-icu>=0.9.18 ${_HARFBUZZ_REQUIRED})
|
endif ()
|
||||||
find_library(HARFBUZZ_ICU_LIBRARIES NAMES harfbuzz-icu
|
|
||||||
HINTS ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} ${PC_HARFBUZZ_ICU_LIBDIR}
|
if ("${harfbuzz_FIND_VERSION}" VERSION_GREATER "${HARFBUZZ_VERSION}")
|
||||||
)
|
message(FATAL_ERROR "Required version (" ${harfbuzz_FIND_VERSION} ") is higher than found version (" ${HARFBUZZ_VERSION} ")")
|
||||||
if (HARFBUZZ_ICU_LIBRARIES)
|
|
||||||
list(APPEND HARFBUZZ_LIBRARIES "${HARFBUZZ_ICU_LIBRARIES}")
|
|
||||||
endif ()
|
|
||||||
set(_HARFBUZZ_EXTRA_REQUIRED_VAR "HARFBUZZ_ICU_LIBRARIES")
|
|
||||||
else ()
|
|
||||||
set(_HARFBUZZ_EXTRA_REQUIRED_VAR "")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HarfBuzz DEFAULT_MSG HARFBUZZ_INCLUDE_DIRS
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||||
HARFBUZZ_LIBRARIES ${_HARFBUZZ_EXTRA_REQUIRED_VAR})
|
harfbuzz
|
||||||
|
REQUIRED_VARS HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES
|
||||||
|
VERSION_VAR HARFBUZZ_VERSION)
|
||||||
|
|
||||||
mark_as_advanced(
|
mark_as_advanced(
|
||||||
HARFBUZZ_ICU_LIBRARIES
|
|
||||||
HARFBUZZ_INCLUDE_DIRS
|
HARFBUZZ_INCLUDE_DIRS
|
||||||
HARFBUZZ_LIBRARIES
|
HARFBUZZ_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 ()
|
||||||
|
|
Loading…
Reference in New Issue