aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/kenlm
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/kenlm')
-rw-r--r--vcpkg/ports/kenlm/cmake-config.patch29
-rw-r--r--vcpkg/ports/kenlm/devendor.patch42
-rw-r--r--vcpkg/ports/kenlm/fix-boost.patch25
-rw-r--r--vcpkg/ports/kenlm/portfile.cmake52
-rw-r--r--vcpkg/ports/kenlm/vcpkg.json37
5 files changed, 185 insertions, 0 deletions
diff --git a/vcpkg/ports/kenlm/cmake-config.patch b/vcpkg/ports/kenlm/cmake-config.patch
new file mode 100644
index 0000000..5e87e68
--- /dev/null
+++ b/vcpkg/ports/kenlm/cmake-config.patch
@@ -0,0 +1,29 @@
+diff --git a/cmake/kenlmConfig.cmake.in b/cmake/kenlmConfig.cmake.in
+index 592407d..86abd36 100644
+--- a/cmake/kenlmConfig.cmake.in
++++ b/cmake/kenlmConfig.cmake.in
+@@ -5,6 +5,12 @@ include(CMakeFindDependencyMacro)
+ find_dependency(Boost)
+ find_dependency(Threads)
+ find_dependency(double-conversion CONFIG)
++if("@ENABLE_INTERPOLATE@")
++ find_dependency(Eigen3)
++ if("@OPENMP_CXX_FOUND@")
++ find_dependency(OpenMP)
++ endif()
++endif()
+
+ # Compression libs
+ if (@ZLIB_FOUND@)
+diff --git a/lm/interpolate/CMakeLists.txt b/lm/interpolate/CMakeLists.txt
+index d23e959..26b6092 100644
+--- a/lm/interpolate/CMakeLists.txt
++++ b/lm/interpolate/CMakeLists.txt
+@@ -24,6 +24,7 @@ if(ENABLE_INTERPOLATE)
+
+
+ find_package(OpenMP)
++ set(OPENMP_CXX_FOUND "${OPENMP_CXX_FOUND}" CACHE INTERNAL "For exported config")
+ if (OPENMP_CXX_FOUND)
+ target_link_libraries(kenlm_interpolate PUBLIC OpenMP::OpenMP_CXX)
+ endif()
diff --git a/vcpkg/ports/kenlm/devendor.patch b/vcpkg/ports/kenlm/devendor.patch
new file mode 100644
index 0000000..891620b
--- /dev/null
+++ b/vcpkg/ports/kenlm/devendor.patch
@@ -0,0 +1,42 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index fd08a48..7439ebf 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -128,7 +128,7 @@ install(EXPORT kenlmTargets
+ DESTINATION share/kenlm/cmake
+ )
+
+-foreach(SUBDIR IN ITEMS util util/double-conversion util/stream lm lm/builder lm/common lm/filter lm/interpolate)
++foreach(SUBDIR IN ITEMS util util/stream lm lm/builder lm/common lm/filter lm/interpolate)
+ file(GLOB HEADERS ${CMAKE_CURRENT_LIST_DIR}/${SUBDIR}/*.h ${CMAKE_CURRENT_LIST_DIR}/${SUBDIR}/*.hh)
+ install(FILES ${HEADERS} DESTINATION include/kenlm/${SUBDIR} COMPONENT headers)
+ endforeach(SUBDIR)
+diff --git a/cmake/kenlmConfig.cmake.in b/cmake/kenlmConfig.cmake.in
+index 0fbf0c6..592407d 100644
+--- a/cmake/kenlmConfig.cmake.in
++++ b/cmake/kenlmConfig.cmake.in
+@@ -4,6 +4,7 @@ include(CMakeFindDependencyMacro)
+
+ find_dependency(Boost)
+ find_dependency(Threads)
++find_dependency(double-conversion CONFIG)
+
+ # Compression libs
+ if (@ZLIB_FOUND@)
+diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt
+index 7a96ef5..3318d73 100644
+--- a/util/CMakeLists.txt
++++ b/util/CMakeLists.txt
+@@ -32,10 +32,11 @@ if (WIN32)
+ endif()
+
+ # This directory has children that need to be processed
+-add_subdirectory(double-conversion)
++find_package(double-conversion CONFIG REQUIRED)
+ add_subdirectory(stream)
+
+ add_library(kenlm_util ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM_SOURCE} ${KENLM_UTIL_SOURCE})
++target_link_libraries(kenlm_util PRIVATE double-conversion::double-conversion)
+ # Since headers are relative to `include/kenlm` at install time, not just `include`
+ target_include_directories(kenlm_util PUBLIC $<INSTALL_INTERFACE:include/kenlm>)
+
diff --git a/vcpkg/ports/kenlm/fix-boost.patch b/vcpkg/ports/kenlm/fix-boost.patch
new file mode 100644
index 0000000..77d23d8
--- /dev/null
+++ b/vcpkg/ports/kenlm/fix-boost.patch
@@ -0,0 +1,25 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3c6c863..fd08a48 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,6 +1,6 @@
+ cmake_minimum_required(VERSION 3.1)
+
+-if (WIN32)
++if (0)
+ set(Boost_USE_STATIC_LIBS OFF)
+ # The auto-linking feature has problems with USE_STATIC_LIBS off, so we use
+ # BOOST_ALL_NO_LIB to turn it off.
+@@ -100,6 +100,12 @@ find_package(Boost 1.41.0 REQUIRED COMPONENTS
+ thread
+ unit_test_framework
+ )
++set(Boost_LIBRARIES
++ Boost::program_options
++ Boost::system
++ Boost::thread
++ Boost::unit_test_framework
++)
+
+ # Define where include files live
+ include_directories(${Boost_INCLUDE_DIRS})
diff --git a/vcpkg/ports/kenlm/portfile.cmake b/vcpkg/ports/kenlm/portfile.cmake
new file mode 100644
index 0000000..bc57af0
--- /dev/null
+++ b/vcpkg/ports/kenlm/portfile.cmake
@@ -0,0 +1,52 @@
+if(VCPKG_TARGET_IS_WINDOWS)
+ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+endif()
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO kpu/kenlm
+ REF 5bf7b46558e1c5595bf3b8c9b0b1f9d8d257040a
+ SHA512 04b645d09e60b65cb1e5065a1623ad01737f0dd9415cf620288ace0db10b1c424d72f304b34c52fa08684f3fecdaad9db91088134f34ed374cb1eb9d58c635b5
+ HEAD_REF master
+ PATCHES
+ devendor.patch
+ cmake-config.patch
+ fix-boost.patch
+)
+file(REMOVE_RECURSE
+ "${SOURCE_PATH}/cmake/modules/FindEigen3.cmake"
+ "${SOURCE_PATH}/util/double-conversion"
+)
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ interpolate ENABLE_INTERPOLATE
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ ${FEATURE_OPTIONS}
+ -DCMAKE_CXX_STANDARD=11 # 17 removes std::binary_function
+ -DFORCE_STATIC=OFF # handled by vcpkg
+ -DENABLE_PYTHON=OFF # kenlm.lib(bhiksha.cc.obj) : fatal error LNK1000: Internal error during IMAGE::Pass2
+ -DCOMPILE_TESTS=OFF
+)
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(CONFIG_PATH share/kenlm/cmake)
+
+set(KENLM_TOOLS count_ngrams filter fragment kenlm_benchmark lmplz phrase_table_vocab query build_binary)
+if (NOT VCPKG_TARGET_IS_WINDOWS)
+ list(APPEND KENLM_TOOLS probing_hash_table_benchmark)
+endif()
+if ("interpolate" IN_LIST FEATURES)
+ list(APPEND KENLM_TOOLS interpolate)
+endif()
+vcpkg_copy_tools(TOOL_NAMES ${KENLM_TOOLS} AUTO_CLEAN)
+
+vcpkg_copy_pdbs()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE" "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/LICENSE")
diff --git a/vcpkg/ports/kenlm/vcpkg.json b/vcpkg/ports/kenlm/vcpkg.json
new file mode 100644
index 0000000..09dd862
--- /dev/null
+++ b/vcpkg/ports/kenlm/vcpkg.json
@@ -0,0 +1,37 @@
+{
+ "name": "kenlm",
+ "version": "20230531",
+ "port-version": 1,
+ "description": "KenLM: Faster and Smaller Language Model Queries",
+ "license": null,
+ "supports": "!(arm64 & windows)",
+ "dependencies": [
+ "boost-interprocess",
+ "boost-program-options",
+ "boost-ptr-container",
+ "boost-system",
+ "boost-test",
+ "boost-thread",
+ "bzip2",
+ "double-conversion",
+ "liblzma",
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ },
+ "zlib"
+ ],
+ "features": {
+ "interpolate": {
+ "description": "Build interpolation program",
+ "supports": "!windows",
+ "dependencies": [
+ "eigen3"
+ ]
+ }
+ }
+}