From baad52570ff20539eb5cb11945ebffbc041b879a Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Thu, 4 Jan 2024 02:33:26 +0100 Subject: [PATCH] [kenlm] Fixes and cleanup (#35907) --- ports/kenlm/cmake-config.patch | 29 ++++++++++++++ ports/kenlm/devendor.patch | 42 ++++++++++++++++++++ ports/kenlm/fix-boost-imported-targets.patch | 33 --------------- ports/kenlm/fix-boost.patch | 17 +++++++- ports/kenlm/portfile.cmake | 27 ++++++++----- ports/kenlm/vcpkg.json | 9 ++--- versions/baseline.json | 2 +- versions/k-/kenlm.json | 5 +++ 8 files changed, 112 insertions(+), 52 deletions(-) create mode 100644 ports/kenlm/cmake-config.patch create mode 100644 ports/kenlm/devendor.patch delete mode 100644 ports/kenlm/fix-boost-imported-targets.patch diff --git a/ports/kenlm/cmake-config.patch b/ports/kenlm/cmake-config.patch new file mode 100644 index 0000000000..5e87e68893 --- /dev/null +++ b/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/ports/kenlm/devendor.patch b/ports/kenlm/devendor.patch new file mode 100644 index 0000000000..891620b769 --- /dev/null +++ b/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 $) + diff --git a/ports/kenlm/fix-boost-imported-targets.patch b/ports/kenlm/fix-boost-imported-targets.patch deleted file mode 100644 index f1987ca436..0000000000 --- a/ports/kenlm/fix-boost-imported-targets.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt -index 7a96ef5..0708d8a 100644 ---- a/util/CMakeLists.txt -+++ b/util/CMakeLists.txt -@@ -85,7 +85,10 @@ set_target_properties(kenlm_util PROPERTIES POSITION_INDEPENDENT_CODE ON) - target_link_libraries(kenlm_util - PUBLIC - # Boost is required for building binaries and tests -- "$" -+ $ -+ $ -+ $ -+ $ - PRIVATE - Threads::Threads - ${RT}) -diff --git a/util/stream/CMakeLists.txt b/util/stream/CMakeLists.txt -index be2fe00..a7e7df5 100644 ---- a/util/stream/CMakeLists.txt -+++ b/util/stream/CMakeLists.txt -@@ -35,5 +35,11 @@ if(BUILD_TESTING) - ) - - AddTests(TESTS ${KENLM_BOOST_TESTS_LIST} -- LIBRARIES kenlm_util ${Boost_LIBRARIES} Threads::Threads) -+ LIBRARIES -+ kenlm_util -+ Boost::program_options -+ Boost::system -+ Boost::thread -+ Boost::unit_test_framework -+ Threads::Threads) - endif() diff --git a/ports/kenlm/fix-boost.patch b/ports/kenlm/fix-boost.patch index 3eded1c69c..77d23d8172 100644 --- a/ports/kenlm/fix-boost.patch +++ b/ports/kenlm/fix-boost.patch @@ -1,12 +1,25 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index bec81d4..44fd48a 100644 +index 3c6c863..fd08a48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) -if (WIN32) -+if (WIN32 AND BUILD_SHARED_LIBS) ++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/ports/kenlm/portfile.cmake b/ports/kenlm/portfile.cmake index 15917d9253..bc57af00e8 100644 --- a/ports/kenlm/portfile.cmake +++ b/ports/kenlm/portfile.cmake @@ -1,4 +1,6 @@ -vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -7,11 +9,14 @@ vcpkg_from_github( SHA512 04b645d09e60b65cb1e5065a1623ad01737f0dd9415cf620288ace0db10b1c424d72f304b34c52fa08684f3fecdaad9db91088134f34ed374cb1eb9d58c635b5 HEAD_REF master PATCHES + devendor.patch + cmake-config.patch fix-boost.patch - fix-boost-imported-targets.patch ) - -file(REMOVE "${SOURCE_PATH}/cmake/modules/FindEigen3.cmake") +file(REMOVE_RECURSE + "${SOURCE_PATH}/cmake/modules/FindEigen3.cmake" + "${SOURCE_PATH}/util/double-conversion" +) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES @@ -22,19 +27,20 @@ vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} - -DFORCE_STATIC=OFF #already handled by vcpkg + -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/${PORT}/cmake) +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) - if ("interpolate" IN_LIST FEATURES) - list(APPEND KENLM_TOOLS interpolate) - endif() +endif() +if ("interpolate" IN_LIST FEATURES) + list(APPEND KENLM_TOOLS interpolate) endif() vcpkg_copy_tools(TOOL_NAMES ${KENLM_TOOLS} AUTO_CLEAN) @@ -43,5 +49,4 @@ vcpkg_copy_pdbs() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") -# Copyright and License -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/LICENSE") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE" "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/LICENSE") diff --git a/ports/kenlm/vcpkg.json b/ports/kenlm/vcpkg.json index 4eaffd89e6..09dd862010 100644 --- a/ports/kenlm/vcpkg.json +++ b/ports/kenlm/vcpkg.json @@ -1,8 +1,9 @@ { "name": "kenlm", "version": "20230531", + "port-version": 1, "description": "KenLM: Faster and Smaller Language Model Queries", - "license": "LGPL-2.1", + "license": null, "supports": "!(arm64 & windows)", "dependencies": [ "boost-interprocess", @@ -12,6 +13,7 @@ "boost-test", "boost-thread", "bzip2", + "double-conversion", "liblzma", { "name": "vcpkg-cmake", @@ -28,10 +30,7 @@ "description": "Build interpolation program", "supports": "!windows", "dependencies": [ - { - "name": "eigen3", - "platform": "!windows" - } + "eigen3" ] } } diff --git a/versions/baseline.json b/versions/baseline.json index 612b77ab82..cb23f21305 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3754,7 +3754,7 @@ }, "kenlm": { "baseline": "20230531", - "port-version": 0 + "port-version": 1 }, "kerbal": { "baseline": "2023.12.1", diff --git a/versions/k-/kenlm.json b/versions/k-/kenlm.json index b0d7dbb03d..33d960b7b3 100644 --- a/versions/k-/kenlm.json +++ b/versions/k-/kenlm.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "3473d89b5d9e5bfc847a3b3575a5843b729b71ee", + "version": "20230531", + "port-version": 1 + }, { "git-tree": "bb9e0ae36b74ecd5bfb6a8855e761138eeda9185", "version": "20230531",