Vcpkg: [harfbuzz] Missing INTERFACE_INCLUDE_DIRECTORIES for harfbuzz::harfbuzz target

Created on 10 Aug 2020  路  6Comments  路  Source: microsoft/vcpkg

Describe the bug

Compiler complains that it cannot find <hb.h> despite installing harfbuzz with vcpkg, and linking to the target in CMake.

Environment

  • OS: Windows 7 64bit
  • Compiler: MSVC 2017 x64

To Reproduce

  1. vcpkg integrate install
  2. vcpkg install freetype:x64-windows harfbuzz:x64-windows

CMakeLists.txt:

cmake_minimum_required(VERSION 3.1.0)
project(testharfbuzz)
set(CMAKE_CXX_STANDARD 11)

find_package(freetype CONFIG REQUIRED)
get_target_property(FREETYPE_INCLUDE_DIRS freetype INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "FreeType include dirs: ${FREETYPE_INCLUDE_DIRS}")

find_package(harfbuzz CONFIG REQUIRED)
get_target_property(HARFBUZZ_INCLUDE_DIRS harfbuzz::harfbuzz INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "HarfBuzz include dirs: ${HARFBUZZ_INCLUDE_DIRS}")

add_executable(main main.cpp)
target_link_libraries(main PRIVATE freetype harfbuzz::harfbuzz)

main.cpp:

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H

#include <hb.h>
#include <hb-ft.h>

int main() {
    return 0;
}
  1. cmake .. -G "Visual Studio 15 2017" -A x64 -DCMAKE_TOOLCHAIN_FILE="%UserProfile%\vcpkg\scripts\buildsystems\vcpkg.cmake"

Output:

-- Selecting Windows SDK version 10.0.17134.0 to target Windows 6.1.7601.
-- The C compiler identification is MSVC 19.15.26729.0
-- The CXX compiler identification is MSVC 19.15.26729.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- FreeType include dirs: C:/Users/Boris/vcpkg/installed/x64-windows/include
-- HarfBuzz include dirs: HARFBUZZ_INCLUDE_DIRS-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Boris/Documents/testharfbuzz/build
````

Expected output:

-- HarfBuzz include dirs: C:/Users/Boris/vcpkg/installed/x64-windows/include/harfbuzz
````

  1. cmake --build . --config Release

Output:

c:\users\boris\documents\testharfbuzz\main.cpp(6): fatal error C1083: Cannot open include file: 'hb.h': No such file or directory [C:\Users\Boris\Documents\testharfbuzz\build\main.vcxproj]
````

Expected output: No errors

**Additional context**

I suspect there's an INTERFACE_INCLUDE_DIRECTORIES something missing in the vcpkg\installed\x64-windows\share\harfbuzz\harfbuzzConfig.cmake

Indeed, we can see the following:

Create imported target harfbuzz::harfbuzz

add_library(harfbuzz::harfbuzz SHARED IMPORTED)


But there seems to be no INTERFACE_INCLUDE_DIRECTORIES added. By comparison, we can see the following in vcpkg\installed\x64-windows\share\freetype\freetype-config.cmake:

Create imported target freetype

add_library(freetype SHARED IMPORTED)

set_target_properties(freetype PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)
```

port-bug

All 6 comments

Here is a workaround that works for now (obviously, should be fine-tuned if you also need x86-windows, etc.)

find_package(harfbuzz CONFIG REQUIRED)
set(HARFBUZZ_INCLUDE_DIRS "${_VCPKG_ROOT_DIR}/installed/x64-windows/include/harfbuzz")
set_target_properties(harfbuzz::harfbuzz PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${HARFBUZZ_INCLUDE_DIRS}")

@dalboris, I thinkl this is expected, you need use #include when you use harfbuzz headers. since all headers installed to ./include/harfbuzz folder.

Hum... no, here is from the manual:

https://harfbuzz.github.io/ch03s03.html

#include <hb.h>
hb_buffer_t *buf;
buf = hb_buffer_create();
hb_buffer_add_utf8(buf, text, -1, 0, -1);

I haven't seen a single source file using <harfbuzz/hb.h> instead.

@dalboris, right, double confrimed, this is a port bug, I will fix this issue.

Good catch! @dalboris.

@dalboris, thanks for reporting this issue!

I have summited PR #12871 to fix this issue.

@PhoebeHui Thanks a lot! I'm not familiar with vcpkg's inner workings but the PR does look great as far as I can tell :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

invy picture invy  路  3Comments

jack17529 picture jack17529  路  3Comments

jasjuang picture jasjuang  路  3Comments

cjvaijo picture cjvaijo  路  3Comments

tzbo picture tzbo  路  3Comments