Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harfbuzz's CMake config uses the wrong path #180054

Closed
2xsaiko opened this issue Jul 3, 2022 · 3 comments · Fixed by #207041
Closed

Harfbuzz's CMake config uses the wrong path #180054

2xsaiko opened this issue Jul 3, 2022 · 3 comments · Fixed by #207041

Comments

@2xsaiko
Copy link
Contributor

2xsaiko commented Jul 3, 2022

Describe the bug

Trying to use harfbuzz in a CMake project, CMake fails with the following:

CMake Error in CMakeLists.txt:
  Imported target "harfbuzz::harfbuzz" includes non-existent path

    "/nix/store/7ahz2g1i3m2pfk96fjl6j37ldcwlxpbg-harfbuzz-3.3.2-dev//nix/store/7ahz2g1i3m2pfk96fjl6j37ldcwlxpbg-harfbuzz-3.3.2-dev/include/harfbuzz"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

That path comes from /nix/store/7ahz2g1i3m2pfk96fjl6j37ldcwlxpbg-harfbuzz-3.3.2-dev/lib/cmake/harfbuzz/harfbuzz-config.cmake, probably on line 25 which says set(_harfbuzz_includedir "${prefix}//nix/store/7ahz2g1i3m2pfk96fjl6j37ldcwlxpbg-harfbuzz-3.3.2-dev/include").

Steps To Reproduce

Steps to reproduce the behavior:

  1. Make a CMake project that tries to link an executable to harfbuzz:
    find_package(harfbuzz REQUIRED)
    add_executable(program main.c)
    target_link_libraries(program harfbuzz::harfbuzz)
    
  2. Try to configure project (cmake .)
  3. See error above

Expected behavior

The project configures successfully.

Notify maintainers

@edolstra

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.49, NixOS, 22.11 (Raccoon), 22.11.20220627.020c740`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.9.1`
 - nixpkgs: `/etc/nix/inputs/nixpkgs`
@2xsaiko

This comment was marked as outdated.

2xsaiko added a commit to 2xsaiko/harfbuzz that referenced this issue Oct 26, 2022
When includedir is set to an absolute path, the previous code appends that
absolute path to ${prefix}, which results in a wrong path. The right behavior
would be in this case to drop ${prefix} and just use the absolute path.

This is an issue in nixpkgs, where includedir is set to the final (absolute)
path of the built library in the Nix store.

See NixOS/nixpkgs#180054.
2xsaiko added a commit to 2xsaiko/harfbuzz that referenced this issue Oct 26, 2022
When includedir or libdir are set to an absolute path, the previous code
appends that absolute path to ${prefix}, which results in a wrong path. The
right behavior would be in this case to drop ${prefix} and just use the
absolute path.

This is an issue in nixpkgs, where includedir is set to the final (absolute)
path of the built library in the Nix store.

See NixOS/nixpkgs#180054.
@2xsaiko

This comment was marked as outdated.

2xsaiko added a commit to 2xsaiko/harfbuzz that referenced this issue Oct 26, 2022
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.
2xsaiko added a commit to 2xsaiko/harfbuzz that referenced this issue Oct 26, 2022
The previous code concatenates includedir to _harfbuzz_prefix verbatim,
which results in a wrong resulting include path in case includedir is an
absolute path. Instead, we can let meson determine the absolute include and
lib paths in advance and save them in the cmake config.

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.
2xsaiko added a commit to 2xsaiko/harfbuzz that referenced this issue Oct 26, 2022
The previous code concatenates includedir to _harfbuzz_prefix verbatim,
which results in a wrong resulting include path in case includedir is an
absolute path. Instead, we can let meson determine the absolute include and
lib paths in advance and save them in the cmake config.

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.
2xsaiko added a commit to 2xsaiko/harfbuzz that referenced this issue Oct 26, 2022
The previous code concatenates includedir to _harfbuzz_prefix verbatim,
which results in a wrong final include path in case includedir is an absolute
path. Instead, we can let meson determine the absolute include and lib paths
in advance and save them in the cmake config.

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.
@2xsaiko
Copy link
Contributor Author

2xsaiko commented Dec 20, 2022

Fixed in harfbuzz 6.0.0.

@2xsaiko 2xsaiko mentioned this issue Dec 20, 2022
13 tasks
@2xsaiko 2xsaiko closed this as completed Jan 4, 2023
CMake breakage automation moved this from To do to Done Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

1 participant