diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | cmake/FindMsgpack.cmake | 51 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 |
3 files changed, 55 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 61a54273c9..918687f9d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,9 @@ include(CheckLibraryExists) find_package(LibUV REQUIRED) include_directories(${LIBUV_INCLUDE_DIRS}) +find_package(Msgpack REQUIRED) +include_directories(${MSGPACK_INCLUDE_DIRS}) + find_package(LuaJit REQUIRED) include_directories(${LUAJIT_INCLUDE_DIRS}) diff --git a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake new file mode 100644 index 0000000000..e7b32eecea --- /dev/null +++ b/cmake/FindMsgpack.cmake @@ -0,0 +1,51 @@ +# - Try to find msgpack +# Once done this will define +# MSGPACK_FOUND - System has msgpack +# MSGPACK_INCLUDE_DIRS - The msgpack include directories +# MSGPACK_LIBRARIES - The libraries needed to use msgpack + +find_package(PkgConfig) +if(NOT MSGPACK_USE_BUNDLED) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_MSGPACK QUIET msgpack) + endif() +else() + set(PC_MSGPACK_INCLUDEDIR) + set(PC_MSGPACK_INCLUDE_DIRS) + set(PC_MSGPACK_LIBDIR) + set(PC_MSGPACK_LIBRARY_DIRS) + set(LIMIT_SEARCH NO_DEFAULT_PATH) +endif() + +set(MSGPACK_DEFINITIONS ${PC_MSGPACK_CFLAGS_OTHER}) + +find_path(MSGPACK_INCLUDE_DIR msgpack.h + HINTS ${PC_MSGPACK_INCLUDEDIR} ${PC_MSGPACK_INCLUDE_DIRS} + PATHS "${DEPS_INSTALL_DIR}" + ${LIMIT_SEARCH}) + +# If we're asked to use static linkage, add libmsgpackc.a as a preferred library name. +if(MSGPACK_USE_STATIC) + list(APPEND MSGPACK_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}msgpackc${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() + +list(APPEND MSGPACK_NAMES msgpackc) + +find_library(MSGPACK_LIBRARY NAMES ${MSGPACK_NAMES} + HINTS ${PC_MSGPACK_LIBDIR} ${PC_MSGPACK_LIBRARY_DIRS} + PATHS "${DEPS_INSTALL_DIR}" + ${LIMIT_SEARCH}) + +mark_as_advanced(MSGPACK_INCLUDE_DIR MSGPACK_LIBRARY) + +set(MSGPACK_LIBRARIES ${MSGPACK_LIBRARY}) +set(MSGPACK_INCLUDE_DIRS ${MSGPACK_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set MSGPACK_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Msgpack DEFAULT_MSG + MSGPACK_LIBRARY MSGPACK_INCLUDE_DIR) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a5e6ebdc5..48f656fad4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,7 @@ endif() # Put these last on the link line, since multiple things may depend on them. list(APPEND NVIM_LINK_LIBRARIES ${LIBUV_LIBRARIES} + ${MSGPACK_LIBRARIES} ${LUAJIT_LIBRARIES} m ${CMAKE_THREAD_LIBS_INIT}) |