ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.0) |
| 2 | project(harfbuzz) |
| 3 | |
Khaled Hosny | c860955 | 2017-12-06 00:43:28 +0200 | [diff] [blame] | 4 | enable_testing() |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 5 | |
| 6 | ## Limit framework build to Xcode generator |
| 7 | if (BUILD_FRAMEWORK) |
Ebrahim Byagowi | c97a7ec | 2018-01-16 14:18:09 +0330 | [diff] [blame] | 8 | # for a framework build on macOS, use: |
| 9 | # cmake -DBUILD_FRAMEWORK=ON -Bbuild -H. -GXcode && cmake --build build |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 10 | if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") |
| 11 | message(FATAL_ERROR |
| 12 | "You should use Xcode generator with BUILD_FRAMEWORK enabled") |
| 13 | endif () |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 14 | set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)") |
| 15 | set (CMAKE_MACOSX_RPATH ON) |
| 16 | set (BUILD_SHARED_LIBS ON) |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 17 | endif () |
| 18 | |
| 19 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 20 | ## Disallow in-source builds, as CMake generated make files can collide with autotools ones |
| 21 | if (NOT MSVC AND "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 22 | message(FATAL_ERROR |
| 23 | " |
| 24 | In-source builds are not permitted! Make a separate folder for" |
| 25 | " building, e.g.," |
| 26 | " |
| 27 | mkdir build; cd build; cmake .." |
| 28 | " |
| 29 | Before that, remove the files created by this failed run with" |
| 30 | " |
| 31 | rm -rf CMakeCache.txt CMakeFiles") |
| 32 | endif () |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 33 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 34 | |
| 35 | ## HarfBuzz build configurations |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 36 | option(HB_HAVE_FREETYPE "Enable freetype interop helpers" OFF) |
| 37 | option(HB_HAVE_GRAPHITE2 "Enable Graphite2 complementary shaper" OFF) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 38 | option(HB_BUILTIN_UCDN "Use HarfBuzz provided UCDN" ON) |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 39 | option(HB_HAVE_GLIB "Enable glib unicode functions" OFF) |
| 40 | option(HB_HAVE_ICU "Enable icu unicode functions" OFF) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 41 | if (APPLE) |
| 42 | option(HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON) |
Ebrahim Byagowi | 3c7aeb5 | 2018-01-09 01:39:42 +0330 | [diff] [blame] | 43 | set (CMAKE_MACOSX_RPATH ON) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 44 | endif () |
| 45 | if (WIN32) |
| 46 | option(HB_HAVE_UNISCRIBE "Enable Uniscribe shaper backend on Windows" OFF) |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 47 | option(HB_HAVE_DIRECTWRITE "Enable DirectWrite shaper backend on Windows" OFF) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 48 | endif () |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 49 | option(HB_BUILD_UTILS "Build harfbuzz utils, needs cairo, freetype, and glib properly be installed" OFF) |
| 50 | if (HB_BUILD_UTILS) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 51 | set (HB_HAVE_GLIB ON) |
| 52 | set (HB_HAVE_FREETYPE ON) |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 53 | endif () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 54 | |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 55 | option(HB_HAVE_GOBJECT "Enable GObject Bindings" OFF) |
| 56 | if (HB_HAVE_GOBJECT) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 57 | set (HB_HAVE_GLIB ON) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 58 | endif () |
| 59 | |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 60 | option(HB_HAVE_INTROSPECTION "Enable building introspection (.gir/.typelib) files" OFF) |
| 61 | if (HB_HAVE_INTROSPECTION) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 62 | set (HB_HAVE_GOBJECT ON) |
| 63 | set (HB_HAVE_GLIB ON) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 64 | endif () |
| 65 | |
Ebrahim Byagowi | 72bec1c | 2018-01-05 12:42:20 +0330 | [diff] [blame] | 66 | option(HB_CHECK OFF "Do a configuration suitable for testing (shared library and enable all options)") |
| 67 | if (HB_CHECK) |
| 68 | set (BUILD_SHARED_LIBS ON) |
| 69 | set (HB_BUILD_UTILS ON) |
| 70 | set (HB_BUILTIN_UCDN ON) |
| 71 | set (HB_HAVE_ICU) |
| 72 | set (HB_HAVE_GLIB ON) |
| 73 | #set (HB_HAVE_GOBJECT ON) |
| 74 | #set (HB_HAVE_INTROSPECTION ON) |
| 75 | set (HB_HAVE_FREETYPE ON) |
| 76 | set (HB_HAVE_GRAPHITE2 ON) |
| 77 | if (WIN32) |
| 78 | set (HB_HAVE_UNISCRIBE ON) |
| 79 | set (HB_HAVE_DIRECTWRITE ON) |
| 80 | elseif (APPLE) |
| 81 | set (HB_HAVE_CORETEXT ON) |
| 82 | endif () |
| 83 | endif () |
| 84 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 85 | include_directories(AFTER |
ebraminio | d2acaf6 | 2017-04-05 02:21:23 -0700 | [diff] [blame] | 86 | ${PROJECT_SOURCE_DIR}/src |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 87 | ${PROJECT_BINARY_DIR}/src |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 88 | ) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 89 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 90 | add_definitions(-DHAVE_OT) |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 91 | add_definitions(-DHAVE_FALLBACK) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 92 | |
Chun-wei Fan | 89dbabf | 2018-03-12 13:27:38 +0800 | [diff] [blame] | 93 | # We need PYTHON_EXECUTABLE to be set for running the tests... |
| 94 | include (FindPythonInterp) |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 95 | |
Ebrahim Byagowi | 07885e6 | 2018-02-03 12:53:48 +0330 | [diff] [blame] | 96 | ## Functions and headers |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 97 | include (CheckFunctionExists) |
| 98 | include (CheckIncludeFile) |
| 99 | macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools |
| 100 | foreach (func_name ${ARGN}) |
Ebrahim Byagowi | e24bea8 | 2018-01-10 23:51:56 +0330 | [diff] [blame] | 101 | string(TOUPPER ${func_name} definiton_to_add) |
| 102 | check_function_exists(${func_name} HAVE_${definiton_to_add}) |
| 103 | if (${HAVE_${definiton_to_add}}) |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 104 | add_definitions(-DHAVE_${definiton_to_add}) |
| 105 | endif () |
| 106 | endforeach () |
| 107 | endmacro () |
Chun-wei Fan | 89dbabf | 2018-03-12 13:27:38 +0800 | [diff] [blame] | 108 | if (UNIX) |
| 109 | list(APPEND CMAKE_REQUIRED_LIBRARIES m) |
| 110 | endif () |
| 111 | check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l round) |
Ebrahim Byagowi | 07885e6 | 2018-02-03 12:53:48 +0330 | [diff] [blame] | 112 | check_include_file(unistd.h HAVE_UNISTD_H) |
| 113 | if (${HAVE_UNISTD_H}) |
| 114 | add_definitions(-DHAVE_UNISTD_H) |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 115 | endif () |
Ebrahim Byagowi | 07885e6 | 2018-02-03 12:53:48 +0330 | [diff] [blame] | 116 | check_include_file(sys/mman.h HAVE_SYS_MMAN_H) |
| 117 | if (${HAVE_SYS_MMAN_H}) |
| 118 | add_definitions(-DHAVE_SYS_MMAN_H) |
| 119 | endif () |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 120 | check_include_file(xlocale.h HAVE_XLOCALE_H) |
| 121 | if (${HAVE_XLOCALE_H}) |
| 122 | add_definitions(-DHAVE_XLOCALE_H) |
| 123 | endif () |
Chun-wei Fan | 89dbabf | 2018-03-12 13:27:38 +0800 | [diff] [blame] | 124 | check_include_file(stdbool.h HAVE_STDBOOL_H) |
| 125 | if (${HAVE_STDBOOL_H}) |
| 126 | add_definitions(-DHAVE_STDBOOL_H) |
| 127 | endif () |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 128 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 129 | |
| 130 | if (MSVC) |
| 131 | add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) |
| 132 | endif () |
| 133 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 134 | |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 135 | ## Detect if we are running inside a distribution or regular repository folder |
Ebrahim Byagowi | 0eec331 | 2018-02-28 11:53:39 +0330 | [diff] [blame] | 136 | # if (EXISTS "${PROJECT_SOURCE_DIR}/ChangeLog") |
| 137 | # # perhaps we are on dist directory |
| 138 | # set (IN_HB_DIST TRUE) |
| 139 | # #set (HB_VERSION_H "${PROJECT_SOURCE_DIR}/src/hb-version.h") |
| 140 | # endif () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 141 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 142 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 143 | ## Extract variables from Makefile files |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 144 | function (extract_make_variable variable makefile_source) |
| 145 | string(REGEX MATCH "${variable} = ([^$]+)\\$" temp ${makefile_source}) |
| 146 | string(REGEX MATCHALL "[^ \n\t\\]+" listVar ${CMAKE_MATCH_1}) |
| 147 | set (${variable} ${listVar} PARENT_SCOPE) |
| 148 | endfunction () |
| 149 | |
| 150 | # http://stackoverflow.com/a/27630120 |
| 151 | function (add_prefix_to_list var prefix) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 152 | set (listVar "") |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 153 | foreach (f ${${var}}) |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 154 | list(APPEND listVar "${prefix}${f}") |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 155 | endforeach () |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 156 | set (${var} "${listVar}" PARENT_SCOPE) |
ebraminio | d2acaf6 | 2017-04-05 02:21:23 -0700 | [diff] [blame] | 157 | endfunction () |
| 158 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 159 | file(READ ${PROJECT_SOURCE_DIR}/src/Makefile.sources SRCSOURCES) |
| 160 | file(READ ${PROJECT_SOURCE_DIR}/util/Makefile.sources UTILSOURCES) |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 161 | file(READ ${PROJECT_SOURCE_DIR}/src/hb-ucdn/Makefile.sources UCDNSOURCES) |
| 162 | |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 163 | extract_make_variable(HB_BASE_sources ${SRCSOURCES}) |
| 164 | add_prefix_to_list(HB_BASE_sources "${PROJECT_SOURCE_DIR}/src/") |
| 165 | extract_make_variable(HB_BASE_headers ${SRCSOURCES}) |
| 166 | add_prefix_to_list(HB_BASE_headers "${PROJECT_SOURCE_DIR}/src/") |
| 167 | extract_make_variable(HB_FALLBACK_sources ${SRCSOURCES}) |
| 168 | add_prefix_to_list(HB_FALLBACK_sources "${PROJECT_SOURCE_DIR}/src/") |
| 169 | extract_make_variable(HB_OT_sources ${SRCSOURCES}) |
| 170 | add_prefix_to_list(HB_OT_sources "${PROJECT_SOURCE_DIR}/src/") |
| 171 | extract_make_variable(HB_OT_headers ${SRCSOURCES}) |
| 172 | add_prefix_to_list(HB_OT_headers "${PROJECT_SOURCE_DIR}/src/") |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 173 | |
Garret Rieger | f83a43b | 2018-02-02 17:50:45 -0800 | [diff] [blame] | 174 | extract_make_variable(HB_SUBSET_sources ${SRCSOURCES}) |
| 175 | add_prefix_to_list(HB_SUBSET_sources "${PROJECT_SOURCE_DIR}/src/") |
| 176 | |
| 177 | extract_make_variable(HB_SUBSET_headers ${SRCSOURCES}) |
| 178 | add_prefix_to_list(HB_SUBSET_headers "${PROJECT_SOURCE_DIR}/src/") |
| 179 | |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 180 | extract_make_variable(HB_BASE_RAGEL_GENERATED_sources ${SRCSOURCES}) |
| 181 | extract_make_variable(HB_OT_RAGEL_GENERATED_sources ${SRCSOURCES}) |
Behdad Esfahbod | b91e8da | 2018-02-23 22:51:17 -0800 | [diff] [blame] | 182 | #if (IN_HB_DIST) |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 183 | add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/") |
| 184 | add_prefix_to_list(HB_OT_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/") |
Behdad Esfahbod | b91e8da | 2018-02-23 22:51:17 -0800 | [diff] [blame] | 185 | #else () |
| 186 | # add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/") |
| 187 | # add_prefix_to_list(HB_OT_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/") |
| 188 | #endif () |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 189 | |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 190 | extract_make_variable(HB_VIEW_sources ${UTILSOURCES}) |
| 191 | add_prefix_to_list(HB_VIEW_sources "${PROJECT_SOURCE_DIR}/util/") |
| 192 | extract_make_variable(HB_SHAPE_sources ${UTILSOURCES}) |
| 193 | add_prefix_to_list(HB_SHAPE_sources "${PROJECT_SOURCE_DIR}/util/") |
Garret Rieger | f83a43b | 2018-02-02 17:50:45 -0800 | [diff] [blame] | 194 | extract_make_variable(HB_SUBSET_CLI_sources ${UTILSOURCES}) |
| 195 | add_prefix_to_list(HB_SUBSET_CLI_sources "${PROJECT_SOURCE_DIR}/util/") |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 196 | extract_make_variable(HB_OT_SHAPE_CLOSURE_sources ${UTILSOURCES}) |
| 197 | add_prefix_to_list(HB_OT_SHAPE_CLOSURE_sources "${PROJECT_SOURCE_DIR}/util/") |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 198 | |
Ebrahim Byagowi | 2dbdeb1 | 2017-12-29 23:13:29 +0330 | [diff] [blame] | 199 | extract_make_variable(LIBHB_UCDN_sources ${UCDNSOURCES}) |
| 200 | add_prefix_to_list(LIBHB_UCDN_sources "${PROJECT_SOURCE_DIR}/src/hb-ucdn/") |
| 201 | |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 202 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 203 | file(READ configure.ac CONFIGUREAC) |
| 204 | string(REGEX MATCH "\\[(([0-9]+)\\.([0-9]+)\\.([0-9]+))\\]" HB_VERSION_MATCH ${CONFIGUREAC}) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 205 | set (HB_VERSION ${CMAKE_MATCH_1}) |
| 206 | set (HB_VERSION_MAJOR ${CMAKE_MATCH_2}) |
| 207 | set (HB_VERSION_MINOR ${CMAKE_MATCH_3}) |
| 208 | set (HB_VERSION_MICRO ${CMAKE_MATCH_4}) |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 209 | |
ebraminio | d2acaf6 | 2017-04-05 02:21:23 -0700 | [diff] [blame] | 210 | |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 211 | ## Define ragel tasks |
Ebrahim Byagowi | 0eec331 | 2018-02-28 11:53:39 +0330 | [diff] [blame] | 212 | # if (NOT IN_HB_DIST) |
| 213 | # foreach (ragel_output IN ITEMS ${HB_BASE_RAGEL_GENERATED_sources} ${HB_OT_RAGEL_GENERATED_sources}) |
| 214 | # string(REGEX MATCH "([^/]+)\\.hh" temp ${ragel_output}) |
| 215 | # set (target_name ${CMAKE_MATCH_1}) |
| 216 | # add_custom_command(OUTPUT ${ragel_output} |
| 217 | # COMMAND ${RAGEL} -G2 -o ${ragel_output} ${PROJECT_SOURCE_DIR}/src/${target_name}.rl -I ${PROJECT_SOURCE_DIR} ${ARGN} |
| 218 | # DEPENDS ${PROJECT_SOURCE_DIR}/src/${target_name}.rl |
| 219 | # ) |
| 220 | # add_custom_target(harfbuzz_${target_name} DEPENDS ${PROJECT_BINARY_DIR}/src/${target_name}) |
| 221 | # endforeach () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 222 | |
Ebrahim Byagowi | 0eec331 | 2018-02-28 11:53:39 +0330 | [diff] [blame] | 223 | # mark_as_advanced(RAGEL) |
| 224 | # endif () |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 225 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 226 | |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 227 | ## Generate hb-version.h |
Ebrahim Byagowi | 0eec331 | 2018-02-28 11:53:39 +0330 | [diff] [blame] | 228 | # if (NOT IN_HB_DIST) |
Behdad Esfahbod | b91e8da | 2018-02-23 22:51:17 -0800 | [diff] [blame] | 229 | # set (HB_VERSION_H_IN "${PROJECT_SOURCE_DIR}/src/hb-version.h.in") |
| 230 | # set (HB_VERSION_H "${PROJECT_BINARY_DIR}/src/hb-version.h") |
| 231 | # set_source_files_properties("${HB_VERSION_H}" PROPERTIES GENERATED true) |
| 232 | # configure_file("${HB_VERSION_H_IN}" "${HB_VERSION_H}.tmp" @ONLY) |
| 233 | # execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_if_different |
| 234 | # "${HB_VERSION_H}.tmp" |
| 235 | # "${HB_VERSION_H}" |
| 236 | # ) |
| 237 | # file(REMOVE "${HB_VERSION_H}.tmp") |
Ebrahim Byagowi | 0eec331 | 2018-02-28 11:53:39 +0330 | [diff] [blame] | 238 | # endif () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 239 | |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 240 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 241 | ## Define sources and headers of the project |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 242 | set (project_sources |
ebraminio | d2acaf6 | 2017-04-05 02:21:23 -0700 | [diff] [blame] | 243 | ${HB_BASE_sources} |
| 244 | ${HB_BASE_RAGEL_GENERATED_sources} |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 245 | |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 246 | ${HB_FALLBACK_sources} |
ebraminio | d2acaf6 | 2017-04-05 02:21:23 -0700 | [diff] [blame] | 247 | ${HB_OT_sources} |
Behdad Esfahbod | 9682ef1 | 2018-02-08 17:35:57 -0600 | [diff] [blame] | 248 | ${HB_OT_RAGEL_GENERATED_sources} |
Garret Rieger | 0f3c756 | 2018-02-08 14:59:32 -0800 | [diff] [blame] | 249 | ) |
Garret Rieger | f83a43b | 2018-02-02 17:50:45 -0800 | [diff] [blame] | 250 | |
Garret Rieger | 0f3c756 | 2018-02-08 14:59:32 -0800 | [diff] [blame] | 251 | set (subset_project_sources |
Garret Rieger | f83a43b | 2018-02-02 17:50:45 -0800 | [diff] [blame] | 252 | ${HB_SUBSET_sources} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 253 | ) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 254 | |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 255 | set (project_extra_sources) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 256 | |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 257 | set (project_headers |
Behdad Esfahbod | b91e8da | 2018-02-23 22:51:17 -0800 | [diff] [blame] | 258 | #${HB_VERSION_H} |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 259 | |
| 260 | ${HB_BASE_headers} |
| 261 | ${HB_OT_headers} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 262 | ) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 263 | |
Garret Rieger | 0f3c756 | 2018-02-08 14:59:32 -0800 | [diff] [blame] | 264 | set (subset_project_headers |
| 265 | ${HB_SUBSET_headers} |
| 266 | ) |
| 267 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 268 | |
| 269 | ## Find and include needed header folders and libraries |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 270 | if (HB_HAVE_FREETYPE) |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 271 | include (FindFreetype) |
Khaled Hosny | 6760021 | 2017-10-12 12:05:08 +0300 | [diff] [blame] | 272 | if (NOT FREETYPE_FOUND) |
| 273 | 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") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 274 | endif () |
Khaled Hosny | 6760021 | 2017-10-12 12:05:08 +0300 | [diff] [blame] | 275 | |
| 276 | list(APPEND THIRD_PARTY_LIBS ${FREETYPE_LIBRARIES}) |
| 277 | include_directories(AFTER ${FREETYPE_INCLUDE_DIRS}) |
Ebrahim Byagowi | 3d61576 | 2018-01-22 21:23:19 +0330 | [diff] [blame] | 278 | add_definitions(-DHAVE_FREETYPE=1) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 279 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 280 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-ft.cc) |
| 281 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-ft.h) |
Ebrahim Byagowi | 3c7aeb5 | 2018-01-09 01:39:42 +0330 | [diff] [blame] | 282 | |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 283 | # So check_funcs can find its headers |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 284 | set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FREETYPE_INCLUDE_DIRS}) |
| 285 | set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${FREETYPE_LIBRARIES}) |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 286 | |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 287 | check_funcs(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 288 | endif () |
| 289 | |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 290 | if (HB_HAVE_GRAPHITE2) |
| 291 | add_definitions(-DHAVE_GRAPHITE2) |
| 292 | |
| 293 | find_path(GRAPHITE2_INCLUDE_DIR graphite2/Font.h) |
| 294 | find_library(GRAPHITE2_LIBRARY graphite2) |
| 295 | |
| 296 | include_directories(${GRAPHITE2_INCLUDE_DIR}) |
| 297 | |
| 298 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-graphite2.cc) |
| 299 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-graphite2.h) |
| 300 | |
| 301 | list(APPEND THIRD_PARTY_LIBS ${GRAPHITE2_LIBRARY}) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 302 | |
| 303 | mark_as_advanced(GRAPHITE2_INCLUDE_DIR GRAPHITE2_LIBRARY) |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 304 | endif () |
| 305 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 306 | if (HB_BUILTIN_UCDN) |
| 307 | include_directories(src/hb-ucdn) |
| 308 | add_definitions(-DHAVE_UCDN) |
| 309 | |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 310 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-ucdn.cc) |
| 311 | list(APPEND project_extra_sources ${LIBHB_UCDN_sources}) |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 312 | endif () |
| 313 | |
| 314 | if (HB_HAVE_GLIB) |
| 315 | add_definitions(-DHAVE_GLIB) |
| 316 | |
| 317 | # https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGLIB.cmake |
| 318 | find_package(PkgConfig) |
| 319 | pkg_check_modules(PC_GLIB QUIET glib-2.0) |
| 320 | |
| 321 | find_library(GLIB_LIBRARIES NAMES glib-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS}) |
| 322 | 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) |
| 323 | find_path(GLIB_INCLUDE_DIR NAMES glib.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0) |
| 324 | |
| 325 | include_directories(${GLIBCONFIG_INCLUDE_DIR} ${GLIB_INCLUDE_DIR}) |
| 326 | |
| 327 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-glib.cc) |
| 328 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-glib.h) |
| 329 | |
| 330 | list(APPEND THIRD_PARTY_LIBS ${GLIB_LIBRARIES}) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 331 | |
| 332 | mark_as_advanced(GLIB_LIBRARIES GLIBCONFIG_INCLUDE_DIR GLIB_INCLUDE_DIR) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 333 | endif () |
| 334 | |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 335 | if (HB_HAVE_ICU) |
| 336 | add_definitions(-DHAVE_ICU) |
| 337 | |
| 338 | # https://github.com/WebKit/webkit/blob/master/Source/cmake/FindICU.cmake |
| 339 | find_package(PkgConfig) |
| 340 | pkg_check_modules(PC_ICU QUIET icu-uc) |
| 341 | |
| 342 | find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR}) |
| 343 | find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR}) |
| 344 | |
| 345 | include_directories(${ICU_INCLUDE_DIR}) |
| 346 | |
| 347 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-icu.cc) |
| 348 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-icu.h) |
| 349 | |
| 350 | list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY}) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 351 | |
| 352 | mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY) |
ebraminio | adfd4ae | 2017-04-11 23:18:18 +0430 | [diff] [blame] | 353 | endif () |
| 354 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 355 | if (APPLE AND HB_HAVE_CORETEXT) |
| 356 | # Apple Advanced Typography |
| 357 | add_definitions(-DHAVE_CORETEXT) |
| 358 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 359 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-coretext.cc) |
| 360 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-coretext.h) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 361 | |
| 362 | find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 363 | if (APPLICATION_SERVICES_FRAMEWORK) |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 364 | list(APPEND THIRD_PARTY_LIBS ${APPLICATION_SERVICES_FRAMEWORK}) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 365 | endif (APPLICATION_SERVICES_FRAMEWORK) |
Ebrahim Byagowi | 3d61576 | 2018-01-22 21:23:19 +0330 | [diff] [blame] | 366 | |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 367 | mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 368 | endif () |
| 369 | |
| 370 | if (WIN32 AND HB_HAVE_UNISCRIBE) |
| 371 | add_definitions(-DHAVE_UNISCRIBE) |
| 372 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 373 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-uniscribe.cc) |
| 374 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-uniscribe.h) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 375 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 376 | list(APPEND THIRD_PARTY_LIBS usp10 gdi32 rpcrt4) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 377 | endif () |
| 378 | |
| 379 | if (WIN32 AND HB_HAVE_DIRECTWRITE) |
| 380 | add_definitions(-DHAVE_DIRECTWRITE) |
| 381 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 382 | list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-directwrite.cc) |
| 383 | list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-directwrite.h) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 384 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 385 | list(APPEND THIRD_PARTY_LIBS dwrite rpcrt4) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 386 | endif () |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 387 | |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 388 | if (HB_HAVE_GOBJECT) |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 389 | include (FindPerl) |
Ebrahim Byagowi | 3d61576 | 2018-01-22 21:23:19 +0330 | [diff] [blame] | 390 | |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 391 | # Use the hints from glib-2.0.pc to find glib-mkenums |
| 392 | find_package(PkgConfig) |
| 393 | pkg_check_modules(PC_GLIB QUIET glib-2.0) |
| 394 | find_program(GLIB_MKENUMS glib-mkenums |
| 395 | HINTS ${PC_glib_mkenums} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 396 | ) |
| 397 | set (GLIB_MKENUMS_CMD) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 398 | |
| 399 | if (WIN32 AND NOT MINGW) |
| 400 | # In Visual Studio builds, shebang lines are not supported |
| 401 | # in the standard cmd.exe shell that we use, so we need to |
| 402 | # first determine whether glib-mkenums is a Python or PERL |
| 403 | # script |
| 404 | execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}" --version |
| 405 | RESULT_VARIABLE GLIB_MKENUMS_PYTHON |
| 406 | OUTPUT_QUIET ERROR_QUIET |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 407 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 408 | if (GLIB_MKENUMS_PYTHON EQUAL 0) |
| 409 | message("${GLIB_MKENUMS} is a Python script.") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 410 | set (GLIB_MKENUMS_CMD "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}") |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 411 | else () |
| 412 | execute_process(COMMAND "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}" --version |
| 413 | RESULT_VARIABLE GLIB_MKENUMS_PERL |
| 414 | OUTPUT_QUIET ERROR_QUIET |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 415 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 416 | if (GLIB_MKENUMS_PERL EQUAL 0) |
| 417 | message("${GLIB_MKENUMS} is a PERL script.") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 418 | set (GLIB_MKENUMS_CMD "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}") |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 419 | endif () |
| 420 | if (NOT GLIB_MKENUMS_PERL EQUAL 0 AND NOT GLIB_MKENUMS_PYTHON EQUAL 0) |
| 421 | message(FATAL_ERROR "Unable to determine type of glib-mkenums script") |
| 422 | endif () |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 423 | endif () |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 424 | else () |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 425 | set (GLIB_MKENUMS_CMD "${GLIB_MKENUMS}") |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 426 | endif () |
| 427 | if (NOT GLIB_MKENUMS_CMD) |
| 428 | message(FATAL_ERROR "HB_HAVE_GOBJECT was set, but we failed to find glib-mkenums, which is required") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 429 | endif () |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 430 | |
| 431 | pkg_check_modules(PC_GOBJECT QUIET gobject-2.0) |
| 432 | |
| 433 | find_library(GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS}) |
| 434 | find_path(GOBJECT_INCLUDE_DIR NAMES glib-object.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0) |
| 435 | |
| 436 | include_directories(${GOBJECTCONFIG_INCLUDE_DIR} ${GOBJECT_INCLUDE_DIR}) |
| 437 | mark_as_advanced(GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR) |
| 438 | |
| 439 | list(APPEND hb_gobject_sources ${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.cc) |
| 440 | list(APPEND hb_gobject_gen_sources |
| 441 | ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 442 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 443 | list(APPEND hb_gobject_structs_headers |
| 444 | ${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.h |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 445 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 446 | list(APPEND hb_gobject_headers |
| 447 | ${PROJECT_SOURCE_DIR}/src/hb-gobject.h |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 448 | ${hb_gobject_structs_headers} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 449 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 450 | list(APPEND hb_gobject_gen_headers |
| 451 | ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 452 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 453 | |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 454 | add_custom_command( |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 455 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h |
| 456 | COMMAND ${GLIB_MKENUMS_CMD} |
| 457 | --template=${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.h.tmpl |
| 458 | --identifier-prefix hb_ |
| 459 | --symbol-prefix hb_gobject |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 460 | ${hb_gobject_structs_headers} |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 461 | ${project_headers} |
| 462 | > ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h.tmp |
| 463 | COMMAND "${CMAKE_COMMAND}" |
| 464 | "-DENUM_INPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h.tmp" |
| 465 | "-DENUM_OUTPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h" |
| 466 | -P ${PROJECT_SOURCE_DIR}/replace-enum-strings.cmake |
| 467 | DEPENDS ${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.h.tmpl |
| 468 | ${hb_gobject_header} |
| 469 | ${project_headers} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 470 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 471 | |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 472 | add_custom_command( |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 473 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc |
| 474 | COMMAND ${GLIB_MKENUMS_CMD} |
| 475 | --template=${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.cc.tmpl |
| 476 | --identifier-prefix hb_ |
| 477 | --symbol-prefix hb_gobject |
| 478 | ${hb_gobject_header} |
| 479 | ${project_headers} |
| 480 | > ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc.tmp |
| 481 | COMMAND "${CMAKE_COMMAND}" |
| 482 | "-DENUM_INPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc.tmp" |
| 483 | "-DENUM_OUTPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc" |
| 484 | -P ${PROJECT_SOURCE_DIR}/replace-enum-strings.cmake |
| 485 | DEPENDS ${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.cc.tmpl |
| 486 | ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h |
| 487 | ${hb_gobject_header} |
| 488 | ${project_headers} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 489 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 490 | endif () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 491 | |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 492 | |
ebraminio | a41d5ea | 2017-04-14 04:25:50 +0430 | [diff] [blame] | 493 | ## Atomic ops availability detection |
| 494 | file(WRITE "${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c" |
| 495 | " void memory_barrier (void) { __sync_synchronize (); } |
| 496 | int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); } |
| 497 | int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); } |
| 498 | void mutex_unlock (int *m) { __sync_lock_release (m); } |
ebraminio | 7593142 | 2017-04-14 05:08:11 +0430 | [diff] [blame] | 499 | int main () { return 0; } |
ebraminio | a41d5ea | 2017-04-14 04:25:50 +0430 | [diff] [blame] | 500 | ") |
| 501 | try_compile(HB_HAVE_INTEL_ATOMIC_PRIMITIVES |
| 502 | ${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives |
rdb | 5e14e5f | 2018-01-16 17:04:33 +0100 | [diff] [blame] | 503 | ${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c) |
ebraminio | a41d5ea | 2017-04-14 04:25:50 +0430 | [diff] [blame] | 504 | if (HB_HAVE_INTEL_ATOMIC_PRIMITIVES) |
| 505 | add_definitions(-DHAVE_INTEL_ATOMIC_PRIMITIVES) |
| 506 | endif () |
| 507 | |
| 508 | file(WRITE "${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c" |
| 509 | " #include <atomic.h> |
| 510 | /* This requires Solaris Studio 12.2 or newer: */ |
| 511 | #include <mbarrier.h> |
| 512 | void memory_barrier (void) { __machine_rw_barrier (); } |
| 513 | int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); } |
| 514 | void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); } |
ebraminio | 7593142 | 2017-04-14 05:08:11 +0430 | [diff] [blame] | 515 | int main () { return 0; } |
ebraminio | a41d5ea | 2017-04-14 04:25:50 +0430 | [diff] [blame] | 516 | ") |
| 517 | try_compile(HB_HAVE_SOLARIS_ATOMIC_OPS |
| 518 | ${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops |
rdb | 5e14e5f | 2018-01-16 17:04:33 +0100 | [diff] [blame] | 519 | ${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c) |
ebraminio | cb021e1 | 2017-04-14 04:31:17 +0430 | [diff] [blame] | 520 | if (HB_HAVE_SOLARIS_ATOMIC_OPS) |
| 521 | add_definitions(-DHAVE_SOLARIS_ATOMIC_OPS) |
ebraminio | a41d5ea | 2017-04-14 04:25:50 +0430 | [diff] [blame] | 522 | endif () |
ebraminio | a41d5ea | 2017-04-14 04:25:50 +0430 | [diff] [blame] | 523 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 524 | |
| 525 | ## Define harfbuzz library |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 526 | add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers}) |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 527 | target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) |
| 528 | |
Garret Rieger | 0f3c756 | 2018-02-08 14:59:32 -0800 | [diff] [blame] | 529 | ## Define harfbuzz-subset library |
| 530 | add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers}) |
| 531 | add_dependencies(harfbuzz-subset harfbuzz) |
| 532 | target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS}) |
| 533 | |
Ebrahim Byagowi | ac92ed7 | 2018-05-08 01:05:15 +0430 | [diff] [blame] | 534 | if (BUILD_SHARED_LIBS) |
| 535 | set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) |
| 536 | endif () |
| 537 | |
Ebrahim Byagowi | 90f01ba | 2018-01-16 22:00:21 +0330 | [diff] [blame] | 538 | if (UNIX OR MINGW) |
| 539 | # Make symbols link locally |
Ebrahim Byagowi | eff36cd | 2018-03-30 22:25:35 +0430 | [diff] [blame] | 540 | include (CheckCXXCompilerFlag) |
Joel Winarske | d68f00e | 2018-03-16 12:14:27 -0700 | [diff] [blame] | 541 | check_cxx_compiler_flag(-Bsymbolic-functions CXX_SUPPORTS_FLAG_BSYMB_FUNCS) |
Ebrahim Byagowi | eff36cd | 2018-03-30 22:25:35 +0430 | [diff] [blame] | 542 | if (CXX_SUPPORTS_FLAG_BSYMB_FUNCS) |
Joel Winarske | d68f00e | 2018-03-16 12:14:27 -0700 | [diff] [blame] | 543 | link_libraries(-Bsymbolic-functions) |
Ebrahim Byagowi | eff36cd | 2018-03-30 22:25:35 +0430 | [diff] [blame] | 544 | endif () |
Ebrahim Byagowi | 90f01ba | 2018-01-16 22:00:21 +0330 | [diff] [blame] | 545 | |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 546 | if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
Ebrahim Byagowi | 844f48e | 2018-02-10 23:13:12 +0330 | [diff] [blame] | 547 | # Make sure we don't link to libstdc++ |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 548 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") |
| 549 | set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm |
| 550 | set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "") |
| 551 | set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C) |
Garret Rieger | 0f3c756 | 2018-02-08 14:59:32 -0800 | [diff] [blame] | 552 | set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C) |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 553 | |
Ebrahim Byagowi | 844f48e | 2018-02-10 23:13:12 +0330 | [diff] [blame] | 554 | # No threadsafe statics as we do it ourselves |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 555 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics") |
Ebrahim Byagowi | 90f01ba | 2018-01-16 22:00:21 +0330 | [diff] [blame] | 556 | endif () |
| 557 | endif () |
| 558 | |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 559 | ## Define harfbuzz-gobject library |
| 560 | if (HB_HAVE_GOBJECT) |
| 561 | add_library(harfbuzz-gobject |
| 562 | ${hb_gobject_sources} |
| 563 | ${hb_gobject_gen_sources} |
| 564 | ${hb_gobject_headers} |
| 565 | ${hb_gobject_gen_headers} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 566 | ) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 567 | include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src) |
| 568 | add_dependencies(harfbuzz-gobject harfbuzz) |
| 569 | target_link_libraries(harfbuzz-gobject harfbuzz ${GOBJECT_LIBRARIES} ${THIRD_PARTY_LIBS}) |
Ebrahim Byagowi | ac92ed7 | 2018-05-08 01:05:15 +0430 | [diff] [blame] | 570 | |
| 571 | if (BUILD_SHARED_LIBS) |
| 572 | set_target_properties(harfbuzz-gobject PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) |
| 573 | endif () |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 574 | endif () |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 575 | |
Ebrahim Byagowi | 42d3271 | 2018-03-16 22:39:58 +0330 | [diff] [blame] | 576 | if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW) |
| 577 | add_definitions("-DHB_EXTERN=__declspec(dllexport) extern") |
Nikolaus Waxweiler | 22de9bf | 2018-03-14 10:29:24 +0000 | [diff] [blame] | 578 | endif () |
| 579 | |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 580 | # On Windows, g-ir-scanner requires a DLL build in order for it to work |
| 581 | if (WIN32) |
| 582 | if (NOT BUILD_SHARED_LIBS) |
| 583 | message("Building introspection files on Windows requires BUILD_SHARED_LIBS to be enabled.") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 584 | set (HB_HAVE_INTROSPECTION OFF) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 585 | endif () |
| 586 | endif () |
| 587 | |
| 588 | if (HB_HAVE_INTROSPECTION) |
| 589 | |
| 590 | find_package(PkgConfig) |
| 591 | pkg_check_modules(PC_GI QUIET gobject-introspection-1.0) |
| 592 | |
| 593 | find_program(G_IR_SCANNER g-ir-scanner |
| 594 | HINTS ${PC_g_ir_scanner} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 595 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 596 | |
| 597 | find_program(G_IR_COMPILER g-ir-compiler |
| 598 | HINTS ${PC_g_ir_compiler} |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 599 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 600 | |
| 601 | if (WIN32 AND NOT MINGW) |
| 602 | # Note that since we already enable HB_HAVE_GOBJECT |
| 603 | # we would already have PYTHON_EXECUTABLE handy |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 604 | set (G_IR_SCANNER_CMD "${PYTHON_EXECUTABLE}" "${G_IR_SCANNER}") |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 605 | else () |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 606 | set (G_IR_SCANNER_CMD "${G_IR_SCANNER}") |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 607 | endif () |
| 608 | |
| 609 | # We need to account for the varying output directories |
| 610 | # when we build using Visual Studio projects |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 611 | if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*") |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 612 | set (hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>") |
| 613 | else () |
| 614 | set (hb_libpath "$<TARGET_FILE_DIR:harfbuzz-gobject>") |
| 615 | endif () |
| 616 | |
| 617 | # Get the CFlags that we used to build HarfBuzz/HarfBuzz-GObject |
| 618 | set (hb_defines_cflags "") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 619 | foreach (hb_cflag ${hb_cflags}) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 620 | list(APPEND hb_defines_cflags "-D${hb_cflag}") |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 621 | endforeach (hb_cflag) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 622 | |
| 623 | # Get the other dependent libraries we used to build HarfBuzz/HarfBuzz-GObject |
| 624 | set (extra_libs "") |
| 625 | foreach (extra_lib ${THIRD_PARTY_LIBS}) |
| 626 | # We don't want the .lib extension here... |
| 627 | string(REPLACE ".lib" "" extra_lib_stripped "${extra_lib}") |
| 628 | list(APPEND extra_libs "--extra-library=${extra_lib_stripped}") |
| 629 | endforeach () |
| 630 | |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 631 | set (introspected_sources) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 632 | foreach (f |
| 633 | ${project_headers} |
| 634 | ${project_sources} |
| 635 | ${hb_gobject_gen_sources} |
| 636 | ${hb_gobject_gen_headers} |
| 637 | ${hb_gobject_sources} |
| 638 | ${hb_gobject_headers} |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 639 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 640 | if (WIN32) |
| 641 | # Nasty issue: We need to make drive letters lower case, |
| 642 | # otherwise g-ir-scanner won't like it and give us a bunch |
| 643 | # of invalid items and unresolved types... |
| 644 | STRING(SUBSTRING "${f}" 0 1 drive) |
| 645 | STRING(SUBSTRING "${f}" 1 -1 path) |
| 646 | if (drive MATCHES "[A-Z]") |
| 647 | STRING(TOLOWER ${drive} drive_lower) |
| 648 | list(APPEND introspected_sources "${drive_lower}${path}") |
| 649 | else () |
| 650 | list(APPEND introspected_sources "${f}") |
| 651 | endif () |
| 652 | else () |
| 653 | list(APPEND introspected_sources "${f}") |
| 654 | endif () |
| 655 | endforeach () |
| 656 | |
Chun-wei Fan | e9b8002 | 2018-03-12 16:23:57 +0800 | [diff] [blame] | 657 | file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list) |
| 658 | foreach (s ${introspected_sources}) |
| 659 | file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list "${s}\n") |
| 660 | endforeach () |
| 661 | |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 662 | # Finally, build the introspection files... |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 663 | add_custom_command( |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 664 | TARGET harfbuzz-gobject |
| 665 | POST_BUILD |
| 666 | COMMAND ${G_IR_SCANNER_CMD} |
| 667 | --warn-all --no-libtool --verbose |
| 668 | -n hb |
| 669 | --namespace=HarfBuzz |
| 670 | --nsversion=0.0 |
| 671 | --identifier-prefix=hb_ |
| 672 | --include GObject-2.0 |
| 673 | --pkg-export=harfbuzz |
| 674 | --cflags-begin |
| 675 | -I${PROJECT_SOURCE_DIR}/src |
| 676 | -I${PROJECT_BINARY_DIR}/src |
| 677 | ${hb_includedir_cflags} |
| 678 | ${hb_defines_cflags} |
| 679 | -DHB_H |
| 680 | -DHB_H_IN |
| 681 | -DHB_OT_H |
| 682 | -DHB_OT_H_IN |
| 683 | -DHB_GOBJECT_H |
| 684 | -DHB_GOBJECT_H_IN |
| 685 | -DHB_EXTERN= |
| 686 | --cflags-end |
| 687 | --library=harfbuzz-gobject |
| 688 | --library=harfbuzz |
| 689 | -L${hb_libpath} |
| 690 | ${extra_libs} |
Chun-wei Fan | e9b8002 | 2018-03-12 16:23:57 +0800 | [diff] [blame] | 691 | --filelist ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 692 | -o ${hb_libpath}/HarfBuzz-0.0.gir |
Chun-wei Fan | e9b8002 | 2018-03-12 16:23:57 +0800 | [diff] [blame] | 693 | DEPENDS harfbuzz-gobject harfbuzz ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 694 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 695 | |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 696 | add_custom_command( |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 697 | TARGET harfbuzz-gobject |
| 698 | POST_BUILD |
| 699 | COMMAND "${G_IR_COMPILER}" |
| 700 | --verbose --debug |
| 701 | --includedir ${CMAKE_CURRENT_BINARY_DIR} |
| 702 | ${hb_libpath}/HarfBuzz-0.0.gir |
| 703 | -o ${hb_libpath}/HarfBuzz-0.0.typelib |
| 704 | DEPENDS ${hb_libpath}/HarfBuzz-0.0.gir harfbuzz-gobject |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 705 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 706 | endif () |
| 707 | |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 708 | |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 709 | ## Additional framework build configs |
| 710 | if (BUILD_FRAMEWORK) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 711 | set (CMAKE_MACOSX_RPATH ON) |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 712 | set_target_properties(harfbuzz PROPERTIES |
| 713 | FRAMEWORK TRUE |
| 714 | PUBLIC_HEADER "${project_headers}" |
| 715 | XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" |
| 716 | ) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 717 | set (MACOSX_FRAMEWORK_IDENTIFIER "harfbuzz") |
| 718 | set (MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${HB_VERSION}") |
| 719 | set (MACOSX_FRAMEWORK_BUNDLE_VERSION "${HB_VERSION}") |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 720 | endif () |
| 721 | |
| 722 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 723 | ## Additional harfbuzz build artifacts |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 724 | if (HB_BUILD_UTILS) |
| 725 | # https://github.com/WebKit/webkit/blob/master/Source/cmake/FindCairo.cmake |
| 726 | find_package(PkgConfig) |
| 727 | pkg_check_modules(PC_CAIRO QUIET cairo) |
| 728 | |
| 729 | find_path(CAIRO_INCLUDE_DIRS NAMES cairo.h HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIRS} PATH_SUFFIXES cairo) |
| 730 | find_library(CAIRO_LIBRARIESNAMES cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS}) |
| 731 | |
| 732 | add_definitions("-DPACKAGE_NAME=\"HarfBuzz\"") |
| 733 | add_definitions("-DPACKAGE_VERSION=\"${HB_VERSION}\"") |
| 734 | include_directories(${CAIRO_INCLUDE_DIRS}) |
| 735 | |
| 736 | add_executable(hb-view ${HB_VIEW_sources}) |
| 737 | target_link_libraries(hb-view harfbuzz ${CAIRO_LIBRARIESNAMES}) |
| 738 | |
| 739 | add_executable(hb-shape ${HB_SHAPE_sources}) |
| 740 | target_link_libraries(hb-shape harfbuzz) |
| 741 | |
Garret Rieger | f83a43b | 2018-02-02 17:50:45 -0800 | [diff] [blame] | 742 | add_executable(hb-subset ${HB_SUBSET_CLI_sources}) |
Garret Rieger | 0f3c756 | 2018-02-08 14:59:32 -0800 | [diff] [blame] | 743 | target_link_libraries(hb-subset harfbuzz harfbuzz-subset) |
Garret Rieger | f83a43b | 2018-02-02 17:50:45 -0800 | [diff] [blame] | 744 | |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 745 | add_executable(hb-ot-shape-closure ${HB_OT_SHAPE_CLOSURE_sources}) |
| 746 | target_link_libraries(hb-ot-shape-closure harfbuzz) |
ebraminio | 6966413 | 2017-04-19 22:59:46 +0430 | [diff] [blame] | 747 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 748 | mark_as_advanced(CAIRO_INCLUDE_DIRS CAIRO_LIBRARIESNAMES) |
ebraminio | 3a8bc57 | 2017-04-11 21:32:14 +0430 | [diff] [blame] | 749 | endif () |
| 750 | |
Ebrahim Byagowi | bf50dda | 2017-05-04 20:31:42 +0430 | [diff] [blame] | 751 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 752 | ## Install |
Ebrahim Byagowi | 71e0ed9 | 2018-01-10 15:45:12 +0330 | [diff] [blame] | 753 | include (GNUInstallDirs) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 754 | |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 755 | if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 756 | install(FILES ${project_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 757 | if (HB_HAVE_GOBJECT) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 758 | install(FILES ${hb_gobject_headers} ${hb_gobject_gen_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz) |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 759 | endif () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 760 | endif () |
| 761 | |
| 762 | if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) |
| 763 | install(TARGETS harfbuzz |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 764 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 765 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 766 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Ebrahim Byagowi | 1527369 | 2017-05-13 21:32:56 +0430 | [diff] [blame] | 767 | FRAMEWORK DESTINATION Library/Frameworks |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 768 | ) |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 769 | if (HB_BUILD_UTILS) |
| 770 | install(TARGETS hb-view |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 771 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 772 | ) |
Chun-wei Fan | 7c43ada | 2018-03-12 16:43:53 +0800 | [diff] [blame] | 773 | install(TARGETS hb-subset |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 774 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 775 | ) |
| 776 | |
| 777 | install(TARGETS hb-shape |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 778 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 779 | ) |
| 780 | |
| 781 | install(TARGETS hb-ot-shape-closure |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 782 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Chun-wei Fan | 162575f | 2017-10-18 22:27:28 +0800 | [diff] [blame] | 783 | ) |
| 784 | endif () |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 785 | if (HB_HAVE_GOBJECT) |
| 786 | install(TARGETS harfbuzz-gobject |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 787 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 788 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 789 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 790 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 791 | if (HB_HAVE_INTROSPECTION) |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 792 | if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*") |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 793 | set (hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>") |
| 794 | else () |
| 795 | set (hb_libpath "$<TARGET_FILE_DIR:harfbuzz-gobject>") |
| 796 | endif () |
| 797 | |
| 798 | install(FILES "${hb_libpath}/HarfBuzz-0.0.gir" |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 799 | DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0 |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 800 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 801 | |
| 802 | install(FILES "${hb_libpath}/HarfBuzz-0.0.typelib" |
Ebrahim Byagowi | 24b30fa | 2017-12-25 22:01:28 +0330 | [diff] [blame] | 803 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0 |
| 804 | ) |
Chun-wei Fan | 41b1825 | 2017-10-19 18:36:32 +0800 | [diff] [blame] | 805 | endif () |
Chun-wei Fan | 53db221 | 2017-10-18 15:43:57 +0800 | [diff] [blame] | 806 | endif () |
ebraminio | 7d64c0e | 2017-04-04 15:03:51 +0430 | [diff] [blame] | 807 | endif () |
Khaled Hosny | c860955 | 2017-12-06 00:43:28 +0200 | [diff] [blame] | 808 | |
Bruce Mitchener | 4f80078 | 2018-01-04 18:37:35 +0700 | [diff] [blame] | 809 | if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja") |
| 810 | if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 811 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") |
| 812 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics") |
Bruce Mitchener | 4f80078 | 2018-01-04 18:37:35 +0700 | [diff] [blame] | 813 | endif () |
| 814 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 815 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color") |
| 816 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color") |
Bruce Mitchener | 4f80078 | 2018-01-04 18:37:35 +0700 | [diff] [blame] | 817 | endif () |
| 818 | endif () |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 819 | |
Ebrahim Byagowi | 72bec1c | 2018-01-05 12:42:20 +0330 | [diff] [blame] | 820 | |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 821 | ## src/ executables |
Ebrahim Byagowi | 0eec331 | 2018-02-28 11:53:39 +0330 | [diff] [blame] | 822 | foreach (prog main test test-would-substitute test-size-params test-buffer-serialize hb-ot-tag test-unicode-ranges) |
| 823 | set (prog_name ${prog}) |
| 824 | if (${prog_name} STREQUAL "test") |
| 825 | # test can not be used as a valid executable name on cmake, lets special case it |
| 826 | set (prog_name test-test) |
| 827 | endif () |
| 828 | add_executable(${prog_name} ${PROJECT_SOURCE_DIR}/src/${prog}.cc) |
| 829 | target_link_libraries(${prog_name} harfbuzz ${THIRD_PARTY_LIBS}) |
| 830 | endforeach () |
| 831 | set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN") |
Ebrahim Byagowi | 29d9012 | 2018-01-30 10:01:46 +0330 | [diff] [blame] | 832 | |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 833 | ## Tests |
Ebrahim Byagowi | 90f01ba | 2018-01-16 22:00:21 +0330 | [diff] [blame] | 834 | if (UNIX OR MINGW) |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 835 | if (BUILD_SHARED_LIBS) |
Ebrahim Byagowi | 3d61576 | 2018-01-22 21:23:19 +0330 | [diff] [blame] | 836 | # generate harfbuzz.def after build completion |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 837 | add_custom_command(TARGET harfbuzz POST_BUILD |
Cosimo Lupo | 53f7340 | 2018-07-09 18:54:23 +0100 | [diff] [blame] | 838 | COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers} |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 839 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) |
Ebrahim Byagowi | c97a7ec | 2018-01-16 14:18:09 +0330 | [diff] [blame] | 840 | |
Ebrahim Byagowi | 0080614 | 2018-01-19 01:12:31 +0330 | [diff] [blame] | 841 | add_test(NAME check-static-inits.sh |
| 842 | COMMAND ${PROJECT_SOURCE_DIR}/src/check-static-inits.sh |
| 843 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/harfbuzz.dir/src # ugly hack |
| 844 | ) |
| 845 | add_test(NAME check-libstdc++.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-libstdc++.sh) |
Ebrahim Byagowi | 3d61576 | 2018-01-22 21:23:19 +0330 | [diff] [blame] | 846 | add_test(NAME check-symbols.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-symbols.sh) |
Ebrahim Byagowi | 8b60e7c | 2018-01-22 18:37:26 +0330 | [diff] [blame] | 847 | |
Ebrahim Byagowi | a9b650d | 2018-02-12 15:10:13 +0330 | [diff] [blame] | 848 | set_tests_properties( |
Behdad Esfahbod | e0939d8 | 2018-02-23 13:19:34 -0800 | [diff] [blame] | 849 | check-static-inits.sh check-libstdc++.sh check-symbols.sh |
Ebrahim Byagowi | a9b650d | 2018-02-12 15:10:13 +0330 | [diff] [blame] | 850 | PROPERTIES |
| 851 | ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src" |
| 852 | SKIP_RETURN_CODE 77) |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 853 | endif () |
| 854 | |
Ebrahim Byagowi | 90f01ba | 2018-01-16 22:00:21 +0330 | [diff] [blame] | 855 | add_test(NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh) |
| 856 | add_test(NAME check-header-guards.sh COMMAND ./check-header-guards.sh) |
| 857 | add_test(NAME check-externs.sh COMMAND ./check-externs.sh) |
| 858 | add_test(NAME check-includes.sh COMMAND ./check-includes.sh) |
| 859 | set_tests_properties( |
| 860 | check-c-linkage-decls.sh check-header-guards.sh check-externs.sh check-includes.sh |
Ebrahim Byagowi | a9b650d | 2018-02-12 15:10:13 +0330 | [diff] [blame] | 861 | PROPERTIES |
| 862 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src |
| 863 | SKIP_RETURN_CODE 77) |
Ebrahim Byagowi | 5ed26fc | 2018-01-04 10:11:34 +0330 | [diff] [blame] | 864 | endif () |
| 865 | |
Khaled Hosny | c860955 | 2017-12-06 00:43:28 +0200 | [diff] [blame] | 866 | # Needs to come last so that variables defined above are passed to |
| 867 | # subdirectories. |
rdb | 5e14e5f | 2018-01-16 17:04:33 +0100 | [diff] [blame] | 868 | add_subdirectory(test) |