Skip to content

FindGTK2.cmake should export the include path for harfbuzz

CMake Version: 3.15.1
OS: Arch Linux

Starting with version 1.44.1, pango headers stopped assuming harfbuzz headers are installed under /usr/include/harfbuzz. The change is made by this commit.

It means the include path for harfbuzz must be provided when building the project that uses pango, that is in turn used by gtk.

Right now, following simple program fails to build in my environment, which installs harfbuzz headers under /usr/include/harfbuzz.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(gtktest)

add_executable(${PROJECT_NAME} main.c)

find_package(GTK2 REQUIRED gtk)

target_link_libraries(${PROJECT_NAME} PRIVATE GTK2::gtk)

main.c:

#include <gtk/gtk.h>

int main(void) {}

Error Message:

[ 50%] Building C object CMakeFiles/gtktest.dir/main.c.o
In file included from /usr/include/pango-1.0/pango/pango-font.h:25,
                 from /usr/include/pango-1.0/pango/pango-attributes.h:25,
                 from /usr/include/pango-1.0/pango/pango.h:25,
                 from /usr/include/gtk-2.0/gdk/gdktypes.h:37,
                 from /usr/include/gtk-2.0/gdk/gdkscreen.h:32,
                 from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:31,
                 from /usr/include/gtk-2.0/gdk/gdk.h:32,
                 from /usr/include/gtk-2.0/gtk/gtk.h:32,
                 from /path/to/project/main.c:1:
/usr/include/pango-1.0/pango/pango-coverage.h:28:10: fatal error: hb.h: No such file or directory
   28 | #include <hb.h>
      |          ^~~~~~

For reference, here is output of pkgconf --cflags gtk+-2.0. Notice harfbuzz include path is included.

-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/atk-1.0 -pthread
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information