CMakeLists.txt 29.2 KB
Newer Older
E
ebraminio 已提交
1 2 3
cmake_minimum_required(VERSION 2.8.0)
project(harfbuzz)

K
Khaled Hosny 已提交
4
enable_testing()
5 6 7

## Limit framework build to Xcode generator
if (BUILD_FRAMEWORK)
8 9
  # for a framework build on macOS, use:
  # cmake -DBUILD_FRAMEWORK=ON -Bbuild -H. -GXcode && cmake --build build
10 11 12 13
  if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
    message(FATAL_ERROR
      "You should use Xcode generator with BUILD_FRAMEWORK enabled")
  endif ()
14 15 16
  set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
  set (CMAKE_MACOSX_RPATH ON)
  set (BUILD_SHARED_LIBS ON)
17 18 19
endif ()


E
Ebrahim Byagowi 已提交
20 21
## 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}")
E
ebraminio 已提交
22 23 24 25 26 27 28 29 30 31 32
  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 ()
E
Ebrahim Byagowi 已提交
33

E
ebraminio 已提交
34 35

## HarfBuzz build configurations
36 37 38 39
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)
E
ebraminio 已提交
40 41
if (APPLE)
  option(HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON)
42
  set (CMAKE_MACOSX_RPATH ON)
E
ebraminio 已提交
43 44 45
endif ()
if (WIN32)
  option(HB_HAVE_UNISCRIBE "Enable Uniscribe shaper backend on Windows" OFF)
C
Chun-wei Fan 已提交
46
  option(HB_HAVE_DIRECTWRITE "Enable DirectWrite shaper backend on Windows" OFF)
E
ebraminio 已提交
47
endif ()
48 49
option(HB_BUILD_UTILS "Build harfbuzz utils, needs cairo, freetype, and glib properly be installed" OFF)
if (HB_BUILD_UTILS)
50 51
  set (HB_HAVE_GLIB ON)
  set (HB_HAVE_FREETYPE ON)
52
endif ()
E
ebraminio 已提交
53

54 55 56
option(HB_BUILD_SUBSET "Build harfbuzz-subset" ON)
option(HB_BUILD_TESTS "Build harfbuzz tests" ON)

57 58
option(HB_HAVE_GOBJECT "Enable GObject Bindings" OFF)
if (HB_HAVE_GOBJECT)
59
  set (HB_HAVE_GLIB ON)
60 61
endif ()

62 63
option(HB_HAVE_INTROSPECTION "Enable building introspection (.gir/.typelib) files" OFF)
if (HB_HAVE_INTROSPECTION)
64 65
  set (HB_HAVE_GOBJECT ON)
  set (HB_HAVE_GLIB ON)
66 67
endif ()

E
Ebrahim Byagowi 已提交
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
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)
    set (HB_HAVE_DIRECTWRITE ON)
  elseif (APPLE)
    set (HB_HAVE_CORETEXT ON)
  endif ()
endif ()

E
ebraminio 已提交
86
include_directories(AFTER
87
  ${PROJECT_SOURCE_DIR}/src
E
ebraminio 已提交
88
  ${PROJECT_BINARY_DIR}/src
E
Ebrahim Byagowi 已提交
89
)
E
ebraminio 已提交
90

91 92
# We need PYTHON_EXECUTABLE to be set for running the tests...
include (FindPythonInterp)
93

E
Ebrahim Byagowi 已提交
94
## Functions and headers
95 96 97 98
include (CheckFunctionExists)
include (CheckIncludeFile)
macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools
  foreach (func_name ${ARGN})
B
Bruce Mitchener 已提交
99 100 101 102
    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})
103 104 105
    endif ()
  endforeach ()
endmacro ()
106 107 108
if (UNIX)
  list(APPEND CMAKE_REQUIRED_LIBRARIES m)
endif ()
E
Ebrahim Byagowi 已提交
109
check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l)
E
Ebrahim Byagowi 已提交
110 111 112 113 114 115 116
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)
117 118 119 120 121
endif ()
check_include_file(xlocale.h HAVE_XLOCALE_H)
if (${HAVE_XLOCALE_H})
  add_definitions(-DHAVE_XLOCALE_H)
