diff --git a/cmake/FindLibTermkey.cmake b/cmake/FindLibTermkey.cmake new file mode 100644 index 0000000000..533f168fe9 --- /dev/null +++ b/cmake/FindLibTermkey.cmake @@ -0,0 +1,48 @@ +# - Try to find libtermkey +# Once done this will define +# LIBTERMKEY_FOUND - System has libtermkey +# LIBTERMKEY_INCLUDE_DIRS - The libtermkey include directories +# LIBTERMKEY_LIBRARIES - The libraries needed to use libtermkey + +find_package(PkgConfig) +if(NOT LIBTERMKEY_USE_BUNDLED) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBTERMKEY QUIET libtermkey) + endif() +else() + set(PC_LIBTERMKEY_INCLUDEDIR) + set(PC_LIBTERMKEY_INCLUDE_DIRS) + set(PC_LIBTERMKEY_LIBDIR) + set(PC_LIBTERMKEY_LIBRARY_DIRS) + set(LIMIT_SEARCH NO_DEFAULT_PATH) +endif() + +set(LIBTERMKEY_DEFINITIONS ${PC_LIBTERMKEY_CFLAGS_OTHER}) + +find_path(LIBTERMKEY_INCLUDE_DIR termkey.h + PATHS ${PC_LIBTERMKEY_INCLUDEDIR} ${PC_LIBTERMKEY_INCLUDE_DIRS} + ${LIMIT_SEARCH}) + +# If we're asked to use static linkage, add libuv.a as a preferred library name. +if(LIBTERMKEY_USE_STATIC) + list(APPEND LIBTERMKEY_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}termkey${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() + +list(APPEND LIBTERMKEY_NAMES termkey) + +find_library(LIBTERMKEY_LIBRARY NAMES ${LIBTERMKEY_NAMES} + HINTS ${PC_LIBTERMKEY_LIBDIR} ${PC_LIBTERMKEY_LIBRARY_DIRS} + ${LIMIT_SEARCH}) + +set(LIBTERMKEY_LIBRARIES ${LIBTERMKEY_LIBRARY}) +set(LIBTERMKEY_INCLUDE_DIRS ${LIBTERMKEY_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set LIBTERMKEY_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(LibTermkey DEFAULT_MSG + LIBTERMKEY_LIBRARY LIBTERMKEY_INCLUDE_DIR) + +mark_as_advanced(LIBTERMKEY_INCLUDE_DIR LIBTERMKEY_LIBRARY) diff --git a/cmake/FindLibTickit.cmake b/cmake/FindLibTickit.cmake new file mode 100644 index 0000000000..c20bf4f74f --- /dev/null +++ b/cmake/FindLibTickit.cmake @@ -0,0 +1,48 @@ +# - Try to find libtickit +# Once done this will define +# LIBTICKIT_FOUND - System has libtickit +# LIBTICKIT_INCLUDE_DIRS - The libtickit include directories +# LIBTICKIT_LIBRARIES - The libraries needed to use libtickit + +find_package(PkgConfig) +if(NOT LIBTICKIT_USE_BUNDLED) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBTICKIT QUIET libtickit) + endif() +else() + set(PC_LIBTICKIT_INCLUDEDIR) + set(PC_LIBTICKIT_INCLUDE_DIRS) + set(PC_LIBTICKIT_LIBDIR) + set(PC_LIBTICKIT_LIBRARY_DIRS) + set(LIMIT_SEARCH NO_DEFAULT_PATH) +endif() + +set(LIBTICKIT_DEFINITIONS ${PC_LIBTICKIT_CFLAGS_OTHER}) + +find_path(LIBTICKIT_INCLUDE_DIR tickit.h + PATHS ${PC_LIBTICKIT_INCLUDEDIR} ${PC_LIBTICKIT_INCLUDE_DIRS} + ${LIMIT_SEARCH}) + +# If we're asked to use static linkage, add libuv.a as a preferred library name. +if(LIBTICKIT_USE_STATIC) + list(APPEND LIBTICKIT_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}tickit${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() + +list(APPEND LIBTICKIT_NAMES tickit) + +find_library(LIBTICKIT_LIBRARY NAMES ${LIBTICKIT_NAMES} + HINTS ${PC_LIBTICKIT_LIBDIR} ${PC_LIBTICKIT_LIBRARY_DIRS} + ${LIMIT_SEARCH}) + +set(LIBTICKIT_LIBRARIES ${LIBTICKIT_LIBRARY}) +set(LIBTICKIT_INCLUDE_DIRS ${LIBTICKIT_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set LIBTICKIT_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(LibTickit DEFAULT_MSG + LIBTICKIT_LIBRARY LIBTICKIT_INCLUDE_DIR) + +mark_as_advanced(LIBTICKIT_INCLUDE_DIR LIBTICKIT_LIBRARY) diff --git a/cmake/FindLibUnibilium.cmake b/cmake/FindLibUnibilium.cmake new file mode 100644 index 0000000000..aace9a40d5 --- /dev/null +++ b/cmake/FindLibUnibilium.cmake @@ -0,0 +1,48 @@ +# - Try to find libunibilium +# Once done this will define +# LIBUNIBILIUM_FOUND - System has libunibilium +# LIBUNIBILIUM_INCLUDE_DIRS - The libunibilium include directories +# LIBUNIBILIUM_LIBRARIES - The libraries needed to use libunibilium + +find_package(PkgConfig) +if(NOT LIBUNIBILIUM_USE_BUNDLED) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBUNIBILIUM QUIET libunibilium) + endif() +else() + set(PC_LIBUNIBILIUM_INCLUDEDIR) + set(PC_LIBUNIBILIUM_INCLUDE_DIRS) + set(PC_LIBUNIBILIUM_LIBDIR) + set(PC_LIBUNIBILIUM_LIBRARY_DIRS) + set(LIMIT_SEARCH NO_DEFAULT_PATH) +endif() + +set(LIBUNIBILIUM_DEFINITIONS ${PC_LIBUNIBILIUM_CFLAGS_OTHER}) + +find_path(LIBUNIBILIUM_INCLUDE_DIR unibilium.h + PATHS ${PC_LIBUNIBILIUM_INCLUDEDIR} ${PC_LIBUNIBILIUM_INCLUDE_DIRS} + ${LIMIT_SEARCH}) + +# If we're asked to use static linkage, add libuv.a as a preferred library name. +if(LIBUNIBILIUM_USE_STATIC) + list(APPEND LIBUNIBILIUM_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}unibilium${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() + +list(APPEND LIBUNIBILIUM_NAMES unibilium) + +find_library(LIBUNIBILIUM_LIBRARY NAMES ${LIBUNIBILIUM_NAMES} + HINTS ${PC_LIBUNIBILIUM_LIBDIR} ${PC_LIBUNIBILIUM_LIBRARY_DIRS} + ${LIMIT_SEARCH}) + +set(LIBUNIBILIUM_LIBRARIES ${LIBUNIBILIUM_LIBRARY}) +set(LIBUNIBILIUM_INCLUDE_DIRS ${LIBUNIBILIUM_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set LIBUNIBILIUM_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(LibUnibilium DEFAULT_MSG + LIBUNIBILIUM_LIBRARY LIBUNIBILIUM_INCLUDE_DIR) + +mark_as_advanced(LIBUNIBILIUM_INCLUDE_DIR LIBUNIBILIUM_LIBRARY) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 83c2cfdc61..6c359050bd 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -15,6 +15,9 @@ set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads") option(USE_BUNDLED "Use bundled dependencies." ON) +option(USE_BUNDLED_LIBUNIBILIUM "Use the bundled libunibilium." ${USE_BUNDLED}) +option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED}) +option(USE_BUNDLED_LIBTICKIT "Use the bundled libtickit." ${USE_BUNDLED}) option(USE_BUNDLED_LIBUV "Use the bundled libuv." ${USE_BUNDLED}) option(USE_BUNDLED_MSGPACK "Use the bundled msgpack." ${USE_BUNDLED}) option(USE_BUNDLED_LUAJIT "Use the bundled version of luajit." ${USE_BUNDLED}) @@ -67,6 +70,90 @@ set(LUAROCKS_URL https://github.com/keplerproject/luarocks/archive/0587afbb5fe8c set(LUAROCKS_SHA1 61a894fd5d61987bf7e7f9c3e0c5de16ba4b68c4) set(LUAROCKS_MD5 0f53f42909fbcd2c88be303e8f970516) +set(LIBUNIBILIUM_URL https://github.com/mauke/unibilium/archive/v1.1.0.tar.gz) +set(LIBUNIBILIUM_SHA1 edda116e736396315abb33397f7815103e2d4fe4) +set(LIBUNIBILIUM_MD5 60f3e6db236daf12cbc92f0b60d9eddc) + +set(LIBTERMKEY_URL https://github.com/neovim/libtermkey/archive/neovim.tar.gz) +set(LIBTERMKEY_SHA1 a309038a2297fe4905f03a8807723a9aa07c272a) +set(LIBTERMKEY_MD5 c99e5546da0063fa26dfa7d7f1d5a26f) + +set(LIBTICKIT_URL https://github.com/neovim/libtickit/archive/neovim.tar.gz) +set(LIBTICKIT_SHA1 49e609de29c3bdc3b40d2ade76e69fde6e0d74bc) +set(LIBTICKIT_MD5 71a5d36d0ef6688d79828aabaf27eb36) + +if(USE_BUNDLED_LIBUNIBILIUM) + ExternalProject_Add(libunibilium + PREFIX ${DEPS_BUILD_DIR} + URL ${LIBUNIBILIUM_URL} + DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/libunibilium + DOWNLOAD_COMMAND ${CMAKE_COMMAND} + -DPREFIX=${DEPS_BUILD_DIR} + -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/libunibilium + -DURL=${LIBUNIBILIUM_URL} + -DEXPECTED_SHA1=${LIBUNIBILIUM_SHA1} + -DEXPECTED_MD5=${LIBUNIBILIUM_MD5} + -DTARGET=libunibilium + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE 1 + BUILD_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} + PREFIX=${DEPS_INSTALL_DIR} + CFLAGS=-fPIC + INSTALL_COMMAND ${MAKE_PRG} PREFIX=${DEPS_INSTALL_DIR} install) + list(APPEND THIRD_PARTY_DEPS libunibilium) +endif() + +if(USE_BUNDLED_LIBTERMKEY) + ExternalProject_Add(libtermkey + PREFIX ${DEPS_BUILD_DIR} + URL ${LIBTERMKEY_URL} + DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/libtermkey + DOWNLOAD_COMMAND ${CMAKE_COMMAND} + -DPREFIX=${DEPS_BUILD_DIR} + -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/libtermkey + -DURL=${LIBTERMKEY_URL} + -DEXPECTED_SHA1=${LIBTERMKEY_SHA1} + -DEXPECTED_MD5=${LIBTERMKEY_MD5} + -DTARGET=libtermkey + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE 1 + BUILD_COMMAND "" + INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} + PREFIX=${DEPS_INSTALL_DIR} + PKG_CONFIG_PATH=${DEPS_LIB_DIR}/pkgconfig + CFLAGS=-fPIC + install) + list(APPEND THIRD_PARTY_DEPS libtermkey) + add_dependencies(libtermkey libunibilium) +endif() + +if(USE_BUNDLED_LIBTICKIT) + ExternalProject_Add(libtickit + PREFIX ${DEPS_BUILD_DIR} + URL ${LIBTICKIT_URL} + DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/libtickit + DOWNLOAD_COMMAND ${CMAKE_COMMAND} + -DPREFIX=${DEPS_BUILD_DIR} + -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/libtickit + -DURL=${LIBTICKIT_URL} + -DEXPECTED_SHA1=${LIBTICKIT_SHA1} + -DEXPECTED_MD5=${LIBTICKIT_MD5} + -DTARGET=libtickit + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE 1 + BUILD_COMMAND "" + INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} + PREFIX=${DEPS_INSTALL_DIR} + PKG_CONFIG_PATH=${DEPS_LIB_DIR}/pkgconfig + CFLAGS=-fPIC + install) + list(APPEND THIRD_PARTY_DEPS libtickit) + add_dependencies(libtickit libtermkey) +endif() + if(USE_BUNDLED_LIBUV) ExternalProject_Add(libuv PREFIX ${DEPS_BUILD_DIR}