Use freetype from CMake target when present (#3361)

Add check for Freetype CMake target. If it is found:
- enable HB_HAVE_FREETYPE option
- add HAVE_FREETYPE=1 define
- bypass finding Freetype as cmake package
- add Freetype CMake target as dependency to harfbuzz
This commit is contained in:
Timo Suoranta 2022-01-11 13:14:44 +01:00 committed by GitHub
parent ce7f19a2cc
commit b8c2c1ab37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -37,6 +37,10 @@ option(HB_HAVE_FREETYPE "Enable freetype interop helpers" OFF)
option(HB_HAVE_GRAPHITE2 "Enable Graphite2 complementary shaper" OFF)
option(HB_HAVE_GLIB "Enable glib unicode functions" OFF)
option(HB_HAVE_ICU "Enable icu unicode functions" OFF)
if (TARGET freetype)
set (HB_HAVE_FREETYPE ON)
add_definitions(-DHAVE_FREETYPE=1)
endif ()
if (APPLE)
option(HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON)
set (CMAKE_MACOSX_RPATH ON)
@ -184,7 +188,7 @@ set (project_headers ${HB_BASE_headers})
set (subset_project_headers ${HB_SUBSET_headers})
## Find and include needed header folders and libraries
if (HB_HAVE_FREETYPE)
if (HB_HAVE_FREETYPE AND NOT TARGET freetype)
include (FindFreetype)
if (NOT FREETYPE_FOUND)
message(FATAL_ERROR "HB_HAVE_FREETYPE was set, but we failed to find it. Maybe add a CMAKE_PREFIX_PATH= to your Freetype2 install prefix")
@ -421,6 +425,10 @@ target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS})
target_include_directories(harfbuzz PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz>")
if (HB_HAVE_FREETYPE AND TARGET freetype)
target_link_libraries(harfbuzz PUBLIC freetype)
endif ()
## Define harfbuzz-icu library
if (HB_HAVE_ICU)