CMake: Use library aliases instead of library names (#55)

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.
This commit is contained in:
Petr Kobalicek 2024-09-10 21:51:00 +02:00 committed by GitHub
parent 5b175c9704
commit dfeb5811dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -56,13 +56,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Using clang++ to compile hyprlang")
endif()
add_library(hypr::hyprlang ALIAS hyprlang)
install(TARGETS hyprlang)
# tests
add_custom_target(tests)
add_executable(hyprlang_test "tests/parse/main.cpp")
target_link_libraries(hyprlang_test PRIVATE hyprlang hyprutils)
target_link_libraries(hyprlang_test PRIVATE hypr::hyprlang)
add_test(
NAME "Parsing"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
@ -70,7 +71,7 @@ add_test(
add_dependencies(tests hyprlang_test)
add_executable(hyprlang_fuzz "tests/fuzz/main.cpp")
target_link_libraries(hyprlang_fuzz PRIVATE hyprlang hyprutils)
target_link_libraries(hyprlang_fuzz PRIVATE hypr::hyprlang)
add_test(
NAME "Fuzz"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests