2017-04-04 10:33:51 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.0)
|
|
|
|
project(harfbuzz)
|
|
|
|
|
2017-12-05 22:43:28 +00:00
|
|
|
enable_testing()
|
2017-05-13 17:02:56 +00:00
|
|
|
|
|
|
|
## Limit framework build to Xcode generator
|
|
|
|
if (BUILD_FRAMEWORK)
|
2018-01-16 10:48:09 +00:00
|
|
|
# for a framework build on macOS, use:
|
|
|
|
# cmake -DBUILD_FRAMEWORK=ON -Bbuild -H. -GXcode && cmake --build build
|
2017-05-13 17:02:56 +00:00
|
|
|
if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"You should use Xcode generator with BUILD_FRAMEWORK enabled")
|
|
|
|
endif ()
|
2017-12-25 18:31:28 +00:00
|
|
|
set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
|
|
|
|
set (CMAKE_MACOSX_RPATH ON)
|
|
|
|
set (BUILD_SHARED_LIBS ON)
|
2017-05-13 17:02:56 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
## Disallow in-source builds, as CMake generated make files can collide with autotools ones
|
|
|
|
if (NOT MSVC AND "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
|
2017-04-04 10:33:51 +00:00
|
|
|
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")
|
|
|
|
endif ()
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
|
|
|
|
## HarfBuzz build configurations
|
2017-04-11 18:48:18 +00:00
|
|
|
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)
|
2017-04-19 18:29:46 +00:00
|
|
|
if (APPLE)
|
|
|
|
option(HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON)
|
2018-01-08 22:09:42 +00:00
|
|
|
set (CMAKE_MACOSX_RPATH ON)
|
2017-04-19 18:29:46 +00:00
|
|
|
endif ()
|
|
|
|
if (WIN32)
|
|
|
|
option(HB_HAVE_UNISCRIBE "Enable Uniscribe shaper backend on Windows" OFF)
|
2019-07-16 17:57:01 +00:00
|
|
|
option(HB_HAVE_GDI "Enable GDI integration helpers on Windows" OFF)
|
2017-10-18 14:27:28 +00:00
|
|
|
option(HB_HAVE_DIRECTWRITE "Enable DirectWrite shaper backend on Windows" OFF)
|
2017-04-19 18:29:46 +00:00
|
|
|
endif ()
|
2017-04-11 17:02:14 +00:00
|
|
|
option(HB_BUILD_UTILS "Build harfbuzz utils, needs cairo, freetype, and glib properly be installed" OFF)
|
|
|
|
if (HB_BUILD_UTILS)
|
2017-12-25 18:31:28 +00:00
|
|
|
set (HB_HAVE_GLIB ON)
|
|
|
|
set (HB_HAVE_FREETYPE ON)
|
2017-04-11 17:02:14 +00:00
|
|
|
endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2018-10-30 06:49:40 +00:00
|
|
|
option(HB_BUILD_SUBSET "Build harfbuzz-subset" ON)
|
|
|
|
option(HB_BUILD_TESTS "Build harfbuzz tests" ON)
|
|
|
|
|
2017-10-18 07:43:57 +00:00
|
|
|
option(HB_HAVE_GOBJECT "Enable GObject Bindings" OFF)
|
|
|
|
if (HB_HAVE_GOBJECT)
|
2017-12-25 18:31:28 +00:00
|
|
|
set (HB_HAVE_GLIB ON)
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-10-19 10:36:32 +00:00
|
|
|
option(HB_HAVE_INTROSPECTION "Enable building introspection (.gir/.typelib) files" OFF)
|
|
|
|
if (HB_HAVE_INTROSPECTION)
|
2017-12-25 18:31:28 +00:00
|
|
|
set (HB_HAVE_GOBJECT ON)
|
|
|
|
set (HB_HAVE_GLIB ON)
|
2017-10-19 10:36:32 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-01-05 09:12:20 +00:00
|
|
|
option(HB_CHECK OFF "Do a configuration suitable for testing (shared library and enable all options)")
|
|
|
|
if (HB_CHECK)
|
|
|
|
set (BUILD_SHARED_LIBS ON)
|
|
|
|
set (HB_BUILD_UTILS ON)
|
|
|
|
set (HB_HAVE_ICU)
|
|
|
|
set (HB_HAVE_GLIB ON)
|
|
|
|
#set (HB_HAVE_GOBJECT ON)
|
|
|
|
#set (HB_HAVE_INTROSPECTION ON)
|
|
|
|
set (HB_HAVE_FREETYPE ON)
|
|
|
|
set (HB_HAVE_GRAPHITE2 ON)
|
|
|
|
if (WIN32)
|
|
|
|
set (HB_HAVE_UNISCRIBE ON)
|
2019-07-16 17:57:01 +00:00
|
|
|
set (HB_HAVE_GDI ON)
|
2018-01-05 09:12:20 +00:00
|
|
|
set (HB_HAVE_DIRECTWRITE ON)
|
|
|
|
elseif (APPLE)
|
|
|
|
set (HB_HAVE_CORETEXT ON)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
include_directories(AFTER
|
2017-04-05 09:21:23 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/src
|
2017-04-04 10:33:51 +00:00
|
|
|
${PROJECT_BINARY_DIR}/src
|
2018-01-04 06:41:34 +00:00
|
|
|
)
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2018-03-12 05:27:38 +00:00
|
|
|
# We need PYTHON_EXECUTABLE to be set for running the tests...
|
|
|
|
include (FindPythonInterp)
|
2018-01-10 12:15:12 +00:00
|
|
|
|
2018-02-03 09:23:48 +00:00
|
|
|
## Functions and headers
|
2018-01-10 12:15:12 +00:00
|
|
|
include (CheckFunctionExists)
|
|
|
|
include (CheckIncludeFile)
|
|
|
|
macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools
|
|
|
|
foreach (func_name ${ARGN})
|
2018-10-19 15:49:21 +00:00
|
|
|
string(TOUPPER ${func_name} definition_to_add)
|
|
|
|
check_function_exists(${func_name} HAVE_${definition_to_add})
|
|
|
|
if (${HAVE_${definition_to_add}})
|
|
|
|
add_definitions(-DHAVE_${definition_to_add})
|
2018-01-10 12:15:12 +00:00
|
|
|
endif ()
|
|
|
|
endforeach ()
|
|
|
|
endmacro ()
|
2018-03-12 05:27:38 +00:00
|
|
|
if (UNIX)
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
|
|
|
endif ()
|
2019-09-03 00:32:06 +00:00
|
|
|
check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l roundf)
|
2018-02-03 09:23:48 +00:00
|
|
|
check_include_file(unistd.h HAVE_UNISTD_H)
|
|
|
|
if (${HAVE_UNISTD_H})
|
|
|
|
add_definitions(-DHAVE_UNISTD_H)
|
|
|
|
endif ()
|
|
|
|
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
|
|
|
|
if (${HAVE_SYS_MMAN_H})
|
|
|
|
add_definitions(-DHAVE_SYS_MMAN_H)
|
2018-01-10 12:15:12 +00:00
|
|
|
endif ()
|
|
|
|
check_include_file(xlocale.h HAVE_XLOCALE_H)
|
|
|
|
if (${HAVE_XLOCALE_H})
|
|
|
|
add_definitions(-DHAVE_XLOCALE_H)
|
|
|
|
endif ()
|
2018-03-12 05:27:38 +00:00
|
|
|
check_include_file(stdbool.h HAVE_STDBOOL_H)
|
|
|
|
if (${HAVE_STDBOOL_H})
|
|
|
|
add_definitions(-DHAVE_STDBOOL_H)
|
|
|
|
endif ()
|
2018-01-10 12:15:12 +00:00
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
|
|
|
|
endif ()
|
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2017-05-13 17:02:56 +00:00
|
|
|
## Detect if we are running inside a distribution or regular repository folder
|
2018-02-28 08:23:39 +00:00
|
|
|
# if (EXISTS "${PROJECT_SOURCE_DIR}/ChangeLog")
|
|
|
|
# # perhaps we are on dist directory
|
|
|
|
# set (IN_HB_DIST TRUE)
|
|
|
|
# #set (HB_VERSION_H "${PROJECT_SOURCE_DIR}/src/hb-version.h")
|
|
|
|
# endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
## Extract variables from Makefile files
|
2017-12-29 19:43:29 +00:00
|
|
|
function (extract_make_variable variable makefile_source)
|
2019-07-26 19:52:03 +00:00
|
|
|
string(REGEX MATCH "${variable} = ([^$]+)\\$" temp "${makefile_source}")
|
|
|
|
string(REGEX MATCHALL "[^ \n\t\\]+" listVar "${CMAKE_MATCH_1}")
|
2017-12-29 19:43:29 +00:00
|
|
|
set (${variable} ${listVar} PARENT_SCOPE)
|
|
|
|
endfunction ()
|
|
|
|
|
|
|
|
# http://stackoverflow.com/a/27630120
|
|
|
|
function (add_prefix_to_list var prefix)
|
2017-12-25 18:31:28 +00:00
|
|
|
set (listVar "")
|
2017-12-29 19:43:29 +00:00
|
|
|
foreach (f ${${var}})
|
2017-04-11 17:02:14 +00:00
|
|
|
list(APPEND listVar "${prefix}${f}")
|
2017-04-11 18:48:18 +00:00
|
|
|
endforeach ()
|
2017-12-25 18:31:28 +00:00
|
|
|
set (${var} "${listVar}" PARENT_SCOPE)
|
2017-04-11 17:02:14 +00:00
|
|
|
endfunction ()
|
|
|
|
|
2017-04-19 18:29:46 +00:00
|
|
|
file(READ ${PROJECT_SOURCE_DIR}/src/Makefile.sources SRCSOURCES)
|
|
|
|
file(READ ${PROJECT_SOURCE_DIR}/util/Makefile.sources UTILSOURCES)
|
2017-04-11 17:02:14 +00:00
|
|
|
|
2017-12-29 19:43:29 +00:00
|
|
|
extract_make_variable(HB_BASE_headers ${SRCSOURCES})
|
|
|
|
add_prefix_to_list(HB_BASE_headers "${PROJECT_SOURCE_DIR}/src/")
|
|
|
|
|
2018-02-03 01:50:45 +00:00
|
|
|
extract_make_variable(HB_SUBSET_sources ${SRCSOURCES})
|
|
|
|
add_prefix_to_list(HB_SUBSET_sources "${PROJECT_SOURCE_DIR}/src/")
|
|
|
|
|
|
|
|
extract_make_variable(HB_SUBSET_headers ${SRCSOURCES})
|
|
|
|
add_prefix_to_list(HB_SUBSET_headers "${PROJECT_SOURCE_DIR}/src/")
|
|
|
|
|
2017-12-29 19:43:29 +00:00
|
|
|
extract_make_variable(HB_BASE_RAGEL_GENERATED_sources ${SRCSOURCES})
|
2018-02-24 06:51:17 +00:00
|
|
|
#if (IN_HB_DIST)
|
2017-12-29 19:43:29 +00:00
|
|
|
add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/")
|
2018-02-24 06:51:17 +00:00
|
|
|
#else ()
|
|
|
|
# add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/")
|
|
|
|
#endif ()
|
2017-04-11 17:02:14 +00:00
|
|
|
|
2017-12-29 19:43:29 +00:00
|
|
|
extract_make_variable(HB_VIEW_sources ${UTILSOURCES})
|
|
|
|
add_prefix_to_list(HB_VIEW_sources "${PROJECT_SOURCE_DIR}/util/")
|
|
|
|
extract_make_variable(HB_SHAPE_sources ${UTILSOURCES})
|
|
|
|
add_prefix_to_list(HB_SHAPE_sources "${PROJECT_SOURCE_DIR}/util/")
|
2018-02-03 01:50:45 +00:00
|
|
|
extract_make_variable(HB_SUBSET_CLI_sources ${UTILSOURCES})
|
|
|
|
add_prefix_to_list(HB_SUBSET_CLI_sources "${PROJECT_SOURCE_DIR}/util/")
|
2017-12-29 19:43:29 +00:00
|
|
|
extract_make_variable(HB_OT_SHAPE_CLOSURE_sources ${UTILSOURCES})
|
|
|
|
add_prefix_to_list(HB_OT_SHAPE_CLOSURE_sources "${PROJECT_SOURCE_DIR}/util/")
|
|
|
|
|
2017-04-11 18:48:18 +00:00
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
file(READ configure.ac CONFIGUREAC)
|
|
|
|
string(REGEX MATCH "\\[(([0-9]+)\\.([0-9]+)\\.([0-9]+))\\]" HB_VERSION_MATCH ${CONFIGUREAC})
|
2017-12-25 18:31:28 +00:00
|
|
|
set (HB_VERSION ${CMAKE_MATCH_1})
|
|
|
|
set (HB_VERSION_MAJOR ${CMAKE_MATCH_2})
|
|
|
|
set (HB_VERSION_MINOR ${CMAKE_MATCH_3})
|
|
|
|
set (HB_VERSION_MICRO ${CMAKE_MATCH_4})
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
## Define sources and headers of the project
|
2019-07-05 14:16:41 +00:00
|
|
|
set (project_sources ${PROJECT_SOURCE_DIR}/src/harfbuzz.cc) # use amalgam source
|
|
|
|
set (subset_project_sources ${HB_SUBSET_sources})
|
2017-12-25 18:31:28 +00:00
|
|
|
set (project_extra_sources)
|
2019-07-05 14:16:41 +00:00
|
|
|
set (project_headers ${HB_BASE_headers})
|
|
|
|
set (subset_project_headers ${HB_SUBSET_headers})
|
2017-05-04 16:01:42 +00:00
|
|
|
|
|
|
|
## Find and include needed header folders and libraries
|
2017-04-04 10:33:51 +00:00
|
|
|
if (HB_HAVE_FREETYPE)
|
2018-01-10 12:15:12 +00:00
|
|
|
include (FindFreetype)
|
2017-10-12 09:05:08 +00:00
|
|
|
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")
|
2017-12-25 18:31:28 +00:00
|
|
|
endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2017-10-12 09:05:08 +00:00
|
|
|
list(APPEND THIRD_PARTY_LIBS ${FREETYPE_LIBRARIES})
|
|
|
|
include_directories(AFTER ${FREETYPE_INCLUDE_DIRS})
|
2018-01-22 17:53:19 +00:00
|
|
|
add_definitions(-DHAVE_FREETYPE=1)
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-ft.h)
|
2018-01-08 22:09:42 +00:00
|
|
|
|
2018-01-30 06:31:46 +00:00
|
|
|
# So check_funcs can find its headers
|
2018-01-10 12:15:12 +00:00
|
|
|
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FREETYPE_INCLUDE_DIRS})
|
|
|
|
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${FREETYPE_LIBRARIES})
|
2018-01-30 06:31:46 +00:00
|
|
|
|
2018-01-10 12:15:12 +00:00
|
|
|
check_funcs(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var)
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-04-11 18:48:18 +00:00
|
|
|
if (HB_HAVE_GRAPHITE2)
|
|
|
|
add_definitions(-DHAVE_GRAPHITE2)
|
|
|
|
|
|
|
|
find_path(GRAPHITE2_INCLUDE_DIR graphite2/Font.h)
|
|
|
|
find_library(GRAPHITE2_LIBRARY graphite2)
|
|
|
|
|
|
|
|
include_directories(${GRAPHITE2_INCLUDE_DIR})
|
|
|
|
|
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-graphite2.h)
|
|
|
|
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${GRAPHITE2_LIBRARY})
|
2017-04-19 18:29:46 +00:00
|
|
|
|
|
|
|
mark_as_advanced(GRAPHITE2_INCLUDE_DIR GRAPHITE2_LIBRARY)
|
2017-04-11 18:48:18 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
if (HB_HAVE_GLIB)
|
|
|
|
add_definitions(-DHAVE_GLIB)
|
|
|
|
|
|
|
|
# https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGLIB.cmake
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(PC_GLIB QUIET glib-2.0)
|
|
|
|
|
|
|
|
find_library(GLIB_LIBRARIES NAMES glib-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS})
|
|
|
|
find_path(GLIBCONFIG_INCLUDE_DIR NAMES glibconfig.h HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0/include)
|
|
|
|
find_path(GLIB_INCLUDE_DIR NAMES glib.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0)
|
|
|
|
|
|
|
|
include_directories(${GLIBCONFIG_INCLUDE_DIR} ${GLIB_INCLUDE_DIR})
|
|
|
|
|
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-glib.h)
|
|
|
|
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${GLIB_LIBRARIES})
|
2017-04-19 18:29:46 +00:00
|
|
|
|
|
|
|
mark_as_advanced(GLIB_LIBRARIES GLIBCONFIG_INCLUDE_DIR GLIB_INCLUDE_DIR)
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-04-11 18:48:18 +00:00
|
|
|
if (HB_HAVE_ICU)
|
|
|
|
add_definitions(-DHAVE_ICU)
|
|
|
|
|
|
|
|
# https://github.com/WebKit/webkit/blob/master/Source/cmake/FindICU.cmake
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(PC_ICU QUIET icu-uc)
|
|
|
|
|
|
|
|
find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR})
|
|
|
|
find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR})
|
|
|
|
|
|
|
|
include_directories(${ICU_INCLUDE_DIR})
|
|
|
|
|
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-icu.h)
|
|
|
|
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY})
|
2017-04-19 18:29:46 +00:00
|
|
|
|
|
|
|
mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY)
|
2017-04-11 18:48:18 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
if (APPLE AND HB_HAVE_CORETEXT)
|
|
|
|
# Apple Advanced Typography
|
|
|
|
add_definitions(-DHAVE_CORETEXT)
|
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-coretext.h)
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2018-10-10 13:42:52 +00:00
|
|
|
if (HB_IOS)
|
|
|
|
find_library(COREFOUNDATION CoreFoundation)
|
|
|
|
if (COREFOUNDATION)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${COREFOUNDATION})
|
|
|
|
endif ()
|
|
|
|
mark_as_advanced(COREFOUNDATION)
|
|
|
|
|
|
|
|
find_library(CORETEXT CoreText)
|
|
|
|
if (CORETEXT)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${CORETEXT})
|
|
|
|
endif ()
|
|
|
|
mark_as_advanced(CORETEXT)
|
|
|
|
|
|
|
|
find_library(COREGRAPHICS CoreGraphics)
|
|
|
|
if (COREGRAPHICS)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${COREGRAPHICS})
|
|
|
|
endif ()
|
|
|
|
mark_as_advanced(COREGRAPHICS)
|
|
|
|
else ()
|
|
|
|
find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices)
|
|
|
|
if (APPLICATION_SERVICES_FRAMEWORK)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS ${APPLICATION_SERVICES_FRAMEWORK})
|
|
|
|
endif ()
|
2018-01-22 17:53:19 +00:00
|
|
|
|
2018-10-10 13:42:52 +00:00
|
|
|
mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK)
|
|
|
|
endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
|
|
|
|
2019-07-16 17:57:01 +00:00
|
|
|
if (WIN32 AND HB_HAVE_GDI)
|
|
|
|
add_definitions(-DHAVE_GDI)
|
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-gdi.h)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS gdi32)
|
|
|
|
endif ()
|
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
if (WIN32 AND HB_HAVE_UNISCRIBE)
|
|
|
|
add_definitions(-DHAVE_UNISCRIBE)
|
2017-04-11 17:02:14 +00:00
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-uniscribe.h)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS usp10 gdi32 rpcrt4)
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (WIN32 AND HB_HAVE_DIRECTWRITE)
|
|
|
|
add_definitions(-DHAVE_DIRECTWRITE)
|
2017-04-11 17:02:14 +00:00
|
|
|
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-directwrite.h)
|
|
|
|
list(APPEND THIRD_PARTY_LIBS dwrite rpcrt4)
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2017-10-18 07:43:57 +00:00
|
|
|
if (HB_HAVE_GOBJECT)
|
2018-01-10 12:15:12 +00:00
|
|
|
include (FindPerl)
|
2018-01-22 17:53:19 +00:00
|
|
|
|
2017-10-18 07:43:57 +00:00
|
|
|
# Use the hints from glib-2.0.pc to find glib-mkenums
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(PC_GLIB QUIET glib-2.0)
|
|
|
|
find_program(GLIB_MKENUMS glib-mkenums
|
|
|
|
HINTS ${PC_glib_mkenums}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
|
|
|
set (GLIB_MKENUMS_CMD)
|
2017-10-18 07:43:57 +00:00
|
|
|
|
|
|
|
if (WIN32 AND NOT MINGW)
|
|
|
|
# In Visual Studio builds, shebang lines are not supported
|
|
|
|
# in the standard cmd.exe shell that we use, so we need to
|
|
|
|
# first determine whether glib-mkenums is a Python or PERL
|
|
|
|
# script
|
|
|
|
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}" --version
|
|
|
|
RESULT_VARIABLE GLIB_MKENUMS_PYTHON
|
|
|
|
OUTPUT_QUIET ERROR_QUIET
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
if (GLIB_MKENUMS_PYTHON EQUAL 0)
|
|
|
|
message("${GLIB_MKENUMS} is a Python script.")
|
2017-12-25 18:31:28 +00:00
|
|
|
set (GLIB_MKENUMS_CMD "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}")
|
2017-10-18 07:43:57 +00:00
|
|
|
else ()
|
|
|
|
execute_process(COMMAND "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}" --version
|
|
|
|
RESULT_VARIABLE GLIB_MKENUMS_PERL
|
|
|
|
OUTPUT_QUIET ERROR_QUIET
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
if (GLIB_MKENUMS_PERL EQUAL 0)
|
|
|
|
message("${GLIB_MKENUMS} is a PERL script.")
|
2017-12-25 18:31:28 +00:00
|
|
|
set (GLIB_MKENUMS_CMD "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}")
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
|
|
|
if (NOT GLIB_MKENUMS_PERL EQUAL 0 AND NOT GLIB_MKENUMS_PYTHON EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Unable to determine type of glib-mkenums script")
|
|
|
|
endif ()
|
2017-12-25 18:31:28 +00:00
|
|
|
endif ()
|
2017-10-18 07:43:57 +00:00
|
|
|
else ()
|
2017-12-25 18:31:28 +00:00
|
|
|
set (GLIB_MKENUMS_CMD "${GLIB_MKENUMS}")
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
|
|
|
if (NOT GLIB_MKENUMS_CMD)
|
|
|
|
message(FATAL_ERROR "HB_HAVE_GOBJECT was set, but we failed to find glib-mkenums, which is required")
|
2017-12-25 18:31:28 +00:00
|
|
|
endif ()
|
2017-10-18 07:43:57 +00:00
|
|
|
|
|
|
|
pkg_check_modules(PC_GOBJECT QUIET gobject-2.0)
|
|
|
|
|
|
|
|
find_library(GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS})
|
|
|
|
find_path(GOBJECT_INCLUDE_DIR NAMES glib-object.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0)
|
|
|
|
|
|
|
|
include_directories(${GOBJECTCONFIG_INCLUDE_DIR} ${GOBJECT_INCLUDE_DIR})
|
|
|
|
mark_as_advanced(GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR)
|
|
|
|
|
|
|
|
list(APPEND hb_gobject_sources ${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.cc)
|
|
|
|
list(APPEND hb_gobject_gen_sources
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
list(APPEND hb_gobject_structs_headers
|
|
|
|
${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.h
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
list(APPEND hb_gobject_headers
|
|
|
|
${PROJECT_SOURCE_DIR}/src/hb-gobject.h
|
2017-10-19 10:36:32 +00:00
|
|
|
${hb_gobject_structs_headers}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
list(APPEND hb_gobject_gen_headers
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
|
2017-12-25 18:31:28 +00:00
|
|
|
add_custom_command(
|
2017-10-18 07:43:57 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h
|
|
|
|
COMMAND ${GLIB_MKENUMS_CMD}
|
|
|
|
--template=${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.h.tmpl
|
|
|
|
--identifier-prefix hb_
|
|
|
|
--symbol-prefix hb_gobject
|
2017-10-19 10:36:32 +00:00
|
|
|
${hb_gobject_structs_headers}
|
2017-10-18 07:43:57 +00:00
|
|
|
${project_headers}
|
|
|
|
> ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h.tmp
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DENUM_INPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h.tmp"
|
|
|
|
"-DENUM_OUTPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h"
|
|
|
|
-P ${PROJECT_SOURCE_DIR}/replace-enum-strings.cmake
|
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.h.tmpl
|
|
|
|
${hb_gobject_header}
|
|
|
|
${project_headers}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
|
2017-12-25 18:31:28 +00:00
|
|
|
add_custom_command(
|
2017-10-18 07:43:57 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc
|
|
|
|
COMMAND ${GLIB_MKENUMS_CMD}
|
|
|
|
--template=${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.cc.tmpl
|
|
|
|
--identifier-prefix hb_
|
|
|
|
--symbol-prefix hb_gobject
|
|
|
|
${hb_gobject_header}
|
|
|
|
${project_headers}
|
|
|
|
> ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc.tmp
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DENUM_INPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc.tmp"
|
|
|
|
"-DENUM_OUTPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc"
|
|
|
|
-P ${PROJECT_SOURCE_DIR}/replace-enum-strings.cmake
|
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.cc.tmpl
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h
|
|
|
|
${hb_gobject_header}
|
|
|
|
${project_headers}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
|
2017-04-13 23:55:50 +00:00
|
|
|
## Atomic ops availability detection
|
|
|
|
file(WRITE "${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c"
|
|
|
|
" void memory_barrier (void) { __sync_synchronize (); }
|
|
|
|
int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
|
|
|
|
int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
|
|
|
|
void mutex_unlock (int *m) { __sync_lock_release (m); }
|
2017-04-14 00:38:11 +00:00
|
|
|
int main () { return 0; }
|
2017-04-13 23:55:50 +00:00
|
|
|
")
|
|
|
|
try_compile(HB_HAVE_INTEL_ATOMIC_PRIMITIVES
|
|
|
|
${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives
|
2018-01-16 16:04:33 +00:00
|
|
|
${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c)
|
2017-04-13 23:55:50 +00:00
|
|
|
if (HB_HAVE_INTEL_ATOMIC_PRIMITIVES)
|
|
|
|
add_definitions(-DHAVE_INTEL_ATOMIC_PRIMITIVES)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
file(WRITE "${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c"
|
|
|
|
" #include <atomic.h>
|
|
|
|
/* This requires Solaris Studio 12.2 or newer: */
|
|
|
|
#include <mbarrier.h>
|
|
|
|
void memory_barrier (void) { __machine_rw_barrier (); }
|
|
|
|
int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
|
|
|
|
void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
|
2017-04-14 00:38:11 +00:00
|
|
|
int main () { return 0; }
|
2017-04-13 23:55:50 +00:00
|
|
|
")
|
|
|
|
try_compile(HB_HAVE_SOLARIS_ATOMIC_OPS
|
|
|
|
${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops
|
2018-01-16 16:04:33 +00:00
|
|
|
${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c)
|
2017-04-14 00:01:17 +00:00
|
|
|
if (HB_HAVE_SOLARIS_ATOMIC_OPS)
|
|
|
|
add_definitions(-DHAVE_SOLARIS_ATOMIC_OPS)
|
2017-04-13 23:55:50 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
|
|
|
|
## Define harfbuzz library
|
2017-10-19 10:36:32 +00:00
|
|
|
add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers})
|
2017-04-04 10:33:51 +00:00
|
|
|
target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS})
|
|
|
|
|
2019-11-05 23:26:01 +00:00
|
|
|
|
|
|
|
## Define harfbuzz-icu library
|
|
|
|
if (HB_HAVE_ICU)
|
|
|
|
add_library(harfbuzz-icu ${PROJECT_SOURCE_DIR}/src/hb-icu.cc ${PROJECT_SOURCE_DIR}/src/hb-icu.h)
|
|
|
|
add_dependencies(harfbuzz-icu harfbuzz)
|
|
|
|
target_link_libraries(harfbuzz-icu harfbuzz ${THIRD_PARTY_LIBS})
|
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(harfbuzz harfbuzz-icu PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
2018-02-08 22:59:32 +00:00
|
|
|
## Define harfbuzz-subset library
|
2018-10-30 06:49:40 +00:00
|
|
|
if (HB_BUILD_SUBSET)
|
2018-10-10 13:42:52 +00:00
|
|
|
add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers})
|
|
|
|
add_dependencies(harfbuzz-subset harfbuzz)
|
|
|
|
target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS})
|
2018-02-08 22:59:32 +00:00
|
|
|
|
2018-10-10 13:42:52 +00:00
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
|
|
|
|
endif ()
|
2018-05-07 20:35:15 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-01-16 18:30:21 +00:00
|
|
|
if (UNIX OR MINGW)
|
|
|
|
# Make symbols link locally
|
2018-03-30 17:55:35 +00:00
|
|
|
include (CheckCXXCompilerFlag)
|
2018-12-30 06:53:47 +00:00
|
|
|
CHECK_CXX_COMPILER_FLAG(-Bsymbolic-functions CXX_SUPPORTS_FLAG_BSYMB_FUNCS)
|
2018-03-30 17:55:35 +00:00
|
|
|
if (CXX_SUPPORTS_FLAG_BSYMB_FUNCS)
|
2018-03-16 19:14:27 +00:00
|
|
|
link_libraries(-Bsymbolic-functions)
|
2018-03-30 17:55:35 +00:00
|
|
|
endif ()
|
2018-01-16 18:30:21 +00:00
|
|
|
|
2018-01-30 06:31:46 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2018-02-10 19:43:12 +00:00
|
|
|
# Make sure we don't link to libstdc++
|
2018-01-30 06:31:46 +00:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
|
|
|
set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm
|
|
|
|
set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
|
|
|
|
set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C)
|
2018-10-30 06:49:40 +00:00
|
|
|
if (HB_BUILD_SUBSET)
|
2018-10-10 13:42:52 +00:00
|
|
|
set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C)
|
|
|
|
endif ()
|
2018-01-18 21:42:31 +00:00
|
|
|
|
2018-02-10 19:43:12 +00:00
|
|
|
# No threadsafe statics as we do it ourselves
|
2018-01-30 06:31:46 +00:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
|
2018-01-16 18:30:21 +00:00
|
|
|
endif ()
|
2018-12-30 06:53:47 +00:00
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
|
|
|
if (COMPILER_SUPPORTS_CXX11)
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
else()
|
|
|
|
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
|
|
|
endif()
|
2018-01-16 18:30:21 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-12-30 06:53:47 +00:00
|
|
|
|
2017-10-18 07:43:57 +00:00
|
|
|
## Define harfbuzz-gobject library
|
|
|
|
if (HB_HAVE_GOBJECT)
|
|
|
|
add_library(harfbuzz-gobject
|
|
|
|
${hb_gobject_sources}
|
|
|
|
${hb_gobject_gen_sources}
|
|
|
|
${hb_gobject_headers}
|
|
|
|
${hb_gobject_gen_headers}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-18 07:43:57 +00:00
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src)
|
|
|
|
add_dependencies(harfbuzz-gobject harfbuzz)
|
|
|
|
target_link_libraries(harfbuzz-gobject harfbuzz ${GOBJECT_LIBRARIES} ${THIRD_PARTY_LIBS})
|
2018-05-07 20:35:15 +00:00
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(harfbuzz-gobject PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
|
|
|
|
endif ()
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2018-03-16 19:09:58 +00:00
|
|
|
if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW)
|
2018-07-25 10:12:34 +00:00
|
|
|
add_definitions("-DHB_DLL_EXPORT")
|
2018-03-14 10:29:24 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-10-19 10:36:32 +00:00
|
|
|
# On Windows, g-ir-scanner requires a DLL build in order for it to work
|
|
|
|
if (WIN32)
|
|
|
|
if (NOT BUILD_SHARED_LIBS)
|
|
|
|
message("Building introspection files on Windows requires BUILD_SHARED_LIBS to be enabled.")
|
2017-12-25 18:31:28 +00:00
|
|
|
set (HB_HAVE_INTROSPECTION OFF)
|
2017-10-19 10:36:32 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (HB_HAVE_INTROSPECTION)
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(PC_GI QUIET gobject-introspection-1.0)
|
|
|
|
|
|
|
|
find_program(G_IR_SCANNER g-ir-scanner
|
|
|
|
HINTS ${PC_g_ir_scanner}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
|
|
|
|
find_program(G_IR_COMPILER g-ir-compiler
|
|
|
|
HINTS ${PC_g_ir_compiler}
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
|
|
|
|
if (WIN32 AND NOT MINGW)
|
|
|
|
# Note that since we already enable HB_HAVE_GOBJECT
|
|
|
|
# we would already have PYTHON_EXECUTABLE handy
|
2017-12-25 18:31:28 +00:00
|
|
|
set (G_IR_SCANNER_CMD "${PYTHON_EXECUTABLE}" "${G_IR_SCANNER}")
|
2017-10-19 10:36:32 +00:00
|
|
|
else ()
|
2017-12-25 18:31:28 +00:00
|
|
|
set (G_IR_SCANNER_CMD "${G_IR_SCANNER}")
|
2017-10-19 10:36:32 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
# We need to account for the varying output directories
|
|
|
|
# when we build using Visual Studio projects
|
2017-12-25 18:31:28 +00:00
|
|
|
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*")
|
2017-10-19 10:36:32 +00:00
|
|
|
set (hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
|
|
|
|
else ()
|
|
|
|
set (hb_libpath "$<TARGET_FILE_DIR:harfbuzz-gobject>")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Get the CFlags that we used to build HarfBuzz/HarfBuzz-GObject
|
|
|
|
set (hb_defines_cflags "")
|
2017-12-25 18:31:28 +00:00
|
|
|
foreach (hb_cflag ${hb_cflags})
|
2017-10-19 10:36:32 +00:00
|
|
|
list(APPEND hb_defines_cflags "-D${hb_cflag}")
|
2017-12-25 18:31:28 +00:00
|
|
|
endforeach (hb_cflag)
|
2017-10-19 10:36:32 +00:00
|
|
|
|
|
|
|
# Get the other dependent libraries we used to build HarfBuzz/HarfBuzz-GObject
|
|
|
|
set (extra_libs "")
|
|
|
|
foreach (extra_lib ${THIRD_PARTY_LIBS})
|
|
|
|
# We don't want the .lib extension here...
|
|
|
|
string(REPLACE ".lib" "" extra_lib_stripped "${extra_lib}")
|
|
|
|
list(APPEND extra_libs "--extra-library=${extra_lib_stripped}")
|
|
|
|
endforeach ()
|
|
|
|
|
2017-12-25 18:31:28 +00:00
|
|
|
set (introspected_sources)
|
2017-10-19 10:36:32 +00:00
|
|
|
foreach (f
|
|
|
|
${project_headers}
|
|
|
|
${project_sources}
|
|
|
|
${hb_gobject_gen_sources}
|
|
|
|
${hb_gobject_gen_headers}
|
|
|
|
${hb_gobject_sources}
|
|
|
|
${hb_gobject_headers}
|
2018-01-04 06:41:34 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
if (WIN32)
|
|
|
|
# Nasty issue: We need to make drive letters lower case,
|
|
|
|
# otherwise g-ir-scanner won't like it and give us a bunch
|
|
|
|
# of invalid items and unresolved types...
|
|
|
|
STRING(SUBSTRING "${f}" 0 1 drive)
|
|
|
|
STRING(SUBSTRING "${f}" 1 -1 path)
|
|
|
|
if (drive MATCHES "[A-Z]")
|
|
|
|
STRING(TOLOWER ${drive} drive_lower)
|
|
|
|
list(APPEND introspected_sources "${drive_lower}${path}")
|
|
|
|
else ()
|
|
|
|
list(APPEND introspected_sources "${f}")
|
|
|
|
endif ()
|
|
|
|
else ()
|
|
|
|
list(APPEND introspected_sources "${f}")
|
|
|
|
endif ()
|
|
|
|
endforeach ()
|
|
|
|
|
2018-03-12 08:23:57 +00:00
|
|
|
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list)
|
|
|
|
foreach (s ${introspected_sources})
|
|
|
|
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list "${s}\n")
|
|
|
|
endforeach ()
|
|
|
|
|
2017-10-19 10:36:32 +00:00
|
|
|
# Finally, build the introspection files...
|
2017-12-25 18:31:28 +00:00
|
|
|
add_custom_command(
|
2017-10-19 10:36:32 +00:00
|
|
|
TARGET harfbuzz-gobject
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${G_IR_SCANNER_CMD}
|
|
|
|
--warn-all --no-libtool --verbose
|
|
|
|
-n hb
|
|
|
|
--namespace=HarfBuzz
|
|
|
|
--nsversion=0.0
|
|
|
|
--identifier-prefix=hb_
|
|
|
|
--include GObject-2.0
|
|
|
|
--pkg-export=harfbuzz
|
|
|
|
--cflags-begin
|
|
|
|
-I${PROJECT_SOURCE_DIR}/src
|
|
|
|
-I${PROJECT_BINARY_DIR}/src
|
|
|
|
${hb_includedir_cflags}
|
|
|
|
${hb_defines_cflags}
|
|
|
|
-DHB_H
|
|
|
|
-DHB_H_IN
|
|
|
|
-DHB_OT_H
|
|
|
|
-DHB_OT_H_IN
|
2018-12-11 17:23:53 +00:00
|
|
|
-DHB_AAT_H
|
|
|
|
-DHB_AAT_H_IN
|
2017-10-19 10:36:32 +00:00
|
|
|
-DHB_GOBJECT_H
|
|
|
|
-DHB_GOBJECT_H_IN
|
|
|
|
-DHB_EXTERN=
|
|
|
|
--cflags-end
|
|
|
|
--library=harfbuzz-gobject
|
|
|
|
--library=harfbuzz
|
|
|
|
-L${hb_libpath}
|
|
|
|
${extra_libs}
|
2018-03-12 08:23:57 +00:00
|
|
|
--filelist ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list
|
2017-10-19 10:36:32 +00:00
|
|
|
-o ${hb_libpath}/HarfBuzz-0.0.gir
|
2018-03-12 08:23:57 +00:00
|
|
|
DEPENDS harfbuzz-gobject harfbuzz ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
|
2017-12-25 18:31:28 +00:00
|
|
|
add_custom_command(
|
2017-10-19 10:36:32 +00:00
|
|
|
TARGET harfbuzz-gobject
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND "${G_IR_COMPILER}"
|
|
|
|
--verbose --debug
|
|
|
|
--includedir ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${hb_libpath}/HarfBuzz-0.0.gir
|
|
|
|
-o ${hb_libpath}/HarfBuzz-0.0.typelib
|
|
|
|
DEPENDS ${hb_libpath}/HarfBuzz-0.0.gir harfbuzz-gobject
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-01-04 06:41:34 +00:00
|
|
|
|
2017-05-13 17:02:56 +00:00
|
|
|
## Additional framework build configs
|
|
|
|
if (BUILD_FRAMEWORK)
|
2017-12-25 18:31:28 +00:00
|
|
|
set (CMAKE_MACOSX_RPATH ON)
|
2017-05-13 17:02:56 +00:00
|
|
|
set_target_properties(harfbuzz PROPERTIES
|
|
|
|
FRAMEWORK TRUE
|
|
|
|
PUBLIC_HEADER "${project_headers}"
|
|
|
|
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
|
|
|
)
|
2017-12-25 18:31:28 +00:00
|
|
|
set (MACOSX_FRAMEWORK_IDENTIFIER "harfbuzz")
|
|
|
|
set (MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${HB_VERSION}")
|
|
|
|
set (MACOSX_FRAMEWORK_BUNDLE_VERSION "${HB_VERSION}")
|
2017-05-13 17:02:56 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
## Additional harfbuzz build artifacts
|
2017-04-11 17:02:14 +00:00
|
|
|
if (HB_BUILD_UTILS)
|
|
|
|
# https://github.com/WebKit/webkit/blob/master/Source/cmake/FindCairo.cmake
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(PC_CAIRO QUIET cairo)
|
|
|
|
|
|
|
|
find_path(CAIRO_INCLUDE_DIRS NAMES cairo.h HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIRS} PATH_SUFFIXES cairo)
|
|
|
|
find_library(CAIRO_LIBRARIESNAMES cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS})
|
|
|
|
|
|
|
|
add_definitions("-DPACKAGE_NAME=\"HarfBuzz\"")
|
|
|
|
add_definitions("-DPACKAGE_VERSION=\"${HB_VERSION}\"")
|
|
|
|
include_directories(${CAIRO_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
add_executable(hb-view ${HB_VIEW_sources})
|
|
|
|
target_link_libraries(hb-view harfbuzz ${CAIRO_LIBRARIESNAMES})
|
|
|
|
|
|
|
|
add_executable(hb-shape ${HB_SHAPE_sources})
|
|
|
|
target_link_libraries(hb-shape harfbuzz)
|
|
|
|
|
2018-02-03 01:50:45 +00:00
|
|
|
add_executable(hb-subset ${HB_SUBSET_CLI_sources})
|
2018-02-08 22:59:32 +00:00
|
|
|
target_link_libraries(hb-subset harfbuzz harfbuzz-subset)
|
2018-02-03 01:50:45 +00:00
|
|
|
|
2017-04-11 17:02:14 +00:00
|
|
|
add_executable(hb-ot-shape-closure ${HB_OT_SHAPE_CLOSURE_sources})
|
|
|
|
target_link_libraries(hb-ot-shape-closure harfbuzz)
|
2017-04-19 18:29:46 +00:00
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
mark_as_advanced(CAIRO_INCLUDE_DIRS CAIRO_LIBRARIESNAMES)
|
2017-04-11 17:02:14 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-05-04 16:01:42 +00:00
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
## Install
|
2018-01-10 12:15:12 +00:00
|
|
|
include (GNUInstallDirs)
|
2017-12-25 18:31:28 +00:00
|
|
|
|
2017-04-04 10:33:51 +00:00
|
|
|
if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
|
2017-12-25 18:31:28 +00:00
|
|
|
install(FILES ${project_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz)
|
2017-10-18 07:43:57 +00:00
|
|
|
if (HB_HAVE_GOBJECT)
|
2017-12-25 18:31:28 +00:00
|
|
|
install(FILES ${hb_gobject_headers} ${hb_gobject_gen_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz)
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
|
|
|
install(TARGETS harfbuzz
|
2018-09-17 08:33:34 +00:00
|
|
|
EXPORT harfbuzzConfig
|
2017-12-25 18:31:28 +00:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-05-13 17:02:56 +00:00
|
|
|
FRAMEWORK DESTINATION Library/Frameworks
|
2017-12-25 18:31:28 +00:00
|
|
|
)
|
2018-09-17 08:33:34 +00:00
|
|
|
install(EXPORT harfbuzzConfig
|
|
|
|
NAMESPACE harfbuzz::
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/harfbuzz
|
|
|
|
)
|
2019-11-05 23:26:01 +00:00
|
|
|
if (HB_HAVE_ICU)
|
|
|
|
install(TARGETS harfbuzz-icu
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
FRAMEWORK DESTINATION Library/Frameworks
|
|
|
|
)
|
|
|
|
endif ()
|
2017-10-18 14:27:28 +00:00
|
|
|
if (HB_BUILD_UTILS)
|
2018-07-25 10:12:34 +00:00
|
|
|
if (WIN32 AND BUILD_SHARED_LIBS)
|
|
|
|
install(TARGETS harfbuzz-subset
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
)
|
|
|
|
endif ()
|
2017-10-18 14:27:28 +00:00
|
|
|
install(TARGETS hb-view
|
2017-12-25 18:31:28 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-10-18 14:27:28 +00:00
|
|
|
)
|
2018-03-12 08:43:53 +00:00
|
|
|
install(TARGETS hb-subset
|
2017-12-25 18:31:28 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-10-18 14:27:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
install(TARGETS hb-shape
|
2017-12-25 18:31:28 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-10-18 14:27:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
install(TARGETS hb-ot-shape-closure
|
2017-12-25 18:31:28 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-10-18 14:27:28 +00:00
|
|
|
)
|
|
|
|
endif ()
|
2017-10-18 07:43:57 +00:00
|
|
|
if (HB_HAVE_GOBJECT)
|
|
|
|
install(TARGETS harfbuzz-gobject
|
2017-12-25 18:31:28 +00:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-10-18 07:43:57 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
if (HB_HAVE_INTROSPECTION)
|
2017-12-25 18:31:28 +00:00
|
|
|
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*")
|
2017-10-19 10:36:32 +00:00
|
|
|
set (hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
|
|
|
|
else ()
|
|
|
|
set (hb_libpath "$<TARGET_FILE_DIR:harfbuzz-gobject>")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
install(FILES "${hb_libpath}/HarfBuzz-0.0.gir"
|
2017-12-25 18:31:28 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0
|
2018-01-04 06:41:34 +00:00
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
|
|
|
|
install(FILES "${hb_libpath}/HarfBuzz-0.0.typelib"
|
2017-12-25 18:31:28 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0
|
|
|
|
)
|
2017-10-19 10:36:32 +00:00
|
|
|
endif ()
|
2017-10-18 07:43:57 +00:00
|
|
|
endif ()
|
2017-04-04 10:33:51 +00:00
|
|
|
endif ()
|
2017-12-05 22:43:28 +00:00
|
|
|
|
2018-10-30 06:49:40 +00:00
|
|
|
if (HB_BUILD_TESTS)
|
2018-10-10 13:42:52 +00:00
|
|
|
## src/ executables
|
2020-01-24 16:52:27 +00:00
|
|
|
foreach (prog test test-gsub-would-substitute test-gpos-size-params test-buffer-serialize test-unicode-ranges) # hb-ot-tag
|
2018-10-10 13:42:52 +00:00
|
|
|
set (prog_name ${prog})
|
|
|
|
if (${prog_name} STREQUAL "test")
|
|
|
|
# test can not be used as a valid executable name on cmake, lets special case it
|
|
|
|
set (prog_name test-test)
|
|
|
|
endif ()
|
|
|
|
add_executable(${prog_name} ${PROJECT_SOURCE_DIR}/src/${prog}.cc)
|
|
|
|
target_link_libraries(${prog_name} harfbuzz ${THIRD_PARTY_LIBS})
|
|
|
|
endforeach ()
|
2019-07-05 14:16:41 +00:00
|
|
|
# set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN")
|
2018-10-10 13:42:52 +00:00
|
|
|
|
|
|
|
## Tests
|
|
|
|
if (UNIX OR MINGW)
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
# generate harfbuzz.def after build completion
|
|
|
|
add_custom_command(TARGET harfbuzz POST_BUILD
|
|
|
|
COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers}
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
|
|
|
|
|
|
|
|
add_test(NAME check-static-inits.sh
|
|
|
|
COMMAND ${PROJECT_SOURCE_DIR}/src/check-static-inits.sh
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/harfbuzz.dir/src # ugly hack
|
|
|
|
)
|
|
|
|
add_test(NAME check-libstdc++.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-libstdc++.sh)
|
|
|
|
add_test(NAME check-symbols.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-symbols.sh)
|
|
|
|
|
|
|
|
set_tests_properties(
|
|
|
|
check-static-inits.sh check-libstdc++.sh check-symbols.sh
|
|
|
|
PROPERTIES
|
|
|
|
ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src"
|
|
|
|
SKIP_RETURN_CODE 77)
|
|
|
|
endif ()
|
2018-01-22 15:07:26 +00:00
|
|
|
|
2018-10-10 13:42:52 +00:00
|
|
|
add_test(NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh)
|
|
|
|
add_test(NAME check-header-guards.sh COMMAND ./check-header-guards.sh)
|
|
|
|
add_test(NAME check-externs.sh COMMAND ./check-externs.sh)
|
|
|
|
add_test(NAME check-includes.sh COMMAND ./check-includes.sh)
|
2018-02-12 11:40:13 +00:00
|
|
|
set_tests_properties(
|
2018-10-10 13:42:52 +00:00
|
|
|
check-c-linkage-decls.sh check-header-guards.sh check-externs.sh check-includes.sh
|
2018-02-12 11:40:13 +00:00
|
|
|
PROPERTIES
|
2018-10-10 13:42:52 +00:00
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
|
2018-02-12 11:40:13 +00:00
|
|
|
SKIP_RETURN_CODE 77)
|
2018-01-04 06:41:34 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-10-10 13:42:52 +00:00
|
|
|
# Needs to come last so that variables defined above are passed to
|
|
|
|
# subdirectories.
|
|
|
|
add_subdirectory(test)
|
2018-01-04 06:41:34 +00:00
|
|
|
endif ()
|