build: use libuv config file (#22209)

Libuv's recent changes in their pc file breaks cmake; they are using
-l:libuv.a for the linker, and it seems cmake can't resolve that.

Prefer using their cmake config file instead instead, and use the find
module as a fall-back in case it fails.

Closes https://github.com/neovim/neovim/issues/22271.
This commit is contained in:
ii14 2023-02-16 22:09:05 +01:00 committed by GitHub
parent bb377afd32
commit 6dfabd0145
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -13,7 +13,7 @@ endif()
find_path(LIBUV_INCLUDE_DIR uv.h
HINTS ${PC_LIBUV_INCLUDEDIR} ${PC_LIBUV_INCLUDE_DIRS})
list(APPEND LIBUV_NAMES uv_a uv libuv)
list(APPEND LIBUV_NAMES uv_a uv)
find_library(LIBUV_LIBRARY NAMES ${LIBUV_NAMES}
HINTS ${PC_LIBUV_LIBDIR} ${PC_LIBUV_LIBRARY_DIRS})

View File

@ -2,9 +2,15 @@ add_library(main_lib INTERFACE)
add_executable(nvim main.c)
add_library(libuv_lib INTERFACE)
find_package(LibUV 1.28.0 REQUIRED)
target_include_directories(libuv_lib SYSTEM BEFORE INTERFACE ${LIBUV_INCLUDE_DIRS})
target_link_libraries(libuv_lib INTERFACE ${LIBUV_LIBRARIES})
find_package(libuv CONFIG)
if(TARGET libuv::uv_a)
target_link_libraries(libuv_lib INTERFACE libuv::uv_a)
else()
# Fallback to find module for older libuv versions, that don't provide the cmake package
find_package(LibUV 1.28.0 REQUIRED MODULE)
target_include_directories(libuv_lib SYSTEM BEFORE INTERFACE ${LIBUV_INCLUDE_DIRS})
target_link_libraries(libuv_lib INTERFACE ${LIBUV_LIBRARIES})
endif()
find_package(Msgpack 1.0.0 REQUIRED)
target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${MSGPACK_INCLUDE_DIRS})