[vcpkg baseline][sentencepiece] Fix flags, linkage, deps (#42226)

This commit is contained in:
Kai Pastor 2024-11-19 07:06:06 +01:00 committed by GitHub
parent d81fa4b050
commit 2a8dc1b6d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 101 additions and 14 deletions

View File

@ -0,0 +1,29 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9fa37fa..0e220e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,9 @@ elseif (SPM_ABSL_PROVIDER STREQUAL "package")
find_package(absl REQUIRED)
get_target_property(ABSL_INCLUDE_DIRS absl::base INTERFACE_INCLUDE_DIRECTORIES)
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl.org)
+ file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl)
+ file(COPY "${ABSL_INCLUDE_DIRS}/absl" DESTINATION "${PROJECT_BINARY_DIR}/third_party")
+ elseif(0)
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl.org)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${ABSL_INCLUDE_DIRS}/absl ${CMAKE_CURRENT_SOURCE_DIR}/third_party/absl)
diff --git a/src/sentencepiece_processor.h b/src/sentencepiece_processor.h
index dd3f092..c1551a7 100644
--- a/src/sentencepiece_processor.h
+++ b/src/sentencepiece_processor.h
@@ -23,9 +23,7 @@
#include <vector>
#ifndef SWIG
-namespace absl {
-using std::string_view;
-} // namespace absl
+#include <absl/strings/string_view.h>
#endif // SWIG
namespace sentencepiece {

View File

@ -0,0 +1,12 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d983089..19736d8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -264,7 +264,6 @@ if (NOT MSVC)
if (SPM_COVERAGE)
set(CMAKE_CXX_FLAGS "-O0 -Wall -fPIC -coverage ${CMAKE_CXX_FLAGS}")
else()
- set(CMAKE_CXX_FLAGS "-O3 -Wall -fPIC ${CMAKE_CXX_FLAGS}")
endif()
if (SPM_ENABLE_TENSORFLOW_SHARED)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

View File

@ -0,0 +1,13 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8d4a34f..6ef8aa9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -250,6 +250,8 @@ if (SPM_ENABLE_SHARED)
set_target_properties(sentencepiece PROPERTIES IMPORT_SUFFIX ".dll.a")
set_target_properties(sentencepiece_train PROPERTIES IMPORT_SUFFIX ".dll.a")
endif()
+ list(REMOVE_ITEM SPM_INSTALLTARGETS sentencepiece-static sentencepiece_train-static)
+ set_target_properties(sentencepiece-static sentencepiece_train-static PROPERTIES EXCLUDE_FROM_ALL 1)
else()
add_library(sentencepiece ALIAS sentencepiece-static)
add_library(sentencepiece_train ALIAS sentencepiece_train-static)

View File

@ -1,31 +1,37 @@
if(NOT VCPKG_CMAKE_SYSTEM_NAME)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_STATIC_CRT)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/sentencepiece
REF "v${VERSION}"
SHA512 b4214f5bfbe2a0757794c792e87e7c53fda7e65b2511b37fc757f280bf9287ba59b5d630801e17de6058f8292a3c6433211917324cb3446a212a51735402e614
SHA512 b4214f5bfbe2a0757794c792e87e7c53fda7e65b2511b37fc757f280bf9287ba59b5d630801e17de6058f8292a3c6433211917324cb3446a212a51735402e614
HEAD_REF master
PATCHES
abseil.diff
cxxflags.diff
linkage.diff
protobuf.diff
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SPM_ENABLE_SHARED)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DSPM_ENABLE_SHARED=OFF
-DSPM_USE_BUILTIN_PROTOBUF=ON
-DSPM_USE_EXTERNAL_ABSL=OFF
-DSPM_ENABLE_SHARED=${SPM_ENABLE_SHARED}
-DSPM_ENABLE_TCMALLOC=OFF
-DSPM_ABSL_PROVIDER=package
-DSPM_PROTOBUF_PROVIDER=package
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
vcpkg_copy_tools(TOOL_NAMES spm_decode spm_encode spm_export_vocab spm_normalize spm_train AUTO_CLEAN)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
vcpkg_copy_tools(TOOL_NAMES spm_decode spm_encode spm_export_vocab spm_normalize spm_train AUTO_CLEAN)
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

View File

@ -0,0 +1,19 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6ef8aa9..d983089 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -70,12 +70,11 @@ if (SPM_PROTOBUF_PROVIDER STREQUAL "internal")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/protobuf-lite)
include_directories(builtin_pb)
elseif (SPM_PROTOBUF_PROVIDER STREQUAL "package")
- find_package(Protobuf REQUIRED)
- include_directories(${Protobuf_INCLUDE_DIRS})
+ find_package(protobuf CONFIG REQUIRED)
+ set(PROTOBUF_LITE_LIBRARY protobuf::libprotobuf-lite)
protobuf_generate_cpp(SPM_PROTO_SRCS SPM_PROTO_HDRS sentencepiece.proto)
protobuf_generate_cpp(SPM_MODEL_PROTO_SRCS SPM_MODEL_PROTO_HDRS sentencepiece_model.proto)
set(PROTOBUF_LITE_SRCS "")
- include_directories(${PROTOBUF_INCLUDE_DIR})
if (MSVC)
add_definitions("/D_USE_EXTERNAL_PROTOBUF")
else()

View File

@ -1,10 +1,13 @@
{
"name": "sentencepiece",
"version": "0.2.0",
"port-version": 1,
"description": "SentencePiece is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation systems where the vocabulary size is predetermined prior to the neural model training",
"homepage": "https://github.com/google/sentencepiece",
"license": "Apache-2.0",
"supports": "static",
"dependencies": [
"abseil",
"protobuf",
{
"name": "vcpkg-cmake",
"host": true

View File

@ -8266,7 +8266,7 @@
},
"sentencepiece": {
"baseline": "0.2.0",
"port-version": 0
"port-version": 1
},
"sentry-native": {
"baseline": "0.7.12",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "626e5f5d9e302b9095128148ff4ccd046486c13e",
"version": "0.2.0",
"port-version": 1
},
{
"git-tree": "60678651110bfbd252017ee568f2cb6484aaaf46",
"version": "0.2.0",