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

CMake: Use library aliases instead of library names #55

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

kobalicek
Copy link
Contributor

This changeset makes it possible to compile hyprlang with a custom install prefix, which was not honored because of using "hyprutils" as a raw dependency, which means that CMake was adding "-lhyprutils" flag to the linker, but the linker didn't know the path in case a custom install prefix was used to compile hyprutils.

@vaxerski
Copy link
Member

why?

@kobalicek
Copy link
Contributor Author

If you install hyprutils to /opt/hyprland, for example, and use the same install prefix to build hyprlang, it will fail to link hyprlang_test and hyprlang_fuzz because it only passes the library name to the linker, but not the path:

target_link_libraries(hyprlang_fuzz PRIVATE hyprlang hyprutils)

This means passing -lhyprlang -lhyprutils to the linker, but not the prefix path, which is essential if it's not the default.

However, if you use the namespaced alias hyprland::xxx then cmake sees it as a dependency and passes correct link flags to the linker, including library paths, so it would also pass -L/opt/hyprland and would link correctly.

@vaxerski
Copy link
Member

makes sense, would be better to call the namespace hypr tho

This changeset makes it possible to compile hyprlang with a custom
install prefix, which was not honored because of using "hyprutils" as
a raw dependency, which means that CMake was adding "-lhyprutils" flag
to the linker, but the linker didn't know the path in case a custom
install prefix was used to compile hyprutils.
@kobalicek
Copy link
Contributor Author

Done

@vaxerski vaxerski merged commit dfeb581 into hyprwm:main Sep 10, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants