2017-04-04 12:33:51 +02:00
cmake_minimum_required ( VERSION 2.8.0 )
project ( harfbuzz )
2017-12-05 23:43:28 +01:00
enable_testing ( )
2017-05-13 19:02:56 +02:00
## Limit framework build to Xcode generator
if ( BUILD_FRAMEWORK )
2018-01-16 11:48:09 +01:00
# for a framework build on macOS, use:
# cmake -DBUILD_FRAMEWORK=ON -Bbuild -H. -GXcode && cmake --build build
2017-05-13 19:02:56 +02:00
if ( NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode" )
message ( FATAL_ERROR
" Y o u s h o u l d u s e X c o d e g e n e r a t o r w i t h B U I L D _ F R A M E W O R K e n a b l e d " )
endif ( )
2017-12-25 19:31:28 +01:00
set ( CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)" )
set ( CMAKE_MACOSX_RPATH ON )
set ( BUILD_SHARED_LIBS ON )
2017-05-13 19:02:56 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
## Disallow in-source builds, as CMake generated make files can collide with autotools ones
if ( NOT MSVC AND "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}" )
2017-04-04 12:33:51 +02:00
message ( FATAL_ERROR
"
I n - s o u r c e b u i l d s a r e n o t p e r m i t t e d ! M a k e a s e p a r a t e f o l d e r f o r "
" b u i l d i n g , e . g . , "
"
m k d i r b u i l d ; c d b u i l d ; c m a k e . . "
"
B e f o r e t h a t , r e m o v e t h e f i l e s c r e a t e d b y t h i s f a i l e d r u n w i t h "
"
r m - r f C M a k e C a c h e . t x t C M a k e F i l e s " )
endif ( )
2017-05-04 18:01:42 +02:00
2017-04-04 12:33:51 +02:00
## HarfBuzz build configurations
2017-04-11 20:48:18 +02:00
option ( HB_HAVE_FREETYPE "Enable freetype interop helpers" OFF )
option ( HB_HAVE_GRAPHITE2 "Enable Graphite2 complementary shaper" OFF )
2017-04-04 12:33:51 +02:00
option ( HB_BUILTIN_UCDN "Use HarfBuzz provided UCDN" ON )
2017-04-11 20:48:18 +02:00
option ( HB_HAVE_GLIB "Enable glib unicode functions" OFF )
option ( HB_HAVE_ICU "Enable icu unicode functions" OFF )
2017-04-19 20:29:46 +02:00
if ( APPLE )
option ( HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON )
2018-01-08 23:09:42 +01:00
set ( CMAKE_MACOSX_RPATH ON )
2017-04-19 20:29:46 +02:00
endif ( )
if ( WIN32 )
option ( HB_HAVE_UNISCRIBE "Enable Uniscribe shaper backend on Windows" OFF )
2017-10-18 16:27:28 +02:00
option ( HB_HAVE_DIRECTWRITE "Enable DirectWrite shaper backend on Windows" OFF )
2017-04-19 20:29:46 +02:00
endif ( )
2017-04-11 19:02:14 +02:00
option ( HB_BUILD_UTILS "Build harfbuzz utils, needs cairo, freetype, and glib properly be installed" OFF )
if ( HB_BUILD_UTILS )
2017-12-25 19:31:28 +01:00
set ( HB_HAVE_GLIB ON )
set ( HB_HAVE_FREETYPE ON )
2017-04-11 19:02:14 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
2017-10-18 09:43:57 +02:00
option ( HB_HAVE_GOBJECT "Enable GObject Bindings" OFF )
if ( HB_HAVE_GOBJECT )
2017-12-25 19:31:28 +01:00
set ( HB_HAVE_GLIB ON )
2017-10-18 09:43:57 +02:00
endif ( )
2017-10-19 12:36:32 +02:00
option ( HB_HAVE_INTROSPECTION "Enable building introspection (.gir/.typelib) files" OFF )
if ( HB_HAVE_INTROSPECTION )
2017-12-25 19:31:28 +01:00
set ( HB_HAVE_GOBJECT ON )
set ( HB_HAVE_GLIB ON )
2017-10-19 12:36:32 +02:00
endif ( )
2018-02-16 10:23:33 +01:00
option ( HB_DISABLE_TEST_PROGS OFF "Do not build some of the test programs, useful for continuous builds" )
2018-01-05 10:12:20 +01:00
option ( HB_CHECK OFF "Do a configuration suitable for testing (shared library and enable all options)" )
if ( HB_CHECK )
set ( BUILD_SHARED_LIBS ON )
set ( HB_BUILD_UTILS ON )
set ( HB_BUILTIN_UCDN 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 ( )
2017-04-04 12:33:51 +02:00
include_directories ( AFTER
2017-04-05 11:21:23 +02:00
$ { P R O J E C T _ S O U R C E _ D I R } / s r c
2017-04-04 12:33:51 +02:00
$ { P R O J E C T _ B I N A R Y _ D I R } / s r c
2018-01-04 07:41:34 +01:00
)
2017-04-04 12:33:51 +02:00
add_definitions ( -DHAVE_OT )
2017-10-18 16:27:28 +02:00
add_definitions ( -DHAVE_FALLBACK )
2017-04-04 12:33:51 +02:00
2018-01-10 13:15:12 +01:00
2018-02-03 10:23:48 +01:00
## Functions and headers
2018-01-10 13:15:12 +01:00
include ( CheckFunctionExists )
include ( CheckIncludeFile )
macro ( check_funcs ) # Similar to AC_CHECK_FUNCS of autotools
foreach ( func_name ${ ARGN } )
2018-01-10 21:21:56 +01:00
string ( TOUPPER ${ func_name } definiton_to_add )
check_function_exists ( ${ func_name } HAVE_ ${ definiton_to_add } )
if ( ${ HAVE_${definiton_to_add } } )
2018-01-10 13:15:12 +01:00
add_definitions ( -DHAVE_ ${ definiton_to_add } )
endif ( )
endforeach ( )
endmacro ( )
2018-02-03 10:23:48 +01:00
check_funcs ( atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l )
check_include_file ( unistd.h HAVE_UNISTD_H )
if ( ${ HAVE_UNISTD_H } )
add_definitions ( -DHAVE_UNISTD_H )
endif ( )
check_include_file ( sys/mman.h HAVE_SYS_MMAN_H )
if ( ${ HAVE_SYS_MMAN_H } )
add_definitions ( -DHAVE_SYS_MMAN_H )
2018-01-10 13:15:12 +01:00
endif ( )
check_include_file ( xlocale.h HAVE_XLOCALE_H )
if ( ${ HAVE_XLOCALE_H } )
add_definitions ( -DHAVE_XLOCALE_H )
endif ( )
2017-04-04 12:33:51 +02:00
if ( MSVC )
add_definitions ( -wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS )
endif ( )
2018-01-16 11:48:09 +01:00
if ( BUILD_SHARED_LIBS )
if ( WIN32 AND NOT MINGW )
add_definitions ( "-DHB_EXTERN=__declspec(dllexport) extern" )
else ( )
2018-01-30 07:31:46 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" )
2018-01-16 11:48:09 +01:00
endif ( )
2017-04-04 12:33:51 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
2017-05-13 19:02:56 +02:00
## Detect if we are running inside a distribution or regular repository folder
2017-12-25 19:31:28 +01:00
set ( IN_HB_DIST FALSE )
2017-06-19 12:17:09 +02:00
if ( EXISTS "${PROJECT_SOURCE_DIR}/ChangeLog" )
2017-04-04 12:33:51 +02:00
# perhaps we are on dist directory
2017-12-25 19:31:28 +01:00
set ( IN_HB_DIST TRUE )
set ( HB_VERSION_H "${PROJECT_SOURCE_DIR}/src/hb-version.h" )
2017-04-04 12:33:51 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
2017-04-11 19:02:14 +02:00
## Extract variables from Makefile files
2017-12-29 20:43:29 +01:00
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 )
2017-12-25 19:31:28 +01:00
set ( listVar "" )
2017-12-29 20:43:29 +01:00
foreach ( f ${ ${var } } )
2017-04-11 19:02:14 +02:00
list ( APPEND listVar "${prefix}${f}" )
2017-04-11 20:48:18 +02:00
endforeach ( )
2017-12-25 19:31:28 +01:00
set ( ${ var } "${listVar}" PARENT_SCOPE )
2017-04-11 19:02:14 +02:00
endfunction ( )
2017-04-19 20:29:46 +02:00
file ( READ ${ PROJECT_SOURCE_DIR } /src/Makefile.sources SRCSOURCES )
file ( READ ${ PROJECT_SOURCE_DIR } /util/Makefile.sources UTILSOURCES )
file ( READ ${ PROJECT_SOURCE_DIR } /src/hb-ucdn/Makefile.sources UCDNSOURCES )
2017-04-11 19:02:14 +02:00
2017-12-29 20:43:29 +01:00
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/" )
extract_make_variable ( HB_OT_sources ${ SRCSOURCES } )
add_prefix_to_list ( HB_OT_sources "${PROJECT_SOURCE_DIR}/src/" )
extract_make_variable ( HB_OT_headers ${ SRCSOURCES } )
add_prefix_to_list ( HB_OT_headers "${PROJECT_SOURCE_DIR}/src/" )
2018-02-03 02:50:45 +01:00
extract_make_variable ( HB_SUBSET_sources ${ SRCSOURCES } )
add_prefix_to_list ( HB_SUBSET_sources "${PROJECT_SOURCE_DIR}/src/" )
extract_make_variable ( HB_SUBSET_headers ${ SRCSOURCES } )
add_prefix_to_list ( HB_SUBSET_headers "${PROJECT_SOURCE_DIR}/src/" )
2017-12-29 20:43:29 +01:00
extract_make_variable ( HB_BASE_RAGEL_GENERATED_sources ${ SRCSOURCES } )
extract_make_variable ( HB_OT_RAGEL_GENERATED_sources ${ SRCSOURCES } )
2017-04-05 11:21:23 +02:00
if ( IN_HB_DIST )
2017-12-29 20:43:29 +01:00
add_prefix_to_list ( HB_BASE_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/" )
add_prefix_to_list ( HB_OT_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/" )
2017-04-05 11:21:23 +02:00
else ( )
2017-12-29 20:43:29 +01:00
add_prefix_to_list ( HB_BASE_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/" )
add_prefix_to_list ( HB_OT_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/" )
2017-04-05 11:21:23 +02:00
endif ( )
2017-04-11 19:02:14 +02:00
2017-12-29 20:43:29 +01:00
extract_make_variable ( HB_VIEW_sources ${ UTILSOURCES } )
add_prefix_to_list ( HB_VIEW_sources "${PROJECT_SOURCE_DIR}/util/" )
extract_make_variable ( HB_SHAPE_sources ${ UTILSOURCES } )
add_prefix_to_list ( HB_SHAPE_sources "${PROJECT_SOURCE_DIR}/util/" )
2018-02-03 02:50:45 +01:00
extract_make_variable ( HB_SUBSET_CLI_sources ${ UTILSOURCES } )
add_prefix_to_list ( HB_SUBSET_CLI_sources "${PROJECT_SOURCE_DIR}/util/" )
2017-12-29 20:43:29 +01:00
extract_make_variable ( HB_OT_SHAPE_CLOSURE_sources ${ UTILSOURCES } )
add_prefix_to_list ( HB_OT_SHAPE_CLOSURE_sources "${PROJECT_SOURCE_DIR}/util/" )
extract_make_variable ( LIBHB_UCDN_sources ${ UCDNSOURCES } )
add_prefix_to_list ( LIBHB_UCDN_sources "${PROJECT_SOURCE_DIR}/src/hb-ucdn/" )
2017-04-19 20:29:46 +02:00
2017-04-11 20:48:18 +02:00
2017-04-11 19:02:14 +02:00
file ( READ configure.ac CONFIGUREAC )
string ( REGEX MATCH "\\[(([0-9]+)\\.([0-9]+)\\.([0-9]+))\\]" HB_VERSION_MATCH ${ CONFIGUREAC } )
2017-12-25 19:31:28 +01:00
set ( HB_VERSION ${ CMAKE_MATCH_1 } )
set ( HB_VERSION_MAJOR ${ CMAKE_MATCH_2 } )
set ( HB_VERSION_MINOR ${ CMAKE_MATCH_3 } )
set ( HB_VERSION_MICRO ${ CMAKE_MATCH_4 } )
2017-05-04 18:01:42 +02:00
2017-04-05 11:21:23 +02:00
2017-05-13 19:02:56 +02:00
## Define ragel tasks
2017-04-04 12:33:51 +02:00
if ( NOT IN_HB_DIST )
2017-06-19 12:17:09 +02:00
find_program ( RAGEL "ragel" CMAKE_FIND_ROOT_PATH_BOTH )
2017-04-04 12:33:51 +02:00
if ( RAGEL )
message ( STATUS "ragel found at: ${RAGEL}" )
2017-04-05 11:21:23 +02:00
else ( )
2017-11-20 20:49:22 +01:00
message ( FATAL_ERROR "ragel not found, get it here -- http://www.complang.org/ragel/ or, use harfbuzz releases https://github.com/harfbuzz/harfbuzz/releases" )
2017-04-05 11:21:23 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
2017-04-05 11:21:23 +02:00
foreach ( ragel_output IN ITEMS ${ HB_BASE_RAGEL_GENERATED_sources } ${ HB_OT_RAGEL_GENERATED_sources } )
string ( REGEX MATCH "([^/]+)\\.hh" temp ${ ragel_output } )
2017-12-25 19:31:28 +01:00
set ( target_name ${ CMAKE_MATCH_1 } )
2017-04-05 11:21:23 +02:00
add_custom_command ( OUTPUT ${ ragel_output }
C O M M A N D $ { R A G E L } - G 2 - o $ { r a g e l _ o u t p u t } $ { P R O J E C T _ S O U R C E _ D I R } / s r c / $ { t a r g e t _ n a m e } . r l - I $ { P R O J E C T _ S O U R C E _ D I R } $ { A R G N }
D E P E N D S $ { P R O J E C T _ S O U R C E _ D I R } / s r c / $ { t a r g e t _ n a m e } . r l
2017-12-25 19:31:28 +01:00
)
2017-04-05 11:21:23 +02:00
add_custom_target ( harfbuzz_ ${ target_name } DEPENDS ${ PROJECT_BINARY_DIR } /src/ ${ target_name } )
endforeach ( )
2017-04-19 20:29:46 +02:00
mark_as_advanced ( RAGEL )
2017-05-13 19:02:56 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
2017-04-04 12:33:51 +02:00
2017-05-13 19:02:56 +02:00
## Generate hb-version.h
if ( NOT IN_HB_DIST )
2017-12-25 19:31:28 +01:00
set ( HB_VERSION_H_IN "${PROJECT_SOURCE_DIR}/src/hb-version.h.in" )
set ( HB_VERSION_H "${PROJECT_BINARY_DIR}/src/hb-version.h" )
2017-04-04 12:33:51 +02:00
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
" $ { H B _ V E R S I O N _ H } . t m p "
2017-05-13 19:02:56 +02:00
" $ { H B _ V E R S I O N _ H } "
2017-12-25 19:31:28 +01:00
)
2017-04-04 12:33:51 +02:00
file ( REMOVE "${HB_VERSION_H}.tmp" )
endif ( )
2017-05-13 19:02:56 +02:00
2017-04-11 19:02:14 +02:00
## Define sources and headers of the project
2017-12-25 19:31:28 +01:00
set ( project_sources
2017-04-05 11:21:23 +02:00
$ { H B _ B A S E _ s o u r c e s }
$ { H B _ B A S E _ R A G E L _ G E N E R A T E D _ s o u r c e s }
2017-04-04 12:33:51 +02:00
2017-10-18 16:27:28 +02:00
$ { H B _ F A L L B A C K _ s o u r c e s }
2017-04-05 11:21:23 +02:00
$ { H B _ O T _ s o u r c e s }
2018-02-09 00:35:57 +01:00
$ { H B _ O T _ R A G E L _ G E N E R A T E D _ s o u r c e s }
2018-02-08 23:59:32 +01:00
)
2018-02-03 02:50:45 +01:00
2018-02-08 23:59:32 +01:00
set ( subset_project_sources
2018-02-03 02:50:45 +01:00
$ { H B _ S U B S E T _ s o u r c e s }
2017-12-25 19:31:28 +01:00
)
2017-04-04 12:33:51 +02:00
2017-12-25 19:31:28 +01:00
set ( project_extra_sources )
2017-10-19 12:36:32 +02:00
2017-12-25 19:31:28 +01:00
set ( project_headers
2017-04-04 12:33:51 +02:00
$ { H B _ V E R S I O N _ H }
$ { H B _ B A S E _ h e a d e r s }
$ { H B _ O T _ h e a d e r s }
2017-12-25 19:31:28 +01:00
)
2017-04-04 12:33:51 +02:00
2018-02-08 23:59:32 +01:00
set ( subset_project_headers
$ { H B _ S U B S E T _ h e a d e r s }
)
2017-05-04 18:01:42 +02:00
## Find and include needed header folders and libraries
2017-04-04 12:33:51 +02:00
if ( HB_HAVE_FREETYPE )
2018-01-10 13:15:12 +01:00
include ( FindFreetype )
2017-10-12 11:05:08 +02:00
if ( NOT FREETYPE_FOUND )
message ( FATAL_ERROR "HB_HAVE_FREETYPE was set, but we failed to find it. Maybe add a CMAKE_PREFIX_PATH= to your Freetype2 install prefix" )
2017-12-25 19:31:28 +01:00
endif ( )
2017-04-04 12:33:51 +02:00
2017-10-12 11:05:08 +02:00
list ( APPEND THIRD_PARTY_LIBS ${ FREETYPE_LIBRARIES } )
include_directories ( AFTER ${ FREETYPE_INCLUDE_DIRS } )
2018-01-22 18:53:19 +01:00
add_definitions ( -DHAVE_FREETYPE=1 )
2017-04-04 12:33:51 +02:00
2017-04-11 19:02:14 +02:00
list ( APPEND project_sources ${ PROJECT_SOURCE_DIR } /src/hb-ft.cc )
list ( APPEND project_headers ${ PROJECT_SOURCE_DIR } /src/hb-ft.h )
2018-01-08 23:09:42 +01:00
2018-01-30 07:31:46 +01:00
# So check_funcs can find its headers
2018-01-10 13:15:12 +01:00
set ( CMAKE_REQUIRED_INCLUDES ${ CMAKE_REQUIRED_INCLUDES } ${ FREETYPE_INCLUDE_DIRS } )
set ( CMAKE_REQUIRED_LIBRARIES ${ CMAKE_REQUIRED_LIBRARIES } ${ FREETYPE_LIBRARIES } )
2018-01-30 07:31:46 +01:00
2018-01-10 13:15:12 +01:00
check_funcs ( FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var )
2017-04-04 12:33:51 +02:00
endif ( )
2017-04-11 20:48:18 +02:00
if ( HB_HAVE_GRAPHITE2 )
add_definitions ( -DHAVE_GRAPHITE2 )
find_path ( GRAPHITE2_INCLUDE_DIR graphite2/Font.h )
find_library ( GRAPHITE2_LIBRARY graphite2 )
include_directories ( ${ GRAPHITE2_INCLUDE_DIR } )
list ( APPEND project_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 } )
2017-04-19 20:29:46 +02:00
mark_as_advanced ( GRAPHITE2_INCLUDE_DIR GRAPHITE2_LIBRARY )
2017-04-11 20:48:18 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
if ( HB_BUILTIN_UCDN )
include_directories ( src/hb-ucdn )
add_definitions ( -DHAVE_UCDN )
2017-10-19 12:36:32 +02:00
list ( APPEND project_sources ${ PROJECT_SOURCE_DIR } /src/hb-ucdn.cc )
list ( APPEND project_extra_sources ${ LIBHB_UCDN_sources } )
2017-04-11 19:02:14 +02:00
endif ( )
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 } )
2017-04-19 20:29:46 +02:00
mark_as_advanced ( GLIB_LIBRARIES GLIBCONFIG_INCLUDE_DIR GLIB_INCLUDE_DIR )
2017-04-04 12:33:51 +02:00
endif ( )
2017-04-11 20:48:18 +02:00
if ( HB_HAVE_ICU )
add_definitions ( -DHAVE_ICU )
# https://github.com/WebKit/webkit/blob/master/Source/cmake/FindICU.cmake
find_package ( PkgConfig )
pkg_check_modules ( PC_ICU QUIET icu-uc )
find_path ( ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${ PC_ICU_INCLUDE_DIRS } ${ PC_ICU_INCLUDEDIR } )
find_library ( ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${ PC_ICU_LIBRARY_DIRS } ${ PC_ICU_LIBDIR } )
include_directories ( ${ ICU_INCLUDE_DIR } )
list ( APPEND project_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 } )
2017-04-19 20:29:46 +02:00
mark_as_advanced ( ICU_INCLUDE_DIR ICU_LIBRARY )
2017-04-11 20:48:18 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
if ( APPLE AND HB_HAVE_CORETEXT )
# Apple Advanced Typography
add_definitions ( -DHAVE_CORETEXT )
2017-04-11 19:02:14 +02:00
list ( APPEND project_sources ${ PROJECT_SOURCE_DIR } /src/hb-coretext.cc )
list ( APPEND project_headers ${ PROJECT_SOURCE_DIR } /src/hb-coretext.h )
2017-04-04 12:33:51 +02:00
find_library ( APPLICATION_SERVICES_FRAMEWORK ApplicationServices )
if ( APPLICATION_SERVICES_FRAMEWORK )
2017-04-11 19:02:14 +02:00
list ( APPEND THIRD_PARTY_LIBS ${ APPLICATION_SERVICES_FRAMEWORK } )
2017-04-04 12:33:51 +02:00
endif ( APPLICATION_SERVICES_FRAMEWORK )
2018-01-22 18:53:19 +01:00
2017-04-19 20:29:46 +02:00
mark_as_advanced ( APPLICATION_SERVICES_FRAMEWORK )
2017-04-04 12:33:51 +02:00
endif ( )
if ( WIN32 AND HB_HAVE_UNISCRIBE )
add_definitions ( -DHAVE_UNISCRIBE )
2017-04-11 19:02:14 +02:00
list ( APPEND project_sources ${ PROJECT_SOURCE_DIR } /src/hb-uniscribe.cc )
list ( APPEND project_headers ${ PROJECT_SOURCE_DIR } /src/hb-uniscribe.h )
2017-04-04 12:33:51 +02:00
2017-04-11 19:02:14 +02:00
list ( APPEND THIRD_PARTY_LIBS usp10 gdi32 rpcrt4 )
2017-04-04 12:33:51 +02:00
endif ( )
if ( WIN32 AND HB_HAVE_DIRECTWRITE )
add_definitions ( -DHAVE_DIRECTWRITE )
2017-04-11 19:02:14 +02:00
list ( APPEND project_sources ${ PROJECT_SOURCE_DIR } /src/hb-directwrite.cc )
list ( APPEND project_headers ${ PROJECT_SOURCE_DIR } /src/hb-directwrite.h )
2017-04-04 12:33:51 +02:00
2017-04-11 19:02:14 +02:00
list ( APPEND THIRD_PARTY_LIBS dwrite rpcrt4 )
2017-04-04 12:33:51 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
2017-10-18 09:43:57 +02:00
if ( HB_HAVE_GOBJECT )
2018-01-10 13:15:12 +01:00
include ( FindPythonInterp )
include ( FindPerl )
2018-01-22 18:53:19 +01:00
2017-10-18 09:43:57 +02:00
# Use the hints from glib-2.0.pc to find glib-mkenums
find_package ( PkgConfig )
pkg_check_modules ( PC_GLIB QUIET glib-2.0 )
find_program ( GLIB_MKENUMS glib-mkenums
H I N T S $ { P C _ g l i b _ m k e n u m s }
2017-12-25 19:31:28 +01:00
)
set ( GLIB_MKENUMS_CMD )
2017-10-18 09:43:57 +02:00
if ( WIN32 AND NOT MINGW )
# In Visual Studio builds, shebang lines are not supported
# in the standard cmd.exe shell that we use, so we need to
# first determine whether glib-mkenums is a Python or PERL
# script
execute_process ( COMMAND "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}" --version
R E S U L T _ V A R I A B L E G L I B _ M K E N U M S _ P Y T H O N
O U T P U T _ Q U I E T E R R O R _ Q U I E T
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
if ( GLIB_MKENUMS_PYTHON EQUAL 0 )
message ( "${GLIB_MKENUMS} is a Python script." )
2017-12-25 19:31:28 +01:00
set ( GLIB_MKENUMS_CMD "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}" )
2017-10-18 09:43:57 +02:00
else ( )
execute_process ( COMMAND "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}" --version
R E S U L T _ V A R I A B L E G L I B _ M K E N U M S _ P E R L
O U T P U T _ Q U I E T E R R O R _ Q U I E T
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
if ( GLIB_MKENUMS_PERL EQUAL 0 )
message ( "${GLIB_MKENUMS} is a PERL script." )
2017-12-25 19:31:28 +01:00
set ( GLIB_MKENUMS_CMD "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}" )
2017-10-18 09:43:57 +02:00
endif ( )
if ( NOT GLIB_MKENUMS_PERL EQUAL 0 AND NOT GLIB_MKENUMS_PYTHON EQUAL 0 )
message ( FATAL_ERROR "Unable to determine type of glib-mkenums script" )
endif ( )
2017-12-25 19:31:28 +01:00
endif ( )
2017-10-18 09:43:57 +02:00
else ( )
2017-12-25 19:31:28 +01:00
set ( GLIB_MKENUMS_CMD "${GLIB_MKENUMS}" )
2017-10-18 09:43:57 +02:00
endif ( )
if ( NOT GLIB_MKENUMS_CMD )
message ( FATAL_ERROR "HB_HAVE_GOBJECT was set, but we failed to find glib-mkenums, which is required" )
2017-12-25 19:31:28 +01:00
endif ( )
2017-10-18 09:43:57 +02:00
pkg_check_modules ( PC_GOBJECT QUIET gobject-2.0 )
find_library ( GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${ PC_GLIB_LIBDIR } ${ PC_GLIB_LIBRARY_DIRS } )
find_path ( GOBJECT_INCLUDE_DIR NAMES glib-object.h HINTS ${ PC_GLIB_INCLUDEDIR } ${ PC_GLIB_INCLUDE_DIRS } PATH_SUFFIXES glib-2.0 )
include_directories ( ${ GOBJECTCONFIG_INCLUDE_DIR } ${ GOBJECT_INCLUDE_DIR } )
mark_as_advanced ( GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR )
list ( APPEND hb_gobject_sources ${ PROJECT_SOURCE_DIR } /src/hb-gobject-structs.cc )
list ( APPEND hb_gobject_gen_sources
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c
2017-12-25 19:31:28 +01:00
)
2017-10-19 12:36:32 +02:00
list ( APPEND hb_gobject_structs_headers
$ { P R O J E C T _ S O U R C E _ D I R } / s r c / h b - g o b j e c t - s t r u c t s . h
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
list ( APPEND hb_gobject_headers
$ { P R O J E C T _ S O U R C E _ D I R } / s r c / h b - g o b j e c t . h
2017-10-19 12:36:32 +02:00
$ { h b _ g o b j e c t _ s t r u c t s _ h e a d e r s }
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
list ( APPEND hb_gobject_gen_headers
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . h
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
2017-12-25 19:31:28 +01:00
add_custom_command (
2017-10-18 09:43:57 +02:00
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . h
C O M M A N D $ { G L I B _ M K E N U M S _ C M D }
- - t e m p l a t e = $ { P R O J E C T _ S O U R C E _ D I R } / s r c / h b - g o b j e c t - e n u m s . h . t m p l
- - i d e n t i f i e r - p r e f i x h b _
- - s y m b o l - p r e f i x h b _ g o b j e c t
2017-10-19 12:36:32 +02:00
$ { h b _ g o b j e c t _ s t r u c t s _ h e a d e r s }
2017-10-18 09:43:57 +02:00
$ { p r o j e c t _ h e a d e r s }
> $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . h . t m p
C O M M A N D " $ { C M A K E _ C O M M A N D } "
" - D E N U M _ I N P U T _ S R C = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . h . t m p "
" - D E N U M _ O U T P U T _ S R C = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . h "
- P $ { P R O J E C T _ S O U R C E _ D I R } / r e p l a c e - e n u m - s t r i n g s . c m a k e
D E P E N D S $ { P R O J E C T _ S O U R C E _ D I R } / s r c / h b - g o b j e c t - e n u m s . h . t m p l
$ { h b _ g o b j e c t _ h e a d e r }
$ { p r o j e c t _ h e a d e r s }
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
2017-12-25 19:31:28 +01:00
add_custom_command (
2017-10-18 09:43:57 +02:00
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c
C O M M A N D $ { G L I B _ M K E N U M S _ C M D }
- - t e m p l a t e = $ { P R O J E C T _ S O U R C E _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c . t m p l
- - i d e n t i f i e r - p r e f i x h b _
- - s y m b o l - p r e f i x h b _ g o b j e c t
$ { h b _ g o b j e c t _ h e a d e r }
$ { p r o j e c t _ h e a d e r s }
> $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c . t m p
C O M M A N D " $ { C M A K E _ C O M M A N D } "
" - D E N U M _ I N P U T _ S R C = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c . t m p "
" - D E N U M _ O U T P U T _ S R C = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c "
- P $ { P R O J E C T _ S O U R C E _ D I R } / r e p l a c e - e n u m - s t r i n g s . c m a k e
D E P E N D S $ { P R O J E C T _ S O U R C E _ D I R } / s r c / h b - g o b j e c t - e n u m s . c c . t m p l
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s r c / h b - g o b j e c t - e n u m s . h
$ { h b _ g o b j e c t _ h e a d e r }
$ { p r o j e c t _ h e a d e r s }
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
2018-01-04 07:41:34 +01:00
2017-04-14 01:55:50 +02:00
## Atomic ops availability detection
file ( WRITE "${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c"
" v o i d memory_barrier ( void ) { __sync_synchronize ( ) ; }
i n t atomic_add ( int *i ) { r e t u r n __sync_fetch_and_add ( i, 1 ) ; }
i n t mutex_trylock ( int *m ) { r e t u r n __sync_lock_test_and_set ( m, 1 ) ; }
v o i d mutex_unlock ( int *m ) { __sync_lock_release ( m ) ; }
2017-04-14 02:38:11 +02:00
i n t main ( ) { r e t u r n 0 ; }
2017-04-14 01:55:50 +02:00
" )
try_compile ( HB_HAVE_INTEL_ATOMIC_PRIMITIVES
$ { P R O J E C T _ B I N A R Y _ D I R } / t r y _ c o m p i l e _ i n t e l _ a t o m i c _ p r i m i t i v e s
2018-01-16 17:04:33 +01:00
$ { P R O J E C T _ B I N A R Y _ D I R } / t r y _ c o m p i l e _ i n t e l _ a t o m i c _ p r i m i t i v e s . c )
2017-04-14 01:55:50 +02:00
if ( HB_HAVE_INTEL_ATOMIC_PRIMITIVES )
add_definitions ( -DHAVE_INTEL_ATOMIC_PRIMITIVES )
endif ( )
file ( WRITE "${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c"
" #include <atomic.h>
/ * T h i s r e q u i r e s S o l a r i s S t u d i o 1 2 . 2 o r n e w e r : * /
#include <mbarrier.h>
v o i d memory_barrier ( void ) { __machine_rw_barrier ( ) ; }
i n t atomic_add ( volatile unsigned *i ) { r e t u r n atomic_add_int_nv ( i, 1 ) ; }
v o i d * atomic_ptr_cmpxchg ( volatile void **target, void *cmp, void *newval ) { r e t u r n atomic_cas_ptr ( target, cmp, newval ) ; }
2017-04-14 02:38:11 +02:00
i n t main ( ) { r e t u r n 0 ; }
2017-04-14 01:55:50 +02:00
" )
try_compile ( HB_HAVE_SOLARIS_ATOMIC_OPS
$ { P R O J E C T _ B I N A R Y _ D I R } / t r y _ c o m p i l e _ s o l a r i s _ a t o m i c _ o p s
2018-01-16 17:04:33 +01:00
$ { P R O J E C T _ B I N A R Y _ D I R } / t r y _ c o m p i l e _ s o l a r i s _ a t o m i c _ o p s . c )
2017-04-14 02:01:17 +02:00
if ( HB_HAVE_SOLARIS_ATOMIC_OPS )
add_definitions ( -DHAVE_SOLARIS_ATOMIC_OPS )
2017-04-14 01:55:50 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
## Define harfbuzz library
2017-10-19 12:36:32 +02:00
add_library ( harfbuzz ${ project_sources } ${ project_extra_sources } ${ project_headers } )
2017-04-04 12:33:51 +02:00
target_link_libraries ( harfbuzz ${ THIRD_PARTY_LIBS } )
2018-02-08 23:59:32 +01:00
## Define harfbuzz-subset library
add_library ( harfbuzz-subset ${ subset_project_sources } ${ subset_project_headers } )
add_dependencies ( harfbuzz-subset harfbuzz )
target_link_libraries ( harfbuzz-subset harfbuzz ${ THIRD_PARTY_LIBS } )
2018-01-16 19:30:21 +01:00
if ( UNIX OR MINGW )
# Make symbols link locally
link_libraries ( -Bsymbolic-functions )
2018-01-30 07:31:46 +01:00
if ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
2018-02-10 20:43:12 +01:00
# Make sure we don't link to libstdc++
2018-01-30 07:31:46 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
set ( CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m" ) # libm
set ( CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "" )
set_target_properties ( harfbuzz PROPERTIES LINKER_LANGUAGE C )
2018-02-08 23:59:32 +01:00
set_target_properties ( harfbuzz-subset PROPERTIES LINKER_LANGUAGE C )
2018-01-18 22:42:31 +01:00
2018-02-10 20:43:12 +01:00
# No threadsafe statics as we do it ourselves
2018-01-30 07:31:46 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics" )
2018-01-16 19:30:21 +01:00
endif ( )
endif ( )
2017-10-18 09:43:57 +02:00
## Define harfbuzz-gobject library
if ( HB_HAVE_GOBJECT )
add_library ( harfbuzz-gobject
$ { h b _ g o b j e c t _ s o u r c e s }
$ { h b _ g o b j e c t _ g e n _ s o u r c e s }
$ { h b _ g o b j e c t _ h e a d e r s }
$ { h b _ g o b j e c t _ g e n _ h e a d e r s }
2017-12-25 19:31:28 +01:00
)
2017-10-18 09:43:57 +02:00
include_directories ( BEFORE ${ CMAKE_CURRENT_BINARY_DIR } /src )
add_dependencies ( harfbuzz-gobject harfbuzz )
target_link_libraries ( harfbuzz-gobject harfbuzz ${ GOBJECT_LIBRARIES } ${ THIRD_PARTY_LIBS } )
endif ( )
2017-05-04 18:01:42 +02:00
2017-10-19 12:36:32 +02:00
# On Windows, g-ir-scanner requires a DLL build in order for it to work
if ( WIN32 )
if ( NOT BUILD_SHARED_LIBS )
message ( "Building introspection files on Windows requires BUILD_SHARED_LIBS to be enabled." )
2017-12-25 19:31:28 +01:00
set ( HB_HAVE_INTROSPECTION OFF )
2017-10-19 12:36:32 +02:00
endif ( )
endif ( )
if ( HB_HAVE_INTROSPECTION )
find_package ( PkgConfig )
pkg_check_modules ( PC_GI QUIET gobject-introspection-1.0 )
find_program ( G_IR_SCANNER g-ir-scanner
H I N T S $ { P C _ g _ i r _ s c a n n e r }
2017-12-25 19:31:28 +01:00
)
2017-10-19 12:36:32 +02:00
find_program ( G_IR_COMPILER g-ir-compiler
H I N T S $ { P C _ g _ i r _ c o m p i l e r }
2017-12-25 19:31:28 +01:00
)
2017-10-19 12:36:32 +02:00
if ( WIN32 AND NOT MINGW )
# Note that since we already enable HB_HAVE_GOBJECT
# we would already have PYTHON_EXECUTABLE handy
2017-12-25 19:31:28 +01:00
set ( G_IR_SCANNER_CMD "${PYTHON_EXECUTABLE}" "${G_IR_SCANNER}" )
2017-10-19 12:36:32 +02:00
else ( )
2017-12-25 19:31:28 +01:00
set ( G_IR_SCANNER_CMD "${G_IR_SCANNER}" )
2017-10-19 12:36:32 +02:00
endif ( )
# We need to account for the varying output directories
# when we build using Visual Studio projects
2017-12-25 19:31:28 +01:00
if ( "${CMAKE_GENERATOR}" MATCHES "Visual Studio*" )
2017-10-19 12:36:32 +02:00
set ( hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>" )
else ( )
set ( hb_libpath "$<TARGET_FILE_DIR:harfbuzz-gobject>" )
endif ( )
# Get the CFlags that we used to build HarfBuzz/HarfBuzz-GObject
set ( hb_defines_cflags "" )
2017-12-25 19:31:28 +01:00
foreach ( hb_cflag ${ hb_cflags } )
2017-10-19 12:36:32 +02:00
list ( APPEND hb_defines_cflags "-D${hb_cflag}" )
2017-12-25 19:31:28 +01:00
endforeach ( hb_cflag )
2017-10-19 12:36:32 +02:00
# Get the other dependent libraries we used to build HarfBuzz/HarfBuzz-GObject
set ( extra_libs "" )
foreach ( extra_lib ${ THIRD_PARTY_LIBS } )
# We don't want the .lib extension here...
string ( REPLACE ".lib" "" extra_lib_stripped "${extra_lib}" )
list ( APPEND extra_libs "--extra-library=${extra_lib_stripped}" )
endforeach ( )
2017-12-25 19:31:28 +01:00
set ( introspected_sources )
2017-10-19 12:36:32 +02:00
foreach ( f
$ { p r o j e c t _ h e a d e r s }
$ { p r o j e c t _ s o u r c e s }
$ { h b _ g o b j e c t _ g e n _ s o u r c e s }
$ { h b _ g o b j e c t _ g e n _ h e a d e r s }
$ { h b _ g o b j e c t _ s o u r c e s }
$ { h b _ g o b j e c t _ h e a d e r s }
2018-01-04 07:41:34 +01:00
)
2017-10-19 12:36:32 +02:00
if ( WIN32 )
# Nasty issue: We need to make drive letters lower case,
# otherwise g-ir-scanner won't like it and give us a bunch
# of invalid items and unresolved types...
STRING ( SUBSTRING "${f}" 0 1 drive )
STRING ( SUBSTRING "${f}" 1 -1 path )
if ( drive MATCHES "[A-Z]" )
STRING ( TOLOWER ${ drive } drive_lower )
list ( APPEND introspected_sources "${drive_lower}${path}" )
else ( )
list ( APPEND introspected_sources "${f}" )
endif ( )
else ( )
list ( APPEND introspected_sources "${f}" )
endif ( )
endforeach ( )
# Finally, build the introspection files...
2017-12-25 19:31:28 +01:00
add_custom_command (
2017-10-19 12:36:32 +02:00
T A R G E T h a r f b u z z - g o b j e c t
P O S T _ B U I L D
C O M M A N D $ { G _ I R _ S C A N N E R _ C M D }
- - w a r n - a l l - - n o - l i b t o o l - - v e r b o s e
- n h b
- - n a m e s p a c e = H a r f B u z z
- - n s v e r s i o n = 0 . 0
- - i d e n t i f i e r - p r e f i x = h b _
- - i n c l u d e G O b j e c t - 2 . 0
- - p k g - e x p o r t = h a r f b u z z
- - c f l a g s - b e g i n
- I $ { P R O J E C T _ S O U R C E _ D I R } / s r c
- I $ { P R O J E C T _ B I N A R Y _ D I R } / s r c
$ { h b _ i n c l u d e d i r _ c f l a g s }
$ { h b _ d e f i n e s _ c f l a g s }
- D H B _ H
- D H B _ H _ I N
- D H B _ O T _ H
- D H B _ O T _ H _ I N
- D H B _ G O B J E C T _ H
- D H B _ G O B J E C T _ H _ I N
- D H B _ E X T E R N =
- - c f l a g s - e n d
- - l i b r a r y = h a r f b u z z - g o b j e c t
- - l i b r a r y = h a r f b u z z
- L $ { h b _ l i b p a t h }
$ { e x t r a _ l i b s }
$ { i n t r o s p e c t e d _ s o u r c e s }
- o $ { h b _ l i b p a t h } / H a r f B u z z - 0 . 0 . g i r
D E P E N D S h a r f b u z z - g o b j e c t h a r f b u z z
2017-12-25 19:31:28 +01:00
)
2017-10-19 12:36:32 +02:00
2017-12-25 19:31:28 +01:00
add_custom_command (
2017-10-19 12:36:32 +02:00
T A R G E T h a r f b u z z - g o b j e c t
P O S T _ B U I L D
C O M M A N D " $ { G _ I R _ C O M P I L E R } "
- - v e r b o s e - - d e b u g
- - i n c l u d e d i r $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
$ { h b _ l i b p a t h } / H a r f B u z z - 0 . 0 . g i r
- o $ { h b _ l i b p a t h } / H a r f B u z z - 0 . 0 . t y p e l i b
D E P E N D S $ { h b _ l i b p a t h } / H a r f B u z z - 0 . 0 . g i r h a r f b u z z - g o b j e c t
2017-12-25 19:31:28 +01:00
)
2017-10-19 12:36:32 +02:00
endif ( )
2018-01-04 07:41:34 +01:00
2017-05-13 19:02:56 +02:00
## Additional framework build configs
if ( BUILD_FRAMEWORK )
2017-12-25 19:31:28 +01:00
set ( CMAKE_MACOSX_RPATH ON )
2017-05-13 19:02:56 +02:00
set_target_properties ( harfbuzz PROPERTIES
F R A M E W O R K T R U E
P U B L I C _ H E A D E R " $ { p r o j e c t _ h e a d e r s } "
X C O D E _ A T T R I B U T E _ I N S T A L L _ P A T H " @ r p a t h "
)
2017-12-25 19:31:28 +01:00
set ( MACOSX_FRAMEWORK_IDENTIFIER "harfbuzz" )
set ( MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${HB_VERSION}" )
set ( MACOSX_FRAMEWORK_BUNDLE_VERSION "${HB_VERSION}" )
2017-05-13 19:02:56 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
## Additional harfbuzz build artifacts
2017-04-11 19:02:14 +02:00
if ( HB_BUILD_UTILS )
# https://github.com/WebKit/webkit/blob/master/Source/cmake/FindCairo.cmake
find_package ( PkgConfig )
pkg_check_modules ( PC_CAIRO QUIET cairo )
find_path ( CAIRO_INCLUDE_DIRS NAMES cairo.h HINTS ${ PC_CAIRO_INCLUDEDIR } ${ PC_CAIRO_INCLUDE_DIRS } PATH_SUFFIXES cairo )
find_library ( CAIRO_LIBRARIESNAMES cairo HINTS ${ PC_CAIRO_LIBDIR } ${ PC_CAIRO_LIBRARY_DIRS } )
add_definitions ( "-DPACKAGE_NAME=\" HarfBuzz\ "" )
add_definitions ( "-DPACKAGE_VERSION=\" ${ HB_VERSION } \"")
include_directories ( ${ CAIRO_INCLUDE_DIRS } )
add_executable ( hb-view ${ HB_VIEW_sources } )
target_link_libraries ( hb-view harfbuzz ${ CAIRO_LIBRARIESNAMES } )
add_executable ( hb-shape ${ HB_SHAPE_sources } )
target_link_libraries ( hb-shape harfbuzz )
2018-02-03 02:50:45 +01:00
add_executable ( hb-subset ${ HB_SUBSET_CLI_sources } )
2018-02-08 23:59:32 +01:00
target_link_libraries ( hb-subset harfbuzz harfbuzz-subset )
2018-02-03 02:50:45 +01:00
2017-04-11 19:02:14 +02:00
add_executable ( hb-ot-shape-closure ${ HB_OT_SHAPE_CLOSURE_sources } )
target_link_libraries ( hb-ot-shape-closure harfbuzz )
2017-04-19 20:29:46 +02:00
2017-05-04 18:01:42 +02:00
mark_as_advanced ( CAIRO_INCLUDE_DIRS CAIRO_LIBRARIESNAMES )
2017-04-11 19:02:14 +02:00
endif ( )
2017-05-04 18:01:42 +02:00
2017-04-04 12:33:51 +02:00
## Install
2018-01-10 13:15:12 +01:00
include ( GNUInstallDirs )
2017-12-25 19:31:28 +01:00
2017-04-04 12:33:51 +02:00
if ( NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
2017-12-25 19:31:28 +01:00
install ( FILES ${ project_headers } DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } /harfbuzz )
2017-10-18 09:43:57 +02:00
if ( HB_HAVE_GOBJECT )
2017-12-25 19:31:28 +01:00
install ( FILES ${ hb_gobject_headers } ${ hb_gobject_gen_headers } DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } /harfbuzz )
2017-10-18 09:43:57 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
endif ( )
if ( NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
install ( TARGETS harfbuzz
2017-12-25 19:31:28 +01:00
A R C H I V E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
L I B R A R Y D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2017-05-13 19:02:56 +02:00
F R A M E W O R K D E S T I N A T I O N L i b r a r y / F r a m e w o r k s
2017-12-25 19:31:28 +01:00
)
2017-10-18 16:27:28 +02:00
if ( HB_BUILD_UTILS )
install ( TARGETS hb-view
2017-12-25 19:31:28 +01:00
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2017-10-18 16:27:28 +02:00
)
install ( TARGETS hb-view
2017-12-25 19:31:28 +01:00
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2017-10-18 16:27:28 +02:00
)
install ( TARGETS hb-shape
2017-12-25 19:31:28 +01:00
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2017-10-18 16:27:28 +02:00
)
install ( TARGETS hb-ot-shape-closure
2017-12-25 19:31:28 +01:00
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2017-10-18 16:27:28 +02:00
)
endif ( )
2017-10-18 09:43:57 +02:00
if ( HB_HAVE_GOBJECT )
install ( TARGETS harfbuzz-gobject
2017-12-25 19:31:28 +01:00
A R C H I V E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
L I B R A R Y D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2017-10-18 09:43:57 +02:00
)
2017-10-19 12:36:32 +02:00
if ( HB_HAVE_INTROSPECTION )
2017-12-25 19:31:28 +01:00
if ( "${CMAKE_GENERATOR}" MATCHES "Visual Studio*" )
2017-10-19 12:36:32 +02:00
set ( hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>" )
else ( )
set ( hb_libpath "$<TARGET_FILE_DIR:harfbuzz-gobject>" )
endif ( )
install ( FILES "${hb_libpath}/HarfBuzz-0.0.gir"
2017-12-25 19:31:28 +01:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A R O O T D I R } / g i r - 1 . 0
2018-01-04 07:41:34 +01:00
)
2017-10-19 12:36:32 +02:00
install ( FILES "${hb_libpath}/HarfBuzz-0.0.typelib"
2017-12-25 19:31:28 +01:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / g i r e p o s i t o r y - 1 . 0
)
2017-10-19 12:36:32 +02:00
endif ( )
2017-10-18 09:43:57 +02:00
endif ( )
2017-04-04 12:33:51 +02:00
endif ( )
2017-12-05 23:43:28 +01:00
2018-01-04 12:37:35 +01:00
if ( UNIX AND CMAKE_GENERATOR STREQUAL "Ninja" )
if ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
2018-01-30 07:31:46 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics" )
2018-01-04 12:37:35 +01:00
endif ( )
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
2018-01-30 07:31:46 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color" )
2018-01-04 12:37:35 +01:00
endif ( )
endif ( )
2018-01-04 07:41:34 +01:00
2018-01-05 10:12:20 +01:00
2018-01-30 07:31:46 +01:00
## src/ executables
2018-02-16 10:23:33 +01:00
if ( NOT HB_DISABLE_TEST_PROGS )
foreach ( prog main test test-would-substitute test-size-params test-buffer-serialize hb-ot-tag )
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" )
endif ( )
2018-01-30 07:31:46 +01:00
2018-01-04 07:41:34 +01:00
## Tests
2018-01-16 19:30:21 +01:00
if ( UNIX OR MINGW )
2018-01-04 07:41:34 +01:00
if ( BUILD_SHARED_LIBS )
2018-01-22 18:53:19 +01:00
# generate harfbuzz.def after build completion
string ( REPLACE ";" " " space_separated_headers "${project_headers}" )
2018-01-18 22:42:31 +01:00
add_custom_command ( TARGET harfbuzz POST_BUILD
C O M M A N D $ { C M A K E _ C O M M A N D } - E e n v " h e a d e r s = $ { s p a c e _ s e p a r a t e d _ h e a d e r s } " p y t h o n $ { P R O J E C T _ S O U R C E _ D I R } / s r c / g e n - d e f . p y $ { P R O J E C T _ B I N A R Y _ D I R } / h a r f b u z z . d e f
W O R K I N G _ D I R E C T O R Y $ { P R O J E C T _ S O U R C E _ D I R } / s r c )
2018-01-16 11:48:09 +01:00
2018-01-18 22:42:31 +01:00
add_test ( NAME check-static-inits.sh
C O M M A N D $ { P R O J E C T _ S O U R C E _ D I R } / s r c / c h e c k - s t a t i c - i n i t s . s h
W O R K I N G _ D I R E C T O R Y $ { P R O J E C T _ B I N A R Y _ D I R } $ { C M A K E _ F I L E S _ D I R E C T O R Y } / h a r f b u z z . d i r / s r c # ugly hack
)
add_test ( NAME check-libstdc++.sh COMMAND ${ PROJECT_SOURCE_DIR } /src/check-libstdc++.sh )
2018-01-22 18:53:19 +01:00
add_test ( NAME check-symbols.sh COMMAND ${ PROJECT_SOURCE_DIR } /src/check-symbols.sh )
add_test ( NAME check-defs.sh COMMAND ${ PROJECT_SOURCE_DIR } /src/check-defs.sh )
2018-01-22 16:07:26 +01:00
2018-02-12 12:40:13 +01:00
set_tests_properties (
c h e c k - s t a t i c - i n i t s . s h c h e c k - l i b s t d c + + . s h c h e c k - s y m b o l s . s h c h e c k - d e f s . s h
P R O P E R T I E S
E N V I R O N M E N T " l i b s = . ; s r c d i r = $ { P R O J E C T _ S O U R C E _ D I R } / s r c "
S K I P _ R E T U R N _ C O D E 7 7 )
2018-01-04 07:41:34 +01:00
endif ( )
2018-01-16 19:30:21 +01:00
add_test ( NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh )
add_test ( NAME check-header-guards.sh COMMAND ./check-header-guards.sh )
add_test ( NAME check-externs.sh COMMAND ./check-externs.sh )
add_test ( NAME check-includes.sh COMMAND ./check-includes.sh )
set_tests_properties (
c h e c k - c - l i n k a g e - d e c l s . s h c h e c k - h e a d e r - g u a r d s . s h c h e c k - e x t e r n s . s h c h e c k - i n c l u d e s . s h
2018-02-12 12:40:13 +01:00
P R O P E R T I E S
W O R K I N G _ D I R E C T O R Y $ { P R O J E C T _ S O U R C E _ D I R } / s r c
S K I P _ R E T U R N _ C O D E 7 7 )
2018-01-04 07:41:34 +01:00
endif ( )
2017-12-05 23:43:28 +01:00
# Needs to come last so that variables defined above are passed to
# subdirectories.
2018-01-16 17:04:33 +01:00
add_subdirectory ( test )