Skip to content

Commit

Permalink
Use cmake_path(APPEND) to determine include directory
Browse files Browse the repository at this point in the history
The previous code concatenates includedir to _harfbuzz_prefix verbatim, which
results in a wrong resulting include path in case includedir is an absolute
path. The right behavior would be in this case to drop _harfbuzz_prefix and
just use the absolute path which this implements using cmake_path(APPEND).

This is an issue in nixpkgs, where includedir is set to the final (absolute)
path of the built library in the Nix store, which causes CMake projects
depending on harfbuzz to not configure.

See NixOS/nixpkgs#180054.

NB: cmake_path is a function introduced in CMake 3.20, while harfbuzz's
CMakeLists.txt currently specifies 3.12.
  • Loading branch information
2xsaiko committed Oct 26, 2022
1 parent 83769b9 commit 3a9438a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/harfbuzz-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ unset(_harfbuzz_libdir_iter)
# Get the include subdir.
set(_harfbuzz_includedir "@includedir@")
string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_includedir "${_harfbuzz_includedir}")
cmake_path(APPEND "${_harfbuzz_prefix}" "${_harfbuzz_includedir}" OUTPUT_VARIABLE _harfbuzz_includedir)

# Extract version information from libtool.
set(_harfbuzz_version_info "@HB_LIBTOOL_VERSION_INFO@")
Expand All @@ -48,18 +49,18 @@ endif ()
# Add the libraries.
add_library(harfbuzz::harfbuzz SHARED IMPORTED)
set_target_properties(harfbuzz::harfbuzz PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
INTERFACE_INCLUDE_DIRECTORIES "${_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_INCLUDE_DIRECTORIES "${_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_INCLUDE_DIRECTORIES "${_harfbuzz_includedir}/harfbuzz"
INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-subset${_harfbuzz_lib_suffix}")

Expand All @@ -68,7 +69,7 @@ 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_INCLUDE_DIRECTORIES "${_harfbuzz_includedir}/harfbuzz"
INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-gobject${_harfbuzz_lib_suffix}")
endif ()
Expand Down

0 comments on commit 3a9438a

Please sign in to comment.