diff options
Diffstat (limited to 'third-party')
-rw-r--r-- | third-party/CMakeLists.txt | 13 | ||||
-rw-r--r-- | third-party/cmake/BuildGperf.cmake | 51 |
2 files changed, 64 insertions, 0 deletions
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 2e41d745d7..823e9719d1 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -32,6 +32,12 @@ option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED}) # build it unless explicitly requested option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF) +if(USE_BUNDLED AND (NOT WIN32)) + option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ON) +else() + option(USE_BUNDLED_GPERF "Use the bundled version of gperf." OFF) +endif() + option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF) if(UNIX) @@ -111,6 +117,9 @@ set(JEMALLOC_SHA256 5630650d5c1caab95d2f0898de4fe5ab8519dc680b04963b38bb425ef6a4 set(LUV_URL https://github.com/luvit/luv/archive/146f1ce4c08c3b67f604c9ee1e124b1cf5c15cf3.tar.gz) set(LUV_SHA256 3d537f8eb9fa5adb146a083eae22af886aee324ec268e2aa0fa75f2f1c52ca7a) +set(GPERF_URL http://ftp.gnu.org/pub/gnu/gperf/gperf-3.0.4.tar.gz) +set(GPERF_SHA256 767112a204407e62dbc3106647cf839ed544f3cf5d0f0523aaa2508623aad63e) + if(USE_BUNDLED_UNIBILIUM) include(BuildUnibilium) endif() @@ -151,6 +160,10 @@ if(USE_BUNDLED_LUV) include(BuildLuv) endif() +if(USE_BUNDLED_GPERF) + include(BuildGperf) +endif() + add_custom_target(clean-shared-libraries COMMAND ${CMAKE_COMMAND} -DREMOVE_FILE_GLOB=${DEPS_INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}* diff --git a/third-party/cmake/BuildGperf.cmake b/third-party/cmake/BuildGperf.cmake new file mode 100644 index 0000000000..494d0d9717 --- /dev/null +++ b/third-party/cmake/BuildGperf.cmake @@ -0,0 +1,51 @@ +# Gperf recipe. Gperf is only required when building Neovim, when +# cross compiling we still want to build for the HOST system, whenever +# writing a recipe that is meant for cross-compile, use the HOSTDEPS_* variables +# instead of DEPS_* - check the main CMakeLists.txt for a list. + +# BuildGperf(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...) +# Reusable function to build Gperf, wraps ExternalProject_Add. +# Failing to pass a command argument will result in no command being run +function(BuildGperf) + cmake_parse_arguments(_gperf + "" + "" + "CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND" + ${ARGN}) + + if(NOT _gperf_CONFIGURE_COMMAND AND NOT _gperf_BUILD_COMMAND + AND NOT _gperf_INSTALL_COMMAND) + message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND") + endif() + + ExternalProject_Add(gperf + PREFIX ${DEPS_BUILD_DIR} + URL ${GPERF_URL} + DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/gperf + DOWNLOAD_COMMAND ${CMAKE_COMMAND} + -DPREFIX=${DEPS_BUILD_DIR} + -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/gperf + -DURL=${GPERF_URL} + -DEXPECTED_SHA256=${GPERF_SHA256} + -DTARGET=gperf + -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND "${_gperf_CONFIGURE_COMMAND}" + BUILD_COMMAND "${_gperf_BUILD_COMMAND}" + INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}") +endfunction() + +set(GPERF_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER}) + +if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING)) + + BuildGperf( + CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/gperf/configure + --prefix=${HOSTDEPS_INSTALL_DIR} + INSTALL_COMMAND ${MAKE_PRG} install) + +else() + message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}") +endif() + |