diff options
author | Rich Wareham <rjw57@cam.ac.uk> | 2014-02-26 10:06:59 +0000 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-02-26 07:10:21 -0300 |
commit | de4fbf92d0da17e2c7f31df29bc72c44702b4e7c (patch) | |
tree | 7b99449cbd922654a1181c87fb11d2e2f6c82ed3 | |
parent | c3ff8cbb7cfe715604099809d0f5f2de84514717 (diff) | |
download | rneovim-de4fbf92d0da17e2c7f31df29bc72c44702b4e7c.tar.gz rneovim-de4fbf92d0da17e2c7f31df29bc72c44702b4e7c.tar.bz2 rneovim-de4fbf92d0da17e2c7f31df29bc72c44702b4e7c.zip |
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.
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/CMakeLists.txt | 13 |
2 files changed, 19 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b057a67f69..04df162f07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ else() set(DEBUG 0) endif() +# Modules used by platform auto-detection +include(CheckLibraryExists) + # Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD # explicitly to indicate a strong preference for pthread. It is an error to not # have pthread installed even if, for example, the Win32 threading API is found. @@ -27,11 +30,15 @@ if(NOT CMAKE_USE_PTHREADS_INIT) message(SEND_ERROR "The pthread library must be installed on your system.") 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) + # Require libuv find_package(LibUV REQUIRED) include_directories(${LibUV_INCLUDE_DIRS}) -include_directories ("${PROJECT_BINARY_DIR}/config") +include_directories ("${PROJECT_BINARY_DIR}/config") set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96c0b01f3d..a7e815fd7c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) |