mindspore/cmake/external_libs/sentencepiece.cmake

75 lines
3.1 KiB
CMake
Raw Normal View History

2022-03-15 20:20:44 +08:00
if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/sentencepiece.git")
set(GIT_TAG "master")
2022-11-02 17:39:06 +08:00
set(SHA256 "4f88df28544b5f1a351f3dbf6b6413b8")
2022-03-15 20:20:44 +08:00
set(SENTENCEPIECE_SRC "${TOP_DIR}/build/mindspore/_deps/sentencepiece-src")
2022-11-02 17:39:06 +08:00
__download_pkg_with_git(sentencepiece ${GIT_REPOSITORY} ${GIT_TAG} ${SHA256})
2022-03-15 20:20:44 +08:00
execute_process(COMMAND tar -xf ${SENTENCEPIECE_SRC}/v0.1.92.tar.gz --strip-components 1 -C ${SENTENCEPIECE_SRC})
else()
2021-01-23 20:20:31 +08:00
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/sentencepiece/repository/archive/v0.1.92.tar.gz")
2022-11-02 17:39:06 +08:00
set(SHA256 "650325f998fb97f360bfa886a761fb5cd34d51d684b26ea53edcb5a0d9fa7601")
else()
set(REQ_URL "https://github.com/google/sentencepiece/archive/v0.1.92.tar.gz")
2022-11-02 17:39:06 +08:00
set(SHA256 "6e9863851e6277862083518cc9f96211f334215d596fc8c65e074d564baeef0c")
2021-01-23 20:20:31 +08:00
endif()
2022-03-15 20:20:44 +08:00
endif()
2021-01-23 20:20:31 +08:00
if(WIN32)
2022-08-26 10:48:53 +08:00
if(MSVC)
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 /EHsc")
else()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-stringop-overflow \
-Wno-format-extra-args -Wno-format")
endif()
2021-01-23 20:20:31 +08:00
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
2022-08-26 10:48:53 +08:00
if(MSVC)
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
2022-11-02 17:39:06 +08:00
SHA256 ${SHA256}
2022-08-26 10:48:53 +08:00
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sentencepiece/sentencepiece_msvc.patch001
)
else()
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
2022-11-02 17:39:06 +08:00
SHA256 ${SHA256}
2022-08-26 10:48:53 +08:00
)
endif()
2021-03-20 19:56:45 +08:00
else()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-sign-compare")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
if(ENABLE_GLIBCXX)
mindspore_add_pkg(sentencepiece
2021-01-23 20:20:31 +08:00
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
2021-03-20 19:56:45 +08:00
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=OFF -DSPM_ENABLE_SHARED=OFF
2021-10-25 16:59:19 +08:00
-DPROTOBUF_INC=${protobuf_INC} -DCMAKE_CXX_STANDARD=11
2022-11-02 17:39:06 +08:00
SHA256 ${SHA256}
2021-03-20 19:56:45 +08:00
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001_cpu
2021-01-23 20:20:31 +08:00
)
2021-03-20 19:56:45 +08:00
else()
mindspore_add_pkg(sentencepiece
2021-01-23 20:20:31 +08:00
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=OFF -DSPM_ENABLE_SHARED=OFF
2021-03-20 19:56:45 +08:00
-DPROTOBUF_INC=${protobuf_INC}
2022-11-02 17:39:06 +08:00
SHA256 ${SHA256}
2021-12-06 17:32:22 +08:00
PATCHES ${TOP_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001
2021-01-23 20:20:31 +08:00
)
2021-03-20 19:56:45 +08:00
endif()
2021-01-23 20:20:31 +08:00
endif()
2020-07-15 10:09:02 +08:00
include_directories(${sentencepiece_INC})
add_library(mindspore::sentencepiece ALIAS sentencepiece::sentencepiece)
2021-11-16 10:15:15 +08:00
add_library(mindspore::sentencepiece_train ALIAS sentencepiece::sentencepiece_train)