diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/cld3 | |
Diffstat (limited to 'vcpkg/ports/cld3')
| -rw-r--r-- | vcpkg/ports/cld3/fix-build.patch | 83 | ||||
| -rw-r--r-- | vcpkg/ports/cld3/portfile.cmake | 34 | ||||
| -rw-r--r-- | vcpkg/ports/cld3/unofficial-cld3Config.cmake | 4 | ||||
| -rw-r--r-- | vcpkg/ports/cld3/unofficial-export.patch | 24 | ||||
| -rw-r--r-- | vcpkg/ports/cld3/vcpkg.json | 19 |
5 files changed, 164 insertions, 0 deletions
diff --git a/vcpkg/ports/cld3/fix-build.patch b/vcpkg/ports/cld3/fix-build.patch new file mode 100644 index 0000000..5711d51 --- /dev/null +++ b/vcpkg/ports/cld3/fix-build.patch @@ -0,0 +1,83 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2fa3908..37e9944 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,11 +1,11 @@ + # This cmake scripts only builds a static cld3 lib and the unittests. + +-project(cld3) + + # Old versions of cmake dont search/find protobuf lite + cmake_minimum_required(VERSION 3.9) ++project(cld3) + +-find_package(Protobuf REQUIRED) ++find_package(Protobuf CONFIG REQUIRED) + message(STATUS "Protobuf_FOUND= ${Protobuf_FOUND}") + message(STATUS "Protobuf_VERSION= ${Protobuf_VERSION}") + message(WARNING "Protobuf 2.5 and CLD3 seems happy together. This script does NOT check if your verison of protobuf is compatible.") +@@ -20,9 +20,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/misc/myprotobuf.cmake) + my_protobuf_generate_cpp(cld_3/protos PROTO_SRCS PROTO_HDRS src/feature_extractor.proto src/sentence.proto src/task_spec.proto) + message(STATUS "PROTO_HDRS= ${PROTO_HDRS}") + +-add_definitions(-fPIC) # Position Independant Code +-add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) +-add_definitions(-std=c++11) # Needed for std::to_string(), ... + + include_directories(${CMAKE_CURRENT_BINARY_DIR} ${Protobuf_INCLUDE_DIRS}) # needed to include generated pb headers + +@@ -58,6 +55,10 @@ add_library(${PROJECT_NAME} + src/script_span/fixunicodevalue.cc + ) + ++target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) ++target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf-lite) ++ ++if(BUILD_TESTS) + # unit tests exec: + add_executable(language_identifier_main src/language_identifier_main.cc) + target_link_libraries(language_identifier_main cld3 ${Protobuf_LITE_LIBRARIES}) +@@ -67,3 +68,4 @@ target_link_libraries(getonescriptspan_test cld3 ${Protobuf_LITE_LIBRARIES}) + + add_executable(language_identifier_features_test src/language_identifier_features_test.cc) + target_link_libraries(language_identifier_features_test cld3 ${Protobuf_LITE_LIBRARIES}) ++endif() +diff --git a/src/base.h b/src/base.h +index 20189e2..3c610e3 100644 +--- a/src/base.h ++++ b/src/base.h +@@ -71,7 +71,7 @@ typedef unsigned short uint16; // NOLINT + typedef signed int char32; + #endif // SWIG + +-#ifdef COMPILER_MSVC ++#ifdef _MSC_VER + typedef __int64 int64; + #else + typedef long long int64; // NOLINT +diff --git a/src/script_span/utf8statetable.cc b/src/script_span/utf8statetable.cc +index 8fcfb1e..87da972 100644 +--- a/src/script_span/utf8statetable.cc ++++ b/src/script_span/utf8statetable.cc +@@ -17,7 +17,7 @@ + // 32- or 16-bit Unicode values. + // + +-#ifdef COMPILER_MSVC ++#ifdef _MSC_VER + // MSVC warns: warning C4309: 'initializing' : truncation of constant value + // But the value is in fact not truncated. 0xFF still comes out 0xFF at + // runtime. +diff --git a/src/sentence_features.h b/src/sentence_features.h +index cc0be88..e2e27d2 100644 +--- a/src/sentence_features.h ++++ b/src/sentence_features.h +@@ -34,7 +34,7 @@ using WholeSentenceExtractor = FeatureExtractor<Sentence>; + // for clang's -Wundefined-var-template. However, MSVC has a bug which treats + // this declaration as a definition, leading to multiple definition errors, so + // omit this on MSVC. +-#if !defined(COMPILER_MSVC) ++#if !defined(_MSC_VER) + template <> + WholeSentenceFeature::Registry + *RegisterableClass<WholeSentenceFeature>::registry_; diff --git a/vcpkg/ports/cld3/portfile.cmake b/vcpkg/ports/cld3/portfile.cmake new file mode 100644 index 0000000..4f204c6 --- /dev/null +++ b/vcpkg/ports/cld3/portfile.cmake @@ -0,0 +1,34 @@ +if (VCPKG_TARGET_IS_WINDOWS)
+ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+endif()
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO google/cld3
+ REF b48dc46512566f5a2d41118c8c1116c4f96dc661
+ SHA512 c3650ffbf5855aaf04d03930f01c6efd76e1f2b2d47365348721f16531a14653ae5b3aff8fefa8e5fa1c769fdf1a9b441a88bc687f97f8c579b84f17c6984c9e
+ HEAD_REF master
+ PATCHES
+ fix-build.patch
+ unofficial-export.patch
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+)
+
+vcpkg_cmake_install()
+vcpkg_copy_pdbs()
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-cld3Config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-cld3")
+vcpkg_cmake_config_fixup(CONFIG_PATH share/unofficial-cld3 PACKAGE_NAME unofficial-cld3)
+
+file(GLOB PUBLIC_HEADER_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/src/*.h")
+file(INSTALL ${PUBLIC_HEADER_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/include/cld3")
+
+file(GLOB HEADERS_SCRIPT_SPAN_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/src/script_span/*.h")
+file(INSTALL ${HEADERS_SCRIPT_SPAN_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/include/cld3/script_span")
+
+file(GLOB HEADERS_PROTO_FILES LIST_DIRECTORIES false "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/cld_3/protos/*.h")
+file(INSTALL ${HEADERS_PROTO_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/include/cld_3/protos")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
diff --git a/vcpkg/ports/cld3/unofficial-cld3Config.cmake b/vcpkg/ports/cld3/unofficial-cld3Config.cmake new file mode 100644 index 0000000..4a87abe --- /dev/null +++ b/vcpkg/ports/cld3/unofficial-cld3Config.cmake @@ -0,0 +1,4 @@ +include(CMakeFindDependencyMacro) +find_dependency(Protobuf) + +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-cld3-targets.cmake") diff --git a/vcpkg/ports/cld3/unofficial-export.patch b/vcpkg/ports/cld3/unofficial-export.patch new file mode 100644 index 0000000..99b900d --- /dev/null +++ b/vcpkg/ports/cld3/unofficial-export.patch @@ -0,0 +1,24 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 37e9944..fb27632 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -57,6 +57,19 @@ add_library(${PROJECT_NAME} + + target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) + target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf-lite) ++target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>) ++ ++install(TARGETS ${PROJECT_NAME} ++ EXPORT unofficial-cld3-targets ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++) ++ ++install(EXPORT unofficial-cld3-targets ++ NAMESPACE unofficial::cld3:: ++ DESTINATION share/unofficial-cld3 ++) + + if(BUILD_TESTS) + # unit tests exec: diff --git a/vcpkg/ports/cld3/vcpkg.json b/vcpkg/ports/cld3/vcpkg.json new file mode 100644 index 0000000..7cd1f19 --- /dev/null +++ b/vcpkg/ports/cld3/vcpkg.json @@ -0,0 +1,19 @@ +{ + "name": "cld3", + "version": "3.0.14", + "port-version": 2, + "description": "Compact Language Detector v3", + "homepage": "https://github.com/google/cld3", + "license": "Apache-2.0", + "dependencies": [ + "protobuf", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} |