From ef2e3803429efe0f5a1fcb2679ae332139297917 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 12 Aug 2020 00:50:33 +0430 Subject: [PATCH] Revert "Remove cmake-config support of HarfBuzz" This reverts commit 75efa893433b6f352c28bda9d0a92683244900aa. --- configure.ac | 1 + meson.build | 1 + src/Makefile.am | 4 +- src/harfbuzz-config.cmake.in | 86 ++++++++++++++++++++++++++++++++++++ src/meson.build | 10 +++++ 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/harfbuzz-config.cmake.in diff --git a/configure.ac b/configure.ac index 7c0d857b1..1f94273bf 100644 --- a/configure.ac +++ b/configure.ac @@ -478,6 +478,7 @@ dnl =========================================================================== AC_CONFIG_FILES([ Makefile src/Makefile +src/harfbuzz-config.cmake util/Makefile test/Makefile test/api/Makefile diff --git a/meson.build b/meson.build index 2e8cbcb9f..e6d5aa927 100644 --- a/meson.build +++ b/meson.build @@ -16,6 +16,7 @@ hb_version_micro = hb_version_arr[2].to_int() # libtool versioning hb_version_int = hb_version_major*10000 + hb_version_minor*100 + hb_version_micro +hb_libtool_version_info = '@0@:0:@0@'.format(hb_version_int) pkgmod = import('pkgconfig') cpp = meson.get_compiler('cpp') diff --git a/src/Makefile.am b/src/Makefile.am index 60cfbb59e..c18adac2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -145,7 +145,9 @@ pkginclude_HEADERS = $(HBHEADERS) nodist_pkginclude_HEADERS = pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = harfbuzz.pc -EXTRA_DIST += hb-version.h.in harfbuzz.pc.in +cmakedir = $(libdir)/cmake/harfbuzz +cmake_DATA = harfbuzz-config.cmake +EXTRA_DIST += hb-version.h.in harfbuzz.pc.in harfbuzz-config.cmake.in lib_LTLIBRARIES += libharfbuzz-subset.la libharfbuzz_subset_la_LINK = $(chosen_linker) $(libharfbuzz_subset_la_LDFLAGS) diff --git a/src/harfbuzz-config.cmake.in b/src/harfbuzz-config.cmake.in new file mode 100644 index 000000000..304410d9b --- /dev/null +++ b/src/harfbuzz-config.cmake.in @@ -0,0 +1,86 @@ +# Set these variables so that the `${prefix}/lib` expands to something we can +# remove. +set(_harfbuzz_remove_string "REMOVE_ME") +set(exec_prefix "${_harfbuzz_remove_string}") +set(prefix "${_harfbuzz_remove_string}") + +# Compute the installation prefix by stripping components from our current +# location. +get_filename_component(_harfbuzz_prefix "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) +get_filename_component(_harfbuzz_prefix "${_harfbuzz_prefix}" DIRECTORY) +set(_harfbuzz_libdir "@libdir@") +string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_libdir "${_harfbuzz_libdir}") +set(_harfbuzz_libdir_iter "${_harfbuzz_libdir}") +while (_harfbuzz_libdir_iter) + set(_harfbuzz_libdir_prev_iter "${_harfbuzz_libdir_iter}") + get_filename_component(_harfbuzz_libdir_iter "${_harfbuzz_libdir_iter}" DIRECTORY) + if (_harfbuzz_libdir_prev_iter STREQUAL _harfbuzz_libdir_iter) + break() + endif () + get_filename_component(_harfbuzz_prefix "${_harfbuzz_prefix}" DIRECTORY) +endwhile () +unset(_harfbuzz_libdir_iter) + +# Get the include subdir. +set(_harfbuzz_includedir "@includedir@") +string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_includedir "${_harfbuzz_includedir}") + +# Extract version information from libtool. +set(_harfbuzz_version_info "@HB_LIBTOOL_VERSION_INFO@") +string(REPLACE ":" ";" _harfbuzz_version_info "${_harfbuzz_version_info}") +list(GET _harfbuzz_version_info 0 + _harfbuzz_current) +list(GET _harfbuzz_version_info 1 + _harfbuzz_revision) +list(GET _harfbuzz_version_info 2 + _harfbuzz_age) +unset(_harfbuzz_version_info) + +if (APPLE) + set(_harfbuzz_lib_suffix ".0${CMAKE_SHARED_LIBRARY_SUFFIX}") +elseif (UNIX) + set(_harfbuzz_lib_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}.0.${_harfbuzz_current}.${_harfbuzz_revision}") +else () + # Unsupported. + set(harfbuzz_FOUND 0) +endif () + +# Add the libraries. +add_library(harfbuzz::harfbuzz SHARED IMPORTED) +set_target_properties(harfbuzz::harfbuzz PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz" + IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz${_harfbuzz_lib_suffix}") + +add_library(harfbuzz::icu SHARED IMPORTED) +set_target_properties(harfbuzz::icu PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz" + INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz" + IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-icu${_harfbuzz_lib_suffix}") + +add_library(harfbuzz::subset SHARED IMPORTED) +set_target_properties(harfbuzz::subset PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz" + INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz" + IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-subset${_harfbuzz_lib_suffix}") + +# Only add the gobject library if it was built. +set(_harfbuzz_have_gobject "@have_gobject@") +if (_harfbuzz_have_gobject) + add_library(harfbuzz::gobject SHARED IMPORTED) + set_target_properties(harfbuzz::gobject PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz" + INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz" + IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-gobject${_harfbuzz_lib_suffix}") +endif () + +# Clean out variables we used in our scope. +unset(_harfbuzz_lib_suffix) +unset(_harfbuzz_current) +unset(_harfbuzz_revision) +unset(_harfbuzz_age) +unset(_harfbuzz_includedir) +unset(_harfbuzz_libdir) +unset(_harfbuzz_prefix) +unset(exec_prefix) +unset(prefix) +unset(_harfbuzz_remove_string) diff --git a/src/meson.build b/src/meson.build index 242caefae..853e0eb10 100644 --- a/src/meson.build +++ b/src/meson.build @@ -562,6 +562,16 @@ endif have_gobject = conf.get('HAVE_GOBJECT', 0) == 1 +cmake_config = configuration_data() +cmake_config.set('libdir', '${prefix}/@0@'.format(get_option('libdir'))) +cmake_config.set('includedir', '${prefix}/@0@'.format(get_option('includedir'))) +cmake_config.set('HB_LIBTOOL_VERSION_INFO', hb_libtool_version_info) +cmake_config.set('have_gobject', have_gobject ? 'true' : 'false') +configure_file(input: 'harfbuzz-config.cmake.in', + output: 'harfbuzz-config.cmake', + configuration: cmake_config, + install_dir: get_option('libdir') / 'cmake' / 'harfbuzz') + libharfbuzz_gobject_dep = null_dep if have_gobject gnome = import('gnome')