link to rt if it provides clock_gettime

As noted in #128, if clock_gettime is provided by librt then it does not
end up being linked into the static libuv.a binary. This might be
considered a bug in libuv but we can address it here.

Detect if librt provides the clock_gettime symbol and, if so, append it
to the list of libraries linked into nvim. On non-librt systems the
behaviour should be as before.
This commit is contained in:
Rich Wareham
2014-02-26 10:06:59 +00:00
committed by Thiago de Arruda
parent c3ff8cbb7c
commit de4fbf92d0
2 changed files with 19 additions and 3 deletions

View File

@@ -14,7 +14,16 @@ file( GLOB OS_SOURCES os/*.c )
add_executable (nvim ${NEOVIM_SOURCES} ${OS_SOURCES})
target_link_libraries (vim m ${LibUV_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
# The libraries we link against for nvim
set(NVIM_LINK_LIBRARIES m ${LibUV_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)
target_link_libraries (nvim ${NVIM_LINK_LIBRARIES})
include(CheckLibraryExists)
check_library_exists(termcap tgetent "" HAVE_LIBTERMCAP)
@@ -30,6 +39,6 @@ else()
endif()
endif()
include_directories ("${PROJECT_SOURCE_DIR}/src/proto")
include_directories ("${PROJECT_SOURCE_DIR}/src/proto")
install(TARGETS nvim RUNTIME DESTINATION bin)