endif ()
122 123 124 125
check_include_file(stdbool.h HAVE_STDBOOL_H)
if (${HAVE_STDBOOL_H})
  add_definitions(-DHAVE_STDBOOL_H)
endif ()
126

E
ebraminio 已提交
127 128 129 130 131

if (MSVC)
  add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
endif ()

E
Ebrahim Byagowi 已提交
132

133
## Detect if we are running inside a distribution or regular repository folder
E
Ebrahim Byagowi 已提交
134 135 136 137 138
# 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 ()
E
ebraminio 已提交
139

E
Ebrahim Byagowi 已提交
140

141
## Extract variables from Makefile files
142 143 144 145 146 147 148 149
function (extract_make_variable variable makefile_source)
  string(REGEX MATCH "${variable} = ([^$]+)\\$" temp ${makefile_source})
  string(REGEX MATCHALL "[^ \n\t\\]+" listVar ${CMAKE_MATCH_1})
  set (${variable} ${listVar} PARENT_SCOPE)
endfunction ()

# http://stackoverflow.com/a/27630120
function (add_prefix_to_list var prefix)
150
  set (listVar "")
151
  foreach (f ${${var}})
152
    list(APPEND listVar "${prefix}${f}")
153
  endforeach ()
154
  set (${var} "${listVar}" PARENT_SCOPE)
155 156
endfunction ()

E
ebraminio 已提交
157 158
file(READ ${PROJECT_SOURCE_DIR}/src/Makefile.sources SRCSOURCES)
file(READ ${PROJECT_SOURCE_DIR}/util/Makefile.sources UTILSOURCES)
159

160 161 162 163 164 165 166
extract_make_variable(HB_BASE_sources ${SRCSOURCES})
add_prefix_to_list(HB_BASE_sources "${PROJECT_SOURCE_DIR}/src/")
extract_make_variable(HB_BASE_headers ${SRCSOURCES})
add_prefix_to_list(HB_BASE_headers "${PROJECT_SOURCE_DIR}/src/")
extract_make_variable(HB_FALLBACK_sources ${SRCSOURCES})
add_prefix_to_list(HB_FALLBACK_sources "${PROJECT_SOURCE_DIR}/src/")

167 168 169 170 171 172
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/")

173
extract_make_variable(HB_BASE_RAGEL_GENERATED_sources ${SRCSOURCES})
174
#if (IN_HB_DIST)
175
  add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/")
176 177 178
#else ()
#  add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/")
#endif ()
179

180 181 182 183
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/")
184 185
extract_make_variable(HB_SUBSET_CLI_sources ${UTILSOURCES})
add_prefix_to_list(HB_SUBSET_CLI_sources "${PROJECT_SOURCE_DIR}/util/")
186 187 188
extract_make_variable(HB_OT_SHAPE_CLOSURE_sources ${UTILSOURCES})
add_prefix_to_list(HB_OT_SHAPE_CLOSURE_sources "${PROJECT_SOURCE_DIR}/util/")

189

190 191
file(READ configure.ac CONFIGUREAC)
string(REGEX MATCH "\\[(([0-9]+)\\.([0-9]+)\\.([0-9]+))\\]" HB_VERSION_MATCH ${CONFIGUREAC})
192 193 194 195
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})
E
Ebrahim Byagowi 已提交
196

197

198
## Define ragel tasks
E
Ebrahim Byagowi 已提交
199
# if (NOT IN_HB_DIST)
B
Behdad Esfahbod 已提交
200
#  foreach (ragel_output IN ITEMS ${HB_BASE_RAGEL_GENERATED_sources})
E
Ebrahim Byagowi 已提交
201 202 203 204 205 206 207 208
#    string(REGEX MATCH "([^/]+)\\.hh" temp ${ragel_output})
#    set (target_name ${CMAKE_MATCH_1})
#    add_custom_command(OUTPUT ${ragel_output}
#      COMMAND ${RAGEL} -G2 -o ${ragel_output} ${PROJECT_SOURCE_DIR}/src/${target_name}.rl -I ${PROJECT_SOURCE_DIR} ${ARGN}
#      DEPENDS ${PROJECT_SOURCE_DIR}/src/${target_name}.rl
#    )
#    add_custom_target(harfbuzz_${target_name} DEPENDS ${PROJECT_BINARY_DIR}/src/${target_name})
#  endforeach ()
E
ebraminio 已提交
209

E
Ebrahim Byagowi 已提交
210 211
#  mark_as_advanced(RAGEL)
# endif ()
E
Ebrahim Byagowi 已提交
212

E
ebraminio 已提交
213

214
## Generate hb-version.h
E
Ebrahim Byagowi 已提交
215
# if (NOT IN_HB_DIST)
216 217 218 219 220 221 222 223 224
#  set (HB_VERSION_H_IN "${PROJECT_SOURCE_DIR}/src/hb-version.h.in")
#  set (HB_VERSION_H "${PROJECT_BINARY_DIR}/src/hb-version.h")
#  set_source_files_properties("${HB_VERSION_H}" PROPERTIES GENERATED true)
#  configure_file("${HB_VERSION_H_IN}" "${HB_VERSION_H}.tmp" @ONLY)
#  execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_if_different
#    "${HB_VERSION_H}.tmp"
#    "${HB_VERSION_H}"
#  )
#  file(REMOVE "${HB_VERSION_H}.tmp")
E
Ebrahim Byagowi 已提交
225
# endif ()
E
ebraminio 已提交
226

227

228
## Define sources and headers of the project
229
set (project_sources
230 231
  ${HB_BASE_sources}
  ${HB_BASE_RAGEL_GENERATED_sources}
E
ebraminio 已提交
232

C
Chun-wei Fan 已提交
233
  ${HB_FALLBACK_sources}
234
)
235

236
set (subset_project_sources
237
  ${HB_SUBSET_sources}
238
)
E
ebraminio 已提交
239

240
set (project_extra_sources)
241

242
set (project_headers
243
  #${HB_VERSION_H}
E
ebraminio 已提交
244 245

  ${HB_BASE_headers}
246
)
E
ebraminio 已提交
247

248 249 250 251
set (subset_project_headers
  ${HB_SUBSET_headers}
)

E
Ebrahim Byagowi 已提交
252 253

## Find and include needed header folders and libraries
E
ebraminio 已提交
254
if (HB_HAVE_FREETYPE)
255
  include (FindFreetype)
256 257
  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")
258
  endif ()
E
ebraminio 已提交
259

260 261
  list(APPEND THIRD_PARTY_LIBS ${FREETYPE_LIBRARIES})
  include_directories(AFTER ${FREETYPE_INCLUDE_DIRS})
262
  add_definitions(-DHAVE_FREETYPE=1)
E
ebraminio 已提交
263

264 265
  list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-ft.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-ft.h)
266

267
  # So check_funcs can find its headers
268 269
  set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FREETYPE_INCLUDE_DIRS})
  set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${FREETYPE_LIBRARIES})
270

271
  check_funcs(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var)
E
ebraminio 已提交
272 273
endif ()

274 275 276 277 278 279 280 281 282 283 284 285
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_sources ${PROJECT_SOURCE_DIR}/src/hb-graphite2.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-graphite2.h)

  list(APPEND THIRD_PARTY_LIBS ${GRAPHITE2_LIBRARY})
E
ebraminio 已提交
286 287

  mark_as_advanced(GRAPHITE2_INCLUDE_DIR GRAPHITE2_LIBRARY)
288 289
endif ()

290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
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_sources ${PROJECT_SOURCE_DIR}/src/hb-glib.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-glib.h)

  list(APPEND THIRD_PARTY_LIBS ${GLIB_LIBRARIES})
E
ebraminio 已提交
307 308

  mark_as_advanced(GLIB_LIBRARIES GLIBCONFIG_INCLUDE_DIR GLIB_INCLUDE_DIR)
E
ebraminio 已提交
309 310
endif ()

311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
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_sources ${PROJECT_SOURCE_DIR}/src/hb-icu.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-icu.h)

  list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY})
E
ebraminio 已提交
327 328

  mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY)
329 330
endif ()

E
ebraminio 已提交
331 332 333 334
if (APPLE AND HB_HAVE_CORETEXT)
  # Apple Advanced Typography
  add_definitions(-DHAVE_CORETEXT)

335 336
  list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-coretext.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-coretext.h)
E
ebraminio 已提交
337

338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
  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 ()
361

362 363
    mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK)
  endif ()
E
ebraminio 已提交
364 365 366 367 368
endif ()

if (WIN32 AND HB_HAVE_UNISCRIBE)
  add_definitions(-DHAVE_UNISCRIBE)

369 370
  list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-uniscribe.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-uniscribe.h)
E
ebraminio 已提交
371

372
  list(APPEND THIRD_PARTY_LIBS usp10 gdi32 rpcrt4)
E
ebraminio 已提交
373 374 375 376 377
endif ()

if (WIN32 AND HB_HAVE_DIRECTWRITE)
  add_definitions(-DHAVE_DIRECTWRITE)

378 379
  list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-directwrite.cc)
  list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-directwrite.h)
E
ebraminio 已提交
380

381
  list(APPEND THIRD_PARTY_LIBS dwrite rpcrt4)
E
ebraminio 已提交
382
endif ()
E
Ebrahim Byagowi 已提交
383

384
if (HB_HAVE_GOBJECT)
385
  include (FindPerl)
386

387 388 389 390 391
  # 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}
392 393
  )
  set (GLIB_MKENUMS_CMD)
394 395 396 397 398 399 400 401 402

  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
403
    )
404 405
    if (GLIB_MKENUMS_PYTHON EQUAL 0)
      message("${GLIB_MKENUMS} is a Python script.")
406
      set (GLIB_MKENUMS_CMD "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}")
407 408 409 410
    else ()
      execute_process(COMMAND "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}" --version
        RESULT_VARIABLE GLIB_MKENUMS_PERL
        OUTPUT_QUIET ERROR_QUIET
411
      )
412 413
      if (GLIB_MKENUMS_PERL EQUAL 0)
        message("${GLIB_MKENUMS} is a PERL script.")
414
        set (GLIB_MKENUMS_CMD "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}")
415 416 417 418
      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 ()
419
    endif ()
420
  else ()
421
    set (GLIB_MKENUMS_CMD "${GLIB_MKENUMS}")
422 423 424
  endif ()
  if (NOT GLIB_MKENUMS_CMD)
    message(FATAL_ERROR "HB_HAVE_GOBJECT was set, but we failed to find glib-mkenums, which is required")
425
  endif ()
426 427 428 429 430 431 432 433 434 435 436 437

  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
438
  )
439 440
  list(APPEND hb_gobject_structs_headers
    ${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.h
441
  )
442 443
  list(APPEND hb_gobject_headers
    ${PROJECT_SOURCE_DIR}/src/hb-gobject.h
444
    ${hb_gobject_structs_headers}
445
  )
446 447
  list(APPEND hb_gobject_gen_headers
    ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h
448
  )
449

450
  add_custom_command(
451 452 453 454 455
    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
456
      ${hb_gobject_structs_headers}
457 458 459 460 461 462 463 464 465
      ${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}
466
  )
467

468
  add_custom_command(
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
    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}
485
  )
486
endif ()
E
ebraminio 已提交
487

E
Ebrahim Byagowi 已提交
488

489 490 491 492 493 494
## 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); }
495
		int main () { return 0; }
496 497 498
")
try_compile(HB_HAVE_INTEL_ATOMIC_PRIMITIVES
  ${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives
R
rdb 已提交
499
  ${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c)
500 501 502 503 504 505 506 507 508 509 510
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); }
511
		int main () { return 0; }
512 513 514
")
try_compile(HB_HAVE_SOLARIS_ATOMIC_OPS
  ${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops
R
rdb 已提交
515
  ${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c)
E
ebraminio 已提交
516 517
if (HB_HAVE_SOLARIS_ATOMIC_OPS)
  add_definitions(-DHAVE_SOLARIS_ATOMIC_OPS)
518 519
endif ()

E
Ebrahim Byagowi 已提交
520 521

## Define harfbuzz library
522
add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers})
E
ebraminio 已提交
523 524
target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS})

525
## Define harfbuzz-subset library
526
if (HB_BUILD_SUBSET)
527 528 529
  add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers})
  add_dependencies(harfbuzz-subset harfbuzz)
  target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS})
530

531 532 533
  if (BUILD_SHARED_LIBS)
    set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
  endif ()
534 535
endif ()

536 537
if (UNIX OR MINGW)
  # Make symbols link locally
E
Ebrahim Byagowi 已提交
538
  include (CheckCXXCompilerFlag)
539
  CHECK_CXX_COMPILER_FLAG(-Bsymbolic-functions CXX_SUPPORTS_FLAG_BSYMB_FUNCS)
E
Ebrahim Byagowi 已提交
540
  if (CXX_SUPPORTS_FLAG_BSYMB_FUNCS)
541
    link_libraries(-Bsymbolic-functions)
E
Ebrahim Byagowi 已提交
542
  endif ()
543

544
  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
545
    # Make sure we don't link to libstdc++
546 547 548 549
    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)
550
    if (HB_BUILD_SUBSET)
551 552
      set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C)
    endif ()
553

554
    # No threadsafe statics as we do it ourselves
555
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
556
  endif ()
557 558 559 560 561 562 563

  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()
564 565
endif ()

566

567 568 569 570 571 572 573
## 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}
574
  )
575 576 577
  include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src)
  add_dependencies(harfbuzz-gobject harfbuzz)
  target_link_libraries(harfbuzz-gobject harfbuzz ${GOBJECT_LIBRARIES} ${THIRD_PARTY_LIBS})
578 579 580 581

  if (BUILD_SHARED_LIBS)
    set_target_properties(harfbuzz-gobject PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
  endif ()
582
endif ()
E
Ebrahim Byagowi 已提交
583

584
if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW)
585
  add_definitions("-DHB_DLL_EXPORT")
586 587
endif ()

588 589 590 591
# 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.")
592
    set (HB_HAVE_INTROSPECTION OFF)
593 594 595 596 597 598 599 600 601 602
  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}
603
  )
604 605 606

  find_program(G_IR_COMPILER g-ir-compiler
    HINTS ${PC_g_ir_compiler}
607
  )
608 609 610 611

  if (WIN32 AND NOT MINGW)
    # Note that since we already enable HB_HAVE_GOBJECT
    # we would already have PYTHON_EXECUTABLE handy
612
    set (G_IR_SCANNER_CMD "${PYTHON_EXECUTABLE}" "${G_IR_SCANNER}")
613
  else ()
614
    set (G_IR_SCANNER_CMD "${G_IR_SCANNER}")
615 616 617 618
  endif ()

  # We need to account for the varying output directories
  # when we build using Visual Studio projects
619
  if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*")
620 621 622 623 624 625 626
    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 "")
627
  foreach (hb_cflag ${hb_cflags})
628
    list(APPEND hb_defines_cflags "-D${hb_cflag}")
629
  endforeach (hb_cflag)
630 631 632 633 634 635 636 637 638

  # 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 ()

639
  set (introspected_sources)
640 641 642 643 644 645 646
  foreach (f
    ${project_headers}
    ${project_sources}
    ${hb_gobject_gen_sources}
    ${hb_gobject_gen_headers}
    ${hb_gobject_sources}
    ${hb_gobject_headers}
E
Ebrahim Byagowi 已提交
647
  )
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
    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 ()

665 666 667 668 669
  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 ()

670
  # Finally, build the introspection files...
671
  add_custom_command(
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
    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
C
Chun-wei Fan 已提交
691 692
      -DHB_AAT_H
      -DHB_AAT_H_IN
693 694 695 696 697 698 699 700
      -DHB_GOBJECT_H
      -DHB_GOBJECT_H_IN
      -DHB_EXTERN=
      --cflags-end
      --library=harfbuzz-gobject
      --library=harfbuzz
      -L${hb_libpath}
      ${extra_libs}
701
      --filelist ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list
702
      -o ${hb_libpath}/HarfBuzz-0.0.gir
703
    DEPENDS harfbuzz-gobject harfbuzz ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list
704
  )
705

706
  add_custom_command(
707 708 709 710 711 712 713 714
    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
715
  )
716 717
endif ()

E
Ebrahim Byagowi 已提交
718

719 720
## Additional framework build configs
if (BUILD_FRAMEWORK)
721
  set (CMAKE_MACOSX_RPATH ON)
722 723 724 725 726
  set_target_properties(harfbuzz PROPERTIES
    FRAMEWORK TRUE
    PUBLIC_HEADER "${project_headers}"
    XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
  )
727 728 729
  set (MACOSX_FRAMEWORK_IDENTIFIER "harfbuzz")
  set (MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${HB_VERSION}")
  set (MACOSX_FRAMEWORK_BUNDLE_VERSION "${HB_VERSION}")
730 731 732
endif ()


E
Ebrahim Byagowi 已提交
733
## Additional harfbuzz build artifacts
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
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)

752
  add_executable(hb-subset ${HB_SUBSET_CLI_sources})
753
  target_link_libraries(hb-subset harfbuzz harfbuzz-subset)
754

755 756
  add_executable(hb-ot-shape-closure ${HB_OT_SHAPE_CLOSURE_sources})
  target_link_libraries(hb-ot-shape-closure harfbuzz)
E
ebraminio 已提交
757

E
Ebrahim Byagowi 已提交
758
  mark_as_advanced(CAIRO_INCLUDE_DIRS CAIRO_LIBRARIESNAMES)
759 760
endif ()

E
Ebrahim Byagowi 已提交
761

E
ebraminio 已提交
762
## Install
763
include (GNUInstallDirs)
764

E
ebraminio 已提交
765
if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
766
  install(FILES ${project_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz)
767
  if (HB_HAVE_GOBJECT)
768
    install(FILES ${hb_gobject_headers} ${hb_gobject_gen_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz)
769
  endif ()
E
ebraminio 已提交
770 771 772 773
endif ()

if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
  install(TARGETS harfbuzz
774
    EXPORT harfbuzzConfig
775 776 777
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
778
    FRAMEWORK DESTINATION Library/Frameworks
779
  )
780 781 782 783
  install(EXPORT harfbuzzConfig
      NAMESPACE harfbuzz::
      DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/harfbuzz
  )
C
Chun-wei Fan 已提交
784
  if (HB_BUILD_UTILS)
785 786 787 788 789
    if (WIN32 AND BUILD_SHARED_LIBS)
      install(TARGETS harfbuzz-subset
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
      )
    endif ()
C
Chun-wei Fan 已提交
790
    install(TARGETS hb-view
791
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
C
Chun-wei Fan 已提交
792
    )
793
    install(TARGETS hb-subset
794
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
C
Chun-wei Fan 已提交
795 796 797
    )

    install(TARGETS hb-shape
798
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
C
Chun-wei Fan 已提交
799 800 801
    )

    install(TARGETS hb-ot-shape-closure
802
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
C
Chun-wei Fan 已提交
803 804
    )
  endif ()
805 806
  if (HB_HAVE_GOBJECT)
    install(TARGETS harfbuzz-gobject
807 808 809
      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
810
    )
811
    if (HB_HAVE_INTROSPECTION)
812
      if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*")
813 814 815 816 817 818
        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"
819
        DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0
E
Ebrahim Byagowi 已提交
820
      )
821 822

      install(FILES "${hb_libpath}/HarfBuzz-0.0.typelib"
823 824
        DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0
      )
825
    endif ()
826
  endif ()
E
ebraminio 已提交
827
endif ()
K
Khaled Hosny 已提交
828

829
if (HB_BUILD_TESTS)
830
  ## src/ executables
831
  foreach (prog main test test-gsub-would-substitute test-gpos-size-params test-buffer-serialize hb-ot-tag test-unicode-ranges)
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862
    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 ()
  set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN")

  ## 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 ()
E
Ebrahim Byagowi 已提交
863

864 865 866 867
    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)
868
    set_tests_properties(
869
      check-c-linkage-decls.sh check-header-guards.sh check-externs.sh check-includes.sh
870
      PROPERTIES
871
        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
872
        SKIP_RETURN_CODE 77)
E
Ebrahim Byagowi 已提交
873 874
  endif ()

875 876 877
  # Needs to come last so that variables defined above are passed to
  # subdirectories.
  add_subdirectory(test)
E
Ebrahim Byagowi 已提交
878
endif ()