Deal with the missing dependencies for libuv.

Since libuv.pc is broken at the moment, try to determine libuv's
dependencies ourselves.  This ports most of the checks from libuv into
our CMake build, and fixes the build on other unix platforms.
This commit is contained in:
John Szakmeister 2014-03-09 08:40:55 -04:00
parent 0b2f6a0cf4
commit 1eed86883b
3 changed files with 49 additions and 18 deletions

View File

@ -40,10 +40,6 @@ if(NOT CMAKE_USE_PTHREADS_INIT)
message(SEND_ERROR "The pthread library must be installed on your system.") message(SEND_ERROR "The pthread library must be installed on your system.")
endif(NOT CMAKE_USE_PTHREADS_INIT) endif(NOT CMAKE_USE_PTHREADS_INIT)
# Detect if clock_gettime exists in -lrt. If so we need to link with it because
# the static libuv doesn't but uses clock_gettime.
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
find_package(LibIntl) find_package(LibIntl)
if(LibIntl_FOUND) if(LibIntl_FOUND)
include_directories(${LibIntl_INCLUDE_DIR}) include_directories(${LibIntl_INCLUDE_DIR})

View File

@ -46,6 +46,45 @@ mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
set(LIBUV_LIBRARIES ${LIBUV_LIBRARY}) set(LIBUV_LIBRARIES ${LIBUV_LIBRARY})
set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR}) set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR})
# Deal with the fact that libuv.pc is missing important dependency information.
include(CheckLibraryExists)
check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
if(HAVE_LIBDL)
list(APPEND LIBUV_LIBRARIES dl)
endif()
check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
if(HAVE_LIBKSTAT)
list(APPEND LIBUV_LIBRARIES kstat)
endif()
check_library_exists(kvm kvm_open "kvm.h" HAVE_LIBKVM)
if(HAVE_LIBKVM)
list(APPEND LIBUV_LIBRARIES kvm)
endif()
check_library_exists(nsl gethostbyname "nsl.h" HAVE_LIBNSL)
if(HAVE_LIBNSL)
list(APPEND LIBUV_LIBRARIES nsl)
endif()
check_library_exists(perfstat perfstat_cpu "libperfstat.h" HAVE_LIBPERFSTAT)
if(HAVE_LIBPERFSTAT)
list(APPEND LIBUV_LIBRARIES perfstat)
endif()
check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
if(HAVE_LIBRT)
list(APPEND LIBUV_LIBRARIES rt)
endif()
check_library_exists(sendfile sendfile "" HAVE_LIBSENDFILE)
if(HAVE_LIBSENDFILE)
list(APPEND LIBUV_LIBRARIES sendfile)
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBUV_FOUND to TRUE # handle the QUIETLY and REQUIRED arguments and set LIBUV_FOUND to TRUE

View File

@ -1,3 +1,5 @@
include(CheckLibraryExists)
file( GLOB NEOVIM_SOURCES *.c ) file( GLOB NEOVIM_SOURCES *.c )
foreach(sfile ${NEOVIM_SOURCES}) foreach(sfile ${NEOVIM_SOURCES})
@ -25,25 +27,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
endif() endif()
endif() endif()
# The libraries we link against for nvim # Our dependencies come first.
set(NVIM_LINK_LIBRARIES
m
${LIBUV_LIBRARIES}
${LUAJIT_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
# Add any libraries needed for a specific platform
if(HAVE_CLOCK_GETTIME)
# Work around libuv.a not linking in rt.
list(APPEND NVIM_LINK_LIBRARIES rt)
endif(HAVE_CLOCK_GETTIME)
if (LibIntl_FOUND) if (LibIntl_FOUND)
list(APPEND NVIM_LINK_LIBRARIES ${LibIntl_LIBRARY}) list(APPEND NVIM_LINK_LIBRARIES ${LibIntl_LIBRARY})
endif() endif()
include(CheckLibraryExists)
check_library_exists(curses tgetent "" HAVE_LIBCURSES) check_library_exists(curses tgetent "" HAVE_LIBCURSES)
if (HAVE_LIBCURSES) if (HAVE_LIBCURSES)
list(APPEND NVIM_LINK_LIBRARIES curses) list(APPEND NVIM_LINK_LIBRARIES curses)
@ -52,6 +41,13 @@ else()
list(APPEND NVIM_LINK_LIBRARIES ${CURSES_LIBRARIES}) list(APPEND NVIM_LINK_LIBRARIES ${CURSES_LIBRARIES})
endif() endif()
# Put these last on the link line, since multiple things may depend on them.
list(APPEND NVIM_LINK_LIBRARIES
${LIBUV_LIBRARIES}
${LUAJIT_LIBRARIES}
m
${CMAKE_THREAD_LIBS_INIT})
if(NOT DEFINED ENV{SKIP_EXEC}) if(NOT DEFINED ENV{SKIP_EXEC})
add_executable(nvim ${NEOVIM_SOURCES} ${OS_SOURCES}) add_executable(nvim ${NEOVIM_SOURCES} ${OS_SOURCES})
target_link_libraries(nvim ${NVIM_LINK_LIBRARIES}) target_link_libraries(nvim ${NVIM_LINK_LIBRARIES})