Skip to content

Commit

Permalink
[GLUTEN-7049][VL] Install lib stemmer through vcpkg (apache#7050)
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE authored Aug 29, 2024
1 parent 3928dc2 commit b2ff2f5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
19 changes: 15 additions & 4 deletions cpp/velox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,22 @@ target_link_libraries(velox PUBLIC Folly::folly)
find_re2()
target_link_libraries(velox PUBLIC ${RE2_LIBRARY})

import_library(external::stemmer
${VELOX_BUILD_PATH}/_deps/libstemmer/src/libstemmer/libstemmer.a)
target_link_libraries(velox PUBLIC external::stemmer)

set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")

find_library(STEMMER_LIB NAMES libstemmer.a)
if(STEMMER_LIB)
message(STATUS "Found stemmer: ${STEMMER_LIB}")
add_library(external::stemmer STATIC IMPORTED)
set_target_properties(external::stemmer PROPERTIES IMPORTED_LOCATION
${STEMMER_LIB})
else()
import_library(
external::stemmer
${VELOX_BUILD_PATH}/_deps/libstemmer/src/libstemmer/libstemmer.a)
endif()
target_link_libraries(velox PUBLIC external::stemmer)

find_package(simdjson CONFIG)
if(simdjson_FOUND AND TARGET simdjson::simdjson)
target_link_libraries(velox PUBLIC simdjson::simdjson)
Expand All @@ -313,6 +323,7 @@ else()
${VELOX_BUILD_PATH}/_deps/simdjson-build/libsimdjson.a)
target_link_libraries(velox PUBLIC external::simdjson)
endif()

set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})

if(BUILD_TESTS)
Expand Down
22 changes: 22 additions & 0 deletions dev/vcpkg/ports/libstemmer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.8.0)

project(libstemmer)

file(GLOB SNOWBALL_SOURCES
src_c/*.c
runtime/api.c
runtime/utilities.c
libstemmer/libstemmer.c
)

add_library(stemmer ${SNOWBALL_SOURCES})

install(
TARGETS stemmer
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
if(NOT DISABLE_INSTALL_HEADERS)
install(FILES include/libstemmer.h DESTINATION include)
endif()
24 changes: 24 additions & 0 deletions dev/vcpkg/ports/libstemmer/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
string(SUBSTRING "${VERSION}" 5 -1 VERSION)

vcpkg_download_distfile(ARCHIVE
URLS "https://snowballstem.org/dist/libstemmer_c-${VERSION}.tar.gz"
FILENAME "libstemmer_c-${VERSION}.tar.gz"
SHA512 a61a06a046a6a5e9ada12310653c71afb27b5833fa9e21992ba4bdf615255de991352186a8736d0156ed754248a0ffb7b7712e8d5ea16f75174d1c8ddd37ba4a
)

vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
)

vcpkg_cmake_install()

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
12 changes: 12 additions & 0 deletions dev/vcpkg/ports/libstemmer/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "libstemmer",
"version": "2021.2.2.0",
"description": "Snowball is a small string processing language designed for creating stemming algorithms for use in Information Retrieval",
"homepage": "https://snowballstem.org/",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
}
]
}
3 changes: 2 additions & 1 deletion dev/vcpkg/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"benchmark",
"jemalloc",
"icu",
"thrift"
"thrift",
"libstemmer"
]
},
"velox-s3": {
Expand Down

0 comments on commit b2ff2f5

Please sign in to comment